diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index ae39a3e..443cf52 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -8,6 +8,7 @@ #include "TableData.hpp" #include "ChatManager.hpp" #include "GroupManager.hpp" +#include "RacingManager.hpp" #include #include @@ -611,8 +612,13 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) { plr->instanceID = INSTANCE_OVERWORLD; MissionManager::failInstancedMissions(sock); // fail any instanced missions sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC)); + ChunkManager::updatePlayerChunk(sock, plr->chunkPos, std::make_tuple(0, 0, 0)); // force player to reload chunks PlayerManager::updatePlayerPosition(sock, resp.iX, resp.iY, resp.iZ, INSTANCE_OVERWORLD, plr->angle); + + // remove the player's ongoing race, if any + if (RacingManager::EPRaces.find(sock) != RacingManager::EPRaces.end()) + RacingManager::EPRaces.erase(sock); } } diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 9507c95..6a6a1a0 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -101,6 +101,10 @@ void PlayerManager::removePlayer(CNSocket* key) { it++; } + // remove the player's ongoing race, if any + if (RacingManager::EPRaces.find(key) != RacingManager::EPRaces.end()) + RacingManager::EPRaces.erase(key); + std::cout << players.size() << " players" << std::endl; } @@ -171,6 +175,10 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I // post-warp: check if the source instance has no more players in it and delete it if so ChunkManager::destroyInstanceIfEmpty(fromInstance); + // clean up EPRaces if we were likely in an IZ + if (fromInstance != INSTANCE_OVERWORLD + && RacingManager::EPRaces.find(sock) != RacingManager::EPRaces.end()) + RacingManager::EPRaces.erase(sock); } void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {