Ensure that all actions are compared to fixed point in time (ie. world update start)

This commit is contained in:
Aokromes committed 2017-04-14 15:02:49 +02:00
1 parent 00babf222a
commit adae2fec26
43 files changed
+479 -185

No files matched your search

@@ -21,6 +21,7 @@
#include "CellImpl.h"
#include "CreatureAISelector.h"
#include "GameObjectModel.h"
#include "GameTime.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "GroupMgr.h"
@@ -365,10 +366,10 @@ void GameObject::Update(uint32 diff)
// Bombs
if (goInfo->trap.type == 2)
// Hardcoded tooltip value
m_cooldownTime = time(NULL) + 10;
m_cooldownTime = GameTime::GetGameTimeMS() + 10 * IN_MILLISECONDS;
else if (Unit* owner = GetOwner())
if (owner->IsInCombat())
m_cooldownTime = time(NULL) + goInfo->trap.startDelay;
m_cooldownTime = GameTime::GetGameTimeMS() + goInfo->trap.startDelay * IN_MILLISECONDS;
SetLootState(GO_READY);
break;
@@ -532,7 +533,7 @@ void GameObject::Update(uint32 diff)
GameObjectTemplate const* goInfo = GetGOInfo();
if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
{
if (m_cooldownTime >= time(NULL))
if (GameTime::GetGameTimeMS() < m_cooldownTime)
break;
// Type 2 (bomb) does not need to be triggered by a unit and despawns after casting its spell.
@@ -599,16 +600,14 @@ void GameObject::Update(uint32 diff)
{
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
if (m_cooldownTime && (m_cooldownTime < time(NULL)))
if (m_cooldownTime && GameTime::GetGameTimeMS() >= m_cooldownTime)
ResetDoorOrButton();
break;
case GAMEOBJECT_TYPE_GOOBER:
if (m_cooldownTime < time(NULL))
if (GameTime::GetGameTimeMS() >= m_cooldownTime)
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}
break;
case GAMEOBJECT_TYPE_CHEST:
@@ -641,7 +640,7 @@ void GameObject::Update(uint32 diff)
CastSpell(target, goInfo->trap.spellId);
// Template value or 4 seconds
m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
m_cooldownTime = GameTime::GetGameTimeMS() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS;
if (goInfo->trap.type == 1)
SetLootState(GO_JUST_DEACTIVATED);
@@ -1196,7 +1195,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
SwitchDoorOrButton(true, alternative);
SetLootState(GO_ACTIVATED, user);
m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0;
m_cooldownTime = GameTime::GetGameTimeMS() + time_to_restore;
}
void GameObject::SetGoArtKit(uint8 kit)
@@ -1254,10 +1253,10 @@ void GameObject::Use(Unit* user)
// If cooldown data present in template
if (uint32 cooldown = GetGOInfo()->GetCooldown())
{
if (m_cooldownTime > sWorld->GetGameTime())
if (GameTime::GetGameTimeMS() < m_cooldownTime)
return;
m_cooldownTime = sWorld->GetGameTime() + cooldown;
m_cooldownTime = GameTime::GetGameTimeMS() + cooldown * IN_MILLISECONDS;
}
switch (GetGoType())
@@ -1284,7 +1283,7 @@ void GameObject::Use(Unit* user)
if (goInfo->trap.spellId)
CastSpell(user, goInfo->trap.spellId);
m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)); // template or 4 seconds
m_cooldownTime = GameTime::GetGameTimeMS() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
if (goInfo->trap.type == 1) // Deactivate after trigger
SetLootState(GO_JUST_DEACTIVATED);
@@ -1431,7 +1430,7 @@ void GameObject::Use(Unit* user)
else
SetGoState(GO_STATE_ACTIVE);
m_cooldownTime = time(NULL) + info->GetAutoCloseTime();
m_cooldownTime = GameTime::GetGameTimeMS() + info->GetAutoCloseTime();
// cast this spell later if provided
spellId = info->goober.spellId;