2121#include " CellImpl.h"
2222#include " CreatureAISelector.h"
2323#include " GameObjectModel.h"
24+ #include " GameTime.h"
2425#include " GridNotifiersImpl.h"
2526#include " Group.h"
2627#include " GroupMgr.h"
@@ -365,10 +366,10 @@ void GameObject::Update(uint32 diff)
365366 // Bombs
366367 if (goInfo->trap .type == 2 )
367368 // Hardcoded tooltip value
368- m_cooldownTime = time ( NULL ) + 10 ;
369+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + 10 * IN_MILLISECONDS ;
369370 else if (Unit* owner = GetOwner ())
370371 if (owner->IsInCombat ())
371- m_cooldownTime = time ( NULL ) + goInfo->trap .startDelay ;
372+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + goInfo->trap .startDelay * IN_MILLISECONDS ;
372373
373374 SetLootState (GO_READY);
374375 break ;
@@ -532,7 +533,7 @@ void GameObject::Update(uint32 diff)
532533 GameObjectTemplate const * goInfo = GetGOInfo ();
533534 if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
534535 {
535- if (m_cooldownTime >= time ( NULL ) )
536+ if (GameTime::GetGameTimeMS () < m_cooldownTime )
536537 break ;
537538
538539 // 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)
599600 {
600601 case GAMEOBJECT_TYPE_DOOR:
601602 case GAMEOBJECT_TYPE_BUTTON:
602- if (m_cooldownTime && (m_cooldownTime < time ( NULL )) )
603+ if (m_cooldownTime && GameTime::GetGameTimeMS () >= m_cooldownTime )
603604 ResetDoorOrButton ();
604605 break ;
605606 case GAMEOBJECT_TYPE_GOOBER:
606- if (m_cooldownTime < time ( NULL ) )
607+ if (GameTime::GetGameTimeMS () >= m_cooldownTime )
607608 {
608609 RemoveFlag (GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
609-
610610 SetLootState (GO_JUST_DEACTIVATED);
611- m_cooldownTime = 0 ;
612611 }
613612 break ;
614613 case GAMEOBJECT_TYPE_CHEST:
@@ -641,7 +640,7 @@ void GameObject::Update(uint32 diff)
641640 CastSpell (target, goInfo->trap .spellId );
642641
643642 // Template value or 4 seconds
644- m_cooldownTime = time ( NULL ) + (goInfo->trap .cooldown ? goInfo->trap .cooldown : uint32 (4 ));
643+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + (goInfo->trap .cooldown ? goInfo->trap .cooldown : uint32 (4 )) * IN_MILLISECONDS ;
645644
646645 if (goInfo->trap .type == 1 )
647646 SetLootState (GO_JUST_DEACTIVATED);
@@ -1196,7 +1195,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
11961195 SwitchDoorOrButton (true , alternative);
11971196 SetLootState (GO_ACTIVATED, user);
11981197
1199- m_cooldownTime = time_to_restore ? ( time ( NULL ) + time_to_restore) : 0 ;
1198+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + time_to_restore;
12001199}
12011200
12021201void GameObject::SetGoArtKit (uint8 kit)
@@ -1254,10 +1253,10 @@ void GameObject::Use(Unit* user)
12541253 // If cooldown data present in template
12551254 if (uint32 cooldown = GetGOInfo ()->GetCooldown ())
12561255 {
1257- if (m_cooldownTime > sWorld -> GetGameTime () )
1256+ if (GameTime::GetGameTimeMS () < m_cooldownTime )
12581257 return ;
12591258
1260- m_cooldownTime = sWorld -> GetGameTime () + cooldown;
1259+ m_cooldownTime = GameTime::GetGameTimeMS () + cooldown * IN_MILLISECONDS ;
12611260 }
12621261
12631262 switch (GetGoType ())
@@ -1284,7 +1283,7 @@ void GameObject::Use(Unit* user)
12841283 if (goInfo->trap .spellId )
12851284 CastSpell (user, goInfo->trap .spellId );
12861285
1287- m_cooldownTime = time ( NULL ) + (goInfo->trap .cooldown ? goInfo->trap .cooldown : uint32 (4 )); // template or 4 seconds
1286+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + (goInfo->trap .cooldown ? goInfo->trap .cooldown : uint32 (4 )) * IN_MILLISECONDS ; // template or 4 seconds
12881287
12891288 if (goInfo->trap .type == 1 ) // Deactivate after trigger
12901289 SetLootState (GO_JUST_DEACTIVATED);
@@ -1431,7 +1430,7 @@ void GameObject::Use(Unit* user)
14311430 else
14321431 SetGoState (GO_STATE_ACTIVE);
14331432
1434- m_cooldownTime = time ( NULL ) + info->GetAutoCloseTime ();
1433+ m_cooldownTime = GameTime::GetGameTimeMS ( ) + info->GetAutoCloseTime ();
14351434
14361435 // cast this spell later if provided
14371436 spellId = info->goober .spellId ;
0 commit comments