mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
fix: invoke despawn callbacks during zone transitions to release renderer resources
handleNewWorld() previously called entityManager.clear() directly without notifying the renderer, leaving stale M2 instances and character models allocated. Now iterates all entities and fires creatureDespawnCallback, playerDespawnCallback, and gameObjectDespawnCallback before clearing. Also clears player caches (visible items, cast states, aura cache, combat text) to prevent state leaking between zones.
This commit is contained in:
parent
1d7eaaf2a0
commit
922177abe0
1 changed files with 18 additions and 1 deletions
|
|
@ -23063,7 +23063,24 @@ void GameHandler::handleNewWorld(network::Packet& packet) {
|
|||
mountCallback_(0);
|
||||
}
|
||||
|
||||
// Clear world state for the new map
|
||||
// Invoke despawn callbacks for all entities before clearing, so the renderer
|
||||
// can release M2 instances, character models, and associated resources.
|
||||
for (const auto& [guid, entity] : entityManager.getEntities()) {
|
||||
if (guid == playerGuid) continue; // skip self
|
||||
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();
|
||||
hostileAttackers_.clear();
|
||||
worldStates_.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue