mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
fix: invoke despawn callbacks on disconnect to prevent renderer leaks
Mirror the zone-transition cleanup in disconnect(): fire despawn callbacks for all entities before clearing the entity manager. Prevents M2 instances and character models from leaking when the player disconnects and reconnects quickly (e.g., server kick, network recovery).
This commit is contained in:
parent
922177abe0
commit
ff1840415e
1 changed files with 16 additions and 1 deletions
|
|
@ -784,7 +784,22 @@ void GameHandler::disconnect() {
|
|||
wardenLoadedModule_.reset();
|
||||
pendingIncomingPackets_.clear();
|
||||
pendingUpdateObjectWork_.clear();
|
||||
// Clear entity state so reconnect sees fresh CREATE_OBJECT for all visible objects.
|
||||
// Fire despawn callbacks so the renderer releases M2/character model resources.
|
||||
for (const auto& [guid, entity] : entityManager.getEntities()) {
|
||||
if (guid == playerGuid) continue;
|
||||
if (entity->getType() == ObjectType::UNIT && creatureDespawnCallback_)
|
||||
creatureDespawnCallback_(guid);
|
||||
else if (entity->getType() == ObjectType::PLAYER && playerDespawnCallback_)
|
||||
playerDespawnCallback_(guid);
|
||||
else if (entity->getType() == ObjectType::GAMEOBJECT && gameObjectDespawnCallback_)
|
||||
gameObjectDespawnCallback_(guid);
|
||||
}
|
||||
otherPlayerVisibleItemEntries_.clear();
|
||||
otherPlayerVisibleDirty_.clear();
|
||||
otherPlayerMoveTimeMs_.clear();
|
||||
unitCastStates_.clear();
|
||||
unitAurasCache_.clear();
|
||||
combatText.clear();
|
||||
entityManager.clear();
|
||||
setState(WorldState::DISCONNECTED);
|
||||
LOG_INFO("Disconnected from world server");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue