diff options
author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2021-06-26 14:21:18 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-03-11 13:39:15 +0100 |
commit | 9c3dc31a3764681ae641e24ab61cd5256cc3331e (patch) | |
tree | f83455fe4ee644ea534fd5f2c795693916bb67d4 /src/server/game/Pools/PoolMgr.cpp | |
parent | 8b1be7bbfc620b2cd39a0f84b0d0300b12205255 (diff) |
Core/Pools: Fix pools with 1 member never spawning anything anymore (#26620)
* Core/Pools: Fix pools with 1 member never spawning anything anymore
Attempts to fix a 6 years old bug and never fixed by the original author.
* Remove respawn times from db once a respawn has been handled
* Allow to specify if Despawn1Object() should save or not the respawn time. We don't need to do that when respawning an object.
* Apply the same fix to GameObjects too
(cherry picked from commit c8ca48823d45dadb042a80637eff954483dd5328)
Diffstat (limited to 'src/server/game/Pools/PoolMgr.cpp')
-rw-r--r-- | src/server/game/Pools/PoolMgr.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index d86421812b3..4bfc918b2af 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -186,7 +186,7 @@ void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint64 guid, bool alway // Method that is actualy doing the removal job on one creature template<> -void PoolGroup<Creature>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTime) +void PoolGroup<Creature>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime) { if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) { @@ -201,7 +201,7 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTi Creature* creature = itr->second; ++itr; // For dynamic spawns, save respawn time here - if (!creature->GetRespawnCompatibilityMode()) + if (saveRespawnTime && !creature->GetRespawnCompatibilityMode()) creature->SaveRespawnTime(); creature->AddObjectToRemoveList(); } @@ -214,7 +214,7 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTi // Same on one gameobject template<> -void PoolGroup<GameObject>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTime) +void PoolGroup<GameObject>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime) { if (GameObjectData const* data = sObjectMgr->GetGameObjectData(guid)) { @@ -230,7 +230,7 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawn ++itr; // For dynamic spawns, save respawn time here - if (!go->GetRespawnCompatibilityMode()) + if (saveRespawnTime && !go->GetRespawnCompatibilityMode()) go->SaveRespawnTime(); go->AddObjectToRemoveList(); } @@ -243,7 +243,7 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid, bool alwaysDeleteRespawn // Same on one pool template<> -void PoolGroup<Pool>::Despawn1Object(uint64 child_pool_id, bool alwaysDeleteRespawnTime) +void PoolGroup<Pool>::Despawn1Object(uint64 child_pool_id, bool alwaysDeleteRespawnTime, bool /*saveRespawnTime*/) { sPoolMgr->DespawnPool(child_pool_id, alwaysDeleteRespawnTime); } @@ -296,7 +296,7 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint64 trig roll -= obj.chance; // Triggering object is marked as spawned at this time and can be also rolled (respawn case) // so this need explicit check for this case - if (roll < 0 && (/*obj.guid == triggerFrom ||*/ !spawns.IsActiveObject<T>(obj.guid))) + if (roll < 0 && (obj.guid == triggerFrom || !spawns.IsActiveObject<T>(obj.guid))) { rolledObjects.push_back(obj); break; @@ -306,9 +306,9 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint64 trig if (!EqualChanced.empty() && rolledObjects.empty()) { - std::copy_if(EqualChanced.begin(), EqualChanced.end(), std::back_inserter(rolledObjects), [/*triggerFrom, */&spawns](PoolObject const& object) + std::copy_if(EqualChanced.begin(), EqualChanced.end(), std::back_inserter(rolledObjects), [triggerFrom, &spawns](PoolObject const& object) { - return /*object.guid == triggerFrom ||*/ !spawns.IsActiveObject<T>(object.guid); + return object.guid == triggerFrom || !spawns.IsActiveObject<T>(object.guid); }); Trinity::Containers::RandomResize(rolledObjects, count); @@ -385,16 +385,18 @@ void PoolGroup<Pool>::Spawn1Object(PoolObject* obj) // Method that does the respawn job on the specified creature template <> -void PoolGroup<Creature>::ReSpawn1Object(PoolObject* /*obj*/) +void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj) { - // Creature is still on map, nothing to do + Despawn1Object(obj->guid, false, false); + Spawn1Object(obj); } // Method that does the respawn job on the specified gameobject template <> -void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* /*obj*/) +void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj) { - // GameObject is still on map, nothing to do + Despawn1Object(obj->guid, false, false); + Spawn1Object(obj); } // Nothing to do for a child Pool |