mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Finish MSS commands + convert stack to vector
This commit is contained in:
parent
47da895544
commit
a9837d6c1b
@ -2,6 +2,7 @@
|
|||||||
#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 "TableData.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -54,7 +55,7 @@ void accessCommand(std::string full, std::vector<std::string>& args, CNSocket* s
|
|||||||
void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/reload/export> <<height>>");
|
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +70,12 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
|
|||||||
|
|
||||||
if (args.size() < 3) {
|
if (args.size() < 3) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/reload/export> <<height>>");
|
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the route (if it doesn't exist yet, this will also make it)
|
// get the route (if it doesn't exist yet, this will also make it)
|
||||||
std::stack<WarpLocation>* route = &TableData::RunningSkywayRoutes[routeNum];
|
std::vector<WarpLocation>* route = &TableData::RunningSkywayRoutes[routeNum];
|
||||||
|
|
||||||
// mss <route> add <height>
|
// mss <route> add <height>
|
||||||
if (args[2] == "add") {
|
if (args[2] == "add") {
|
||||||
@ -93,7 +94,7 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
route->push({ plr->x, plr->y, height }); // add point to stack
|
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));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,8 +106,8 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WarpLocation pulled = route->top();
|
WarpLocation pulled = route->back();
|
||||||
route->pop(); // remove point at top of stack
|
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));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,32 +119,38 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WarpLocation pulled = route->top();
|
WarpLocation pulled = route->back();
|
||||||
// simulate goto
|
PlayerManager::sendPlayerTo(sock, pulled.x, pulled.y, pulled.z);
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_GOTO_SUCC, pkt);
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
|
||||||
PlayerManager::updatePlayerPosition(sock, pulled.x, pulled.y, pulled.z);
|
|
||||||
pkt.iX = pulled.x;
|
|
||||||
pkt.iY = pulled.y;
|
|
||||||
pkt.iZ = pulled.z;
|
|
||||||
sock->sendPacket((void*)&pkt, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss <route> clear
|
// mss <route> clear
|
||||||
if (args[2] == "clear") {
|
if (args[2] == "clear") {
|
||||||
// clear the stack
|
route->clear();
|
||||||
while (!route->empty()) {
|
|
||||||
route->pop();
|
|
||||||
}
|
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Cleared route " + std::to_string(routeNum));
|
ChatManager::sendServerMessage(sock, "[MSS] Cleared route " + std::to_string(routeNum));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss <route> reload
|
// mss <route> reload
|
||||||
if (args[2] == "reload") {
|
if (args[2] == "test") {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] reload on " + std::to_string(routeNum));
|
if (route->empty()) {
|
||||||
// TODO: inject route and reload
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,7 +12,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
std::map<int32_t, std::stack<WarpLocation>> TableData::RunningSkywayRoutes;
|
std::map<int32_t, std::vector<WarpLocation>> TableData::RunningSkywayRoutes;
|
||||||
|
|
||||||
void TableData::init() {
|
void TableData::init() {
|
||||||
int32_t nextId = 0;
|
int32_t nextId = 0;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
#include "contrib/JSON.hpp"
|
#include "contrib/JSON.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
|
|
||||||
namespace TableData {
|
namespace TableData {
|
||||||
extern std::map<int32_t, std::stack<WarpLocation>> RunningSkywayRoutes;
|
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