From 609d3cdb99f99c86afcd3841a3f691b70f276199 Mon Sep 17 00:00:00 2001 From: Gent S Date: Sun, 25 Oct 2020 18:14:35 -0400 Subject: [PATCH] Remove redundant instance deletion --- src/ChunkManager.cpp | 3 ++- src/NPCManager.cpp | 5 ----- src/PlayerManager.cpp | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ChunkManager.cpp b/src/ChunkManager.cpp index 798a7e4..e5c11d7 100644 --- a/src/ChunkManager.cpp +++ b/src/ChunkManager.cpp @@ -267,8 +267,9 @@ void ChunkManager::createInstance(uint64_t instanceID) { } void ChunkManager::destroyInstance(uint64_t instanceID) { - std::cout << "Deleting instance " << instanceID << std::endl; + std::vector> instanceChunks = ChunkManager::getChunksInMap(instanceID); + std::cout << "Deleting instance " << instanceID << " (" << instanceChunks.size() << " chunks)" << std::endl; for (std::tuple& coords : instanceChunks) { destroyChunk(coords); } diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index d8ab954..f45fd57 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -584,8 +584,6 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) { if (Warps.find(warpId) == Warps.end()) return; - uint64_t fromInstance = plrv.plr->instanceID; // saved for post-warp - // std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl; if (Warps[warpId].isInstance) { uint64_t instanceID = Warps[warpId].instanceID; @@ -625,9 +623,6 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) { plrv.plr->instanceID = INSTANCE_OVERWORLD; sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC)); } - - // post-warp: check if the source instance has no more players in it and delete it if so - ChunkManager::destroyInstanceIfEmpty(fromInstance); } /* diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index fa6b375..9527b9e 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -241,7 +241,7 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I MissionManager::failInstancedMissions(sock); // fail any instanced missions - uint64_t fromInstance = plr->instanceID; + uint64_t fromInstance = plrv.plr->instanceID; // pre-warp instance, saved for post-warp plr->instanceID = I; if (I != INSTANCE_OVERWORLD) { @@ -264,6 +264,7 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I updatePlayerPosition(sock, X, Y, Z); } + // post-warp: check if the source instance has no more players in it and delete it if so ChunkManager::destroyInstanceIfEmpty(fromInstance); }