mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
commit
5015e2575d
@ -2,6 +2,8 @@
|
|||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "ChatManager.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
|
#include "TransportManager.hpp"
|
||||||
|
#include "TableData.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -50,6 +52,120 @@ void accessCommand(std::string full, std::vector<std::string>& args, CNSocket* s
|
|||||||
ChatManager::sendServerMessage(sock, "Your access level is " + std::to_string(PlayerManager::getPlayer(sock)->accountLevel));
|
ChatManager::sendServerMessage(sock, "Your access level is " + std::to_string(PlayerManager::getPlayer(sock)->accountLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate route number
|
||||||
|
char* routeNumC;
|
||||||
|
int routeNum = std::strtol(args[1].c_str(), &routeNumC, 10);
|
||||||
|
if (*routeNumC) {
|
||||||
|
// not an integer
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Invalid route number '" + args[1] + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size() < 3) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the route (if it doesn't exist yet, this will also make it)
|
||||||
|
std::vector<WarpLocation>* route = &TableData::RunningSkywayRoutes[routeNum];
|
||||||
|
|
||||||
|
// mss <route> add <height>
|
||||||
|
if (args[2] == "add") {
|
||||||
|
// make sure height token exists
|
||||||
|
if (args.size() < 4) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Point height must be specified");
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> add <height>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// validate height token
|
||||||
|
char* heightC;
|
||||||
|
int height = std::strtol(args[3].c_str(), &heightC, 10);
|
||||||
|
if (*heightC) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Invalid height " + args[3]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
route->push_back({ plr->x, plr->y, height }); // add point
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Added point (" + std::to_string(plr->x) + ", " + std::to_string(plr->y) + ", " + std::to_string(height) + ") to route " + std::to_string(routeNum));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss <route> remove
|
||||||
|
if (args[2] == "remove") {
|
||||||
|
if (route->empty()) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarpLocation pulled = route->back();
|
||||||
|
route->pop_back(); // remove point at top of stack
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Removed point (" + std::to_string(pulled.x) + ", " + std::to_string(pulled.y) + ", " + std::to_string(pulled.z) + ") from route " + std::to_string(routeNum));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss <route> goto
|
||||||
|
if (args[2] == "goto") {
|
||||||
|
if (route->empty()) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarpLocation pulled = route->back();
|
||||||
|
PlayerManager::sendPlayerTo(sock, pulled.x, pulled.y, pulled.z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss <route> clear
|
||||||
|
if (args[2] == "clear") {
|
||||||
|
route->clear();
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Cleared route " + std::to_string(routeNum));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss <route> reload
|
||||||
|
if (args[2] == "test") {
|
||||||
|
if (route->empty()) {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IMPROMPTU LERP
|
||||||
|
int speed = 1500; // TODO: make this adjustable
|
||||||
|
std::queue<WarpLocation> path;
|
||||||
|
WarpLocation last = route->front(); // start pos
|
||||||
|
PlayerManager::sendPlayerTo(sock, last.x, last.y, last.z); // send the player to the start of the path
|
||||||
|
for (int i = 1; i < route->size(); i++) {
|
||||||
|
WarpLocation coords = route->at(i);
|
||||||
|
TransportManager::lerp(&path, last, coords, speed);
|
||||||
|
path.push(coords); // add keyframe to the queue
|
||||||
|
last = coords; // update start pos
|
||||||
|
}
|
||||||
|
|
||||||
|
TransportManager::SkywayQueues[sock] = path;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss <route> export
|
||||||
|
if (args[2] == "export") {
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] export on " + std::to_string(routeNum));
|
||||||
|
// TODO: dump route to tdata
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mss ????
|
||||||
|
ChatManager::sendServerMessage(sock, "[MSS] Unknown command '" + args[2] + "'");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ChatManager::init() {
|
void ChatManager::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
||||||
@ -58,6 +174,7 @@ void ChatManager::init() {
|
|||||||
registerCommand("test", 1, testCommand);
|
registerCommand("test", 1, testCommand);
|
||||||
registerCommand("access", 100, accessCommand);
|
registerCommand("access", 100, accessCommand);
|
||||||
// TODO: add help command
|
// TODO: add help command
|
||||||
|
registerCommand("mss", 100, mssCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr) {
|
void ChatManager::registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr) {
|
||||||
|
@ -212,6 +212,27 @@ void PlayerManager::updatePlayerChunk(CNSocket* sock, int X, int Y) {
|
|||||||
view.currentChunks = allChunks;
|
view.currentChunks = allChunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, int I) {
|
||||||
|
getPlayer(sock)->instanceID = I;
|
||||||
|
sendPlayerTo(sock, X, Y, Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
||||||
|
|
||||||
|
PlayerManager::updatePlayerPosition(sock, X, Y, Z);
|
||||||
|
INITSTRUCT(sP_FE2CL_REP_PC_GOTO_SUCC, pkt);
|
||||||
|
pkt.iX = X;
|
||||||
|
pkt.iY = Y;
|
||||||
|
pkt.iZ = Z;
|
||||||
|
|
||||||
|
// force player & NPC reload
|
||||||
|
PlayerView& plrv = players[sock];
|
||||||
|
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||||
|
plrv.currentChunks.clear();
|
||||||
|
plrv.chunkPos = std::make_tuple(0, 0, plrv.plr->instanceID);
|
||||||
|
sock->sendPacket((void*)&pkt, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER))
|
||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
@ -638,16 +659,7 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
std::cout << "\tZ: " << gotoData->iToZ << std::endl;
|
std::cout << "\tZ: " << gotoData->iToZ << std::endl;
|
||||||
)
|
)
|
||||||
|
|
||||||
response.iX = plrv.plr->x = gotoData->iToX;
|
sendPlayerTo(sock, gotoData->iToX, gotoData->iToY, gotoData->iToZ);
|
||||||
response.iY = plrv.plr->y = gotoData->iToY;
|
|
||||||
response.iZ = plrv.plr->z = gotoData->iToZ;
|
|
||||||
|
|
||||||
// force player & NPC reload
|
|
||||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
|
||||||
plrv.currentChunks.clear();
|
|
||||||
plrv.chunkPos = std::make_tuple(0, 0, plrv.plr->instanceID);
|
|
||||||
|
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||||
|
@ -34,6 +34,9 @@ namespace PlayerManager {
|
|||||||
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, int angle);
|
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, int angle);
|
||||||
void updatePlayerChunk(CNSocket* sock, int X, int Y);
|
void updatePlayerChunk(CNSocket* sock, int X, int Y);
|
||||||
|
|
||||||
|
void sendPlayerTo(CNSocket* sock, int X, int Y, int Z, int I);
|
||||||
|
void sendPlayerTo(CNSocket* sock, int X, int Y, int Z);
|
||||||
|
|
||||||
void sendToViewable(CNSocket* sock, void* buf, uint32_t type, size_t size);
|
void sendToViewable(CNSocket* sock, void* buf, uint32_t type, size_t size);
|
||||||
|
|
||||||
void enterPlayer(CNSocket* sock, CNPacketData* data);
|
void enterPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
std::map<int32_t, std::vector<WarpLocation>> TableData::RunningSkywayRoutes;
|
||||||
|
|
||||||
void TableData::init() {
|
void TableData::init() {
|
||||||
int32_t nextId = 0;
|
int32_t nextId = 0;
|
||||||
|
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "contrib/JSON.hpp"
|
#include "contrib/JSON.hpp"
|
||||||
|
#include "NPCManager.hpp"
|
||||||
|
|
||||||
namespace TableData {
|
namespace TableData {
|
||||||
|
extern std::map<int32_t, std::vector<WarpLocation>> RunningSkywayRoutes;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user