fix(Core/Creatures): Fixed unitialized varibale implemented in 728d018. (#5042)

- Closes #5030

Co-authored-by: UltraNix <ultranix@gmail.com>
This commit is contained in:
UltraNix
2021-03-28 22:29:50 +02:00
committed by GitHub
parent 5d3cc6e513
commit 9ca4a23ef3

View File

@@ -185,6 +185,8 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(),
TriggerJustRespawned = false; TriggerJustRespawned = false;
m_isTempWorldObject = false; m_isTempWorldObject = false;
_focusSpell = nullptr; _focusSpell = nullptr;
m_respawnedTime = time_t(0);
} }
Creature::~Creature() Creature::~Creature()
@@ -1790,6 +1792,8 @@ void Creature::Respawn(bool force)
//Re-initialize reactstate that could be altered by movementgenerators //Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState(); InitializeReactState();
m_respawnedTime = sWorld->GetGameTime();
} }
m_respawnedTime = time(nullptr); m_respawnedTime = time(nullptr);
// xinef: relocate notifier, fixes npc appearing in corpse position after forced respawn (instead of spawn) // xinef: relocate notifier, fixes npc appearing in corpse position after forced respawn (instead of spawn)
@@ -2277,7 +2281,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
return false; return false;
// cannot attack if is during 5 second grace period, unless being attacked // cannot attack if is during 5 second grace period, unless being attacked
if ((time(nullptr) - m_respawnedTime) < 5 && victim->getAttackers().empty()) if (m_respawnedTime && (sWorld->GetGameTime() - m_respawnedTime) < 5 && victim->getAttackers().empty())
{ {
return false; return false;
} }