aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 42234afb7fc..55c6365d109 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -600,7 +600,18 @@ void Creature::Update(uint32 diff)
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
- m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
+ {
+ // else copy time from master and add a little
+ time_t baseRespawnTime = std::max(linkedRespawntime, now);
+ time_t const offset = urand(5, MINUTE);
+
+ // linked guid can be a boss, uses std::numeric_limits<time_t>::max to never respawn in that instance
+ // we shall inherit it instead of adding and causing an overflow
+ if (baseRespawnTime <= std::numeric_limits<time_t>::max() - offset)
+ m_respawnTime = baseRespawnTime + offset;
+ else
+ m_respawnTime = std::numeric_limits<time_t>::max();
+ }
SaveRespawnTime(); // also save to DB immediately
}
}