fix(Core/Pool): Fix degradation of pools over time (#19750)

This commit is contained in:
Anton Popovichenko
2024-08-28 13:14:08 +02:00
committed by GitHub
parent b595586bf0
commit 9144031ed9
+9 -7
View File
@@ -330,7 +330,7 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
// Triggering object is marked as spawned at this time and can be also rolled (respawn case) // Triggering object is marked as spawned at this time and can be also rolled (respawn case)
// so this need explicit check for this 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); rolledObjects.push_back(obj);
break; break;
@@ -340,9 +340,9 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
if (!EqualChanced.empty() && rolledObjects.empty()) 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);
}); });
Acore::Containers::RandomResize(rolledObjects, count); Acore::Containers::RandomResize(rolledObjects, count);
@@ -527,16 +527,18 @@ void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32
// Method that does the respawn job on the specified creature // Method that does the respawn job on the specified creature
template <> template <>
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* /*obj*/) void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj)
{ {
// Creature is still on map, nothing to do Despawn1Object(obj->guid);
Spawn1Object(obj);
} }
// Method that does the respawn job on the specified gameobject // Method that does the respawn job on the specified gameobject
template <> template <>
void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* /*obj*/) void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj)
{ {
// Gameobject is still on map, nothing to do Despawn1Object(obj->guid);
Spawn1Object(obj);
} }
// Nothing to do for a child Pool // Nothing to do for a child Pool