Cleaned up warp code.

This commit is contained in:
Gent 2020-10-22 13:14:24 -04:00
parent 512647974d
commit 2b650b0bed
2 changed files with 10 additions and 12 deletions

View File

@ -584,18 +584,8 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
if (Warps.find(warpId) == Warps.end()) if (Warps.find(warpId) == Warps.end())
return; return;
MissionManager::failInstancedMissions(sock); // fail any missions that require the player's current instance
uint64_t fromInstance = plrv.plr->instanceID; // saved for post-warp uint64_t fromInstance = plrv.plr->instanceID; // saved for post-warp
if (plrv.plr->instanceID == 0) {
// save last uninstanced coords
plrv.plr->lastX = plrv.plr->x;
plrv.plr->lastY = plrv.plr->y;
plrv.plr->lastZ = plrv.plr->z;
plrv.plr->lastAngle = plrv.plr->angle;
}
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl; // std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
if (Warps[warpId].isInstance) { if (Warps[warpId].isInstance) {
uint64_t instanceID = Warps[warpId].instanceID; uint64_t instanceID = Warps[warpId].instanceID;

View File

@ -231,6 +231,16 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
PlayerView& plrv = PlayerManager::players[sock]; PlayerView& plrv = PlayerManager::players[sock];
Player* plr = plrv.plr; Player* plr = plrv.plr;
if (plrv.plr->instanceID == 0) {
// save last uninstanced coords
plrv.plr->lastX = plrv.plr->x;
plrv.plr->lastY = plrv.plr->y;
plrv.plr->lastZ = plrv.plr->z;
plrv.plr->lastAngle = plrv.plr->angle;
}
MissionManager::failInstancedMissions(sock); // fail any instanced missions
uint64_t fromInstance = plr->instanceID; uint64_t fromInstance = plr->instanceID;
plr->instanceID = I; plr->instanceID = I;
@ -242,7 +252,6 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
sendPlayerTo(sock, X, Y, Z); sendPlayerTo(sock, X, Y, Z);
} else { } else {
// annoying but necessary to set the flag back // annoying but necessary to set the flag back
MissionManager::failInstancedMissions(sock); // fail any instanced missions
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp);
resp.iX = X; resp.iX = X;
resp.iY = Y; resp.iY = Y;
@ -702,7 +711,6 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
std::cout << "\tZ: " << gotoData->iToZ << std::endl; std::cout << "\tZ: " << gotoData->iToZ << std::endl;
) )
MissionManager::failInstancedMissions(sock); // this ensures warping by command still fails instanced missions
sendPlayerTo(sock, gotoData->iToX, gotoData->iToY, gotoData->iToZ, 0); sendPlayerTo(sock, gotoData->iToX, gotoData->iToY, gotoData->iToZ, 0);
} }