Core/Pools: Fix pools with 1 member never spawning anything anymore

Port From (https://github.com/TrinityCore/TrinityCore/commit/9c3dc31a3764681ae641e24ab61cd5256cc3331e)
This commit is contained in:
hondacrx
2022-05-28 17:49:41 -04:00
parent 06da4c2dfd
commit 504da24dd0
3 changed files with 21 additions and 8 deletions
+5 -2
View File
@@ -3277,9 +3277,12 @@ namespace Game.Entities
return false; return false;
} }
} }
else
{
// compatibility mode creatures will be respawned in ::Update()
m_deathState = DeathState.Dead;
}
// compatibility mode creatures will be respawned in ::Update()
m_deathState = DeathState.Dead;
if (CanFly()) if (CanFly())
{ {
float tz = map.GetHeight(GetPhaseShift(), data.SpawnPoint, true, MapConst.MaxFallDistance); float tz = map.GetHeight(GetPhaseShift(), data.SpawnPoint, true, MapConst.MaxFallDistance);
+3
View File
@@ -2646,6 +2646,7 @@ namespace Game.Maps
Global.PoolMgr.UpdatePool(poolId, next.type, next.spawnId); Global.PoolMgr.UpdatePool(poolId, next.type, next.spawnId);
// step 3: get rid of the actual entry // step 3: get rid of the actual entry
RemoveRespawnTime(next.type, next.spawnId, null, true);
GetRespawnMapForType(next.type).Remove(next.spawnId); GetRespawnMapForType(next.type).Remove(next.spawnId);
} }
else if (CheckRespawn(next)) // see if we're allowed to respawn else if (CheckRespawn(next)) // see if we're allowed to respawn
@@ -2657,12 +2658,14 @@ namespace Game.Maps
DoRespawn(next.type, next.spawnId, next.gridId); DoRespawn(next.type, next.spawnId, next.gridId);
// step 3: get rid of the actual entry // step 3: get rid of the actual entry
RemoveRespawnTime(next.type, next.spawnId, null, true);
GetRespawnMapForType(next.type).Remove(next.spawnId); GetRespawnMapForType(next.type).Remove(next.spawnId);
} }
else if (next.respawnTime == 0) else if (next.respawnTime == 0)
{ // just remove this respawn entry without rescheduling { // just remove this respawn entry without rescheduling
_respawnTimes.Remove(next); _respawnTimes.Remove(next);
GetRespawnMapForType(next.type).Remove(next.spawnId); GetRespawnMapForType(next.type).Remove(next.spawnId);
RemoveRespawnTime(next.type, next.spawnId, null, true);
} }
else else
{ // new respawn time, update heap position { // new respawn time, update heap position
+13 -6
View File
@@ -490,7 +490,7 @@ namespace Game
} }
} }
void Despawn1Object(ulong guid, bool alwaysDeleteRespawnTime = false) void Despawn1Object(ulong guid, bool alwaysDeleteRespawnTime = false, bool saveRespawnTime = true)
{ {
switch (typeof(T).Name) switch (typeof(T).Name)
{ {
@@ -507,7 +507,7 @@ namespace Game
foreach (var creature in creatureBounds) foreach (var creature in creatureBounds)
{ {
// For dynamic spawns, save respawn time here // For dynamic spawns, save respawn time here
if (!creature.GetRespawnCompatibilityMode()) if (saveRespawnTime && !creature.GetRespawnCompatibilityMode())
creature.SaveRespawnTime(); creature.SaveRespawnTime();
creature.AddObjectToRemoveList(); creature.AddObjectToRemoveList();
@@ -532,7 +532,7 @@ namespace Game
foreach (var go in gameobjectBounds) foreach (var go in gameobjectBounds)
{ {
// For dynamic spawns, save respawn time here // For dynamic spawns, save respawn time here
if (!go.GetRespawnCompatibilityMode()) if (saveRespawnTime && !go.GetRespawnCompatibilityMode())
go.SaveRespawnTime(); go.SaveRespawnTime();
go.AddObjectToRemoveList(); go.AddObjectToRemoveList();
@@ -598,7 +598,7 @@ namespace Game
roll -= obj.chance; roll -= obj.chance;
// 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.Add(obj); rolledObjects.Add(obj);
break; break;
@@ -608,7 +608,7 @@ namespace Game
if (!EqualChanced.Empty() && rolledObjects.Empty()) if (!EqualChanced.Empty() && rolledObjects.Empty())
{ {
rolledObjects.AddRange(EqualChanced.Where(obj => /*obj.guid == triggerFrom ||*/ !spawns.IsActiveObject<T>(obj.guid))); rolledObjects.AddRange(EqualChanced.Where(obj => obj.guid == triggerFrom || !spawns.IsActiveObject<T>(obj.guid)));
rolledObjects.RandomResize((uint)count); rolledObjects.RandomResize((uint)count);
} }
@@ -682,7 +682,14 @@ namespace Game
void ReSpawn1Object(PoolObject obj) void ReSpawn1Object(PoolObject obj)
{ {
// GameObject/Creature is still on map, nothing to do switch (typeof(T).Name)
{
case "Creature":
case "GameObject":
Despawn1Object(obj.guid, false, false);
Spawn1Object(obj);
break;
}
} }
void RemoveRespawnTimeFromDB(ulong guid) void RemoveRespawnTimeFromDB(ulong guid)