Make sure the current race is cleared when leaving an IZ

This commit is contained in:
dongresource 2020-12-28 17:51:57 +01:00
parent 07a930fe1c
commit 55431362a7
2 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "TableData.hpp"
#include "ChatManager.hpp"
#include "GroupManager.hpp"
#include "RacingManager.hpp"
#include <cmath>
#include <algorithm>
@ -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);
}
}

View File

@ -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) {