set up "go to the time machine" button working

This commit is contained in:
kamilprzyb 2020-09-24 21:51:25 +02:00
parent c33f218e56
commit df936e8c9c
4 changed files with 22 additions and 7 deletions

View File

@ -18,6 +18,7 @@ std::vector<WarpLocation> NPCManager::RespawnPoints;
void NPCManager::init() { void NPCManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TIME_TO_GO_WARP, npcWarpTimeMachine);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_SUMMON, npcSummonHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_SUMMON, npcSummonHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_UNSUMMON, npcUnsummonHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_UNSUMMON, npcUnsummonHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_BARKER, npcBarkHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_BARKER, npcBarkHandler);
@ -499,17 +500,28 @@ void NPCManager::npcWarpHandler(CNSocket* sock, CNPacketData* data) {
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_PC_WARP_USE_NPC* warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf; sP_CL2FE_REQ_PC_WARP_USE_NPC* warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf;
PlayerView& plrv = PlayerManager::players[sock]; handleWarp(sock, warpNpc->iWarpID);
}
void NPCManager::npcWarpTimeMachine(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TIME_TO_GO_WARP))
return; // malformed packet
// this is just a warp request
handleWarp(sock, 28);
}
void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
// sanity check // sanity check
if (Warps.find(warpNpc->iWarpID) == Warps.end()) if (Warps.find(warpId) == Warps.end())
return; return;
PlayerView& plrv = PlayerManager::players[sock];
// send to client // send to client
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp);
resp.iX = Warps[warpNpc->iWarpID].x; resp.iX = Warps[warpId].x;
resp.iY = Warps[warpNpc->iWarpID].y; resp.iY = Warps[warpId].y;
resp.iZ = Warps[warpNpc->iWarpID].z; resp.iZ = Warps[warpId].z;
// force player & NPC reload // force player & NPC reload
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock); PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);

View File

@ -28,6 +28,7 @@ namespace NPCManager {
void npcSummonHandler(CNSocket* sock, CNPacketData* data); void npcSummonHandler(CNSocket* sock, CNPacketData* data);
void npcUnsummonHandler(CNSocket* sock, CNPacketData* data); void npcUnsummonHandler(CNSocket* sock, CNPacketData* data);
void npcWarpHandler(CNSocket* sock, CNPacketData* data); void npcWarpHandler(CNSocket* sock, CNPacketData* data);
void npcWarpTimeMachine(CNSocket* sock, CNPacketData* data);
void npcVendorStart(CNSocket* sock, CNPacketData* data); void npcVendorStart(CNSocket* sock, CNPacketData* data);
void npcVendorTable(CNSocket* sock, CNPacketData* data); void npcVendorTable(CNSocket* sock, CNPacketData* data);
@ -36,4 +37,6 @@ namespace NPCManager {
void npcVendorBuyback(CNSocket* sock, CNPacketData* data); void npcVendorBuyback(CNSocket* sock, CNPacketData* data);
void npcVendorBuyBattery(CNSocket* sock, CNPacketData* data); void npcVendorBuyBattery(CNSocket* sock, CNPacketData* data);
void npcCombineItems(CNSocket* sock, CNPacketData* data); void npcCombineItems(CNSocket* sock, CNPacketData* data);
void handleWarp(CNSocket* sock, int32_t warpId);
} }