Core/Spawn: Limit saved/stored respawn time.

- Limit to time_t maximum, for the compiled-for architecture.

Closes #20834

(cherry picked from commit 3446424540c5692c9e0ff11803d70e8129a5adc4)
This commit is contained in:
r00ty-tc
2021-02-06 21:41:51 +01:00
committed by Shauren
parent ce8b3a1308
commit f3ac10f36f
2 changed files with 4 additions and 2 deletions
@@ -2554,7 +2554,7 @@ void Creature::SaveRespawnTime(uint32 forceDelay, bool savetodb)
return;
}
uint32 thisRespawnTime = forceDelay ? time(NULL) + forceDelay : m_respawnTime;
time_t thisRespawnTime = forceDelay ? time(NULL) + forceDelay : m_respawnTime;
GetMap()->SaveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId, GetEntry(), thisRespawnTime, GetMap()->GetZoneId(GetPhaseShift(), GetHomePosition()), Trinity::ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId(), savetodb && m_creatureData && m_creatureData->dbData);
}
+3 -1
View File
@@ -3345,7 +3345,9 @@ bool Map::CheckRespawn(RespawnInfo* info)
{
time_t now = time(NULL);
time_t respawnTime;
if (sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID) // never respawn, save "something" in DB
if (linkedTime == std::numeric_limits<time_t>::max())
respawnTime = linkedTime;
else if (sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID) // never respawn, save "something" in DB
respawnTime = now + WEEK;
else // set us to check again shortly after linked unit
respawnTime = std::max<time_t>(now, linkedTime) + urand(5, 15);