mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +00:00
feat(Core/Time): Implement saparated manager for game time (#8630)
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "DynamicTree.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameObjectModel.h"
|
||||
#include "GameTime.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
@@ -461,9 +462,9 @@ void GameObject::Update(uint32 diff)
|
||||
GameObjectTemplate const* goInfo = GetGOInfo();
|
||||
// Bombs
|
||||
if (goInfo->trap.type == 2)
|
||||
m_cooldownTime = World::GetGameTimeMS() + 10 * IN_MILLISECONDS; // Hardcoded tooltip value
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + 10 * IN_MILLISECONDS; // Hardcoded tooltip value
|
||||
else if (GetOwner())
|
||||
m_cooldownTime = World::GetGameTimeMS() + goInfo->trap.startDelay * IN_MILLISECONDS;
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + goInfo->trap.startDelay * IN_MILLISECONDS;
|
||||
|
||||
m_lootState = GO_READY;
|
||||
break;
|
||||
@@ -471,7 +472,7 @@ void GameObject::Update(uint32 diff)
|
||||
case GAMEOBJECT_TYPE_FISHINGNODE:
|
||||
{
|
||||
// fishing code (bobber ready)
|
||||
if (time(nullptr) > m_respawnTime - FISHING_BOBBER_READY_TIME)
|
||||
if (GameTime::GetGameTime().count() > m_respawnTime - FISHING_BOBBER_READY_TIME)
|
||||
{
|
||||
// splash bobber (bobber ready now)
|
||||
Unit* caster = GetOwner();
|
||||
@@ -495,7 +496,7 @@ void GameObject::Update(uint32 diff)
|
||||
}
|
||||
case GAMEOBJECT_TYPE_SUMMONING_RITUAL:
|
||||
{
|
||||
if (World::GetGameTimeMS() < m_cooldownTime)
|
||||
if (GameTime::GetGameTimeMS().count() < m_cooldownTime)
|
||||
return;
|
||||
GameObjectTemplate const* info = GetGOInfo();
|
||||
if (info->summoningRitual.animSpell)
|
||||
@@ -568,7 +569,7 @@ void GameObject::Update(uint32 diff)
|
||||
{
|
||||
if (m_respawnTime > 0) // timer on
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
if (m_respawnTime <= now) // timer expired
|
||||
{
|
||||
ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::GameObject>(GetEntry(), m_spawnId);
|
||||
@@ -644,7 +645,7 @@ void GameObject::Update(uint32 diff)
|
||||
GameObjectTemplate const* goInfo = GetGOInfo();
|
||||
if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
|
||||
{
|
||||
if (World::GetGameTimeMS() < m_cooldownTime)
|
||||
if (GameTime::GetGameTimeMS().count() < m_cooldownTime)
|
||||
break;
|
||||
|
||||
// Type 2 - Bomb (will go away after casting it's spell)
|
||||
@@ -702,7 +703,7 @@ void GameObject::Update(uint32 diff)
|
||||
if (goInfo->trap.spellId)
|
||||
CastSpell(target, goInfo->trap.spellId);
|
||||
|
||||
m_cooldownTime = World::GetGameTimeMS() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
|
||||
|
||||
if (goInfo->trap.type == 1)
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
@@ -734,11 +735,11 @@ void GameObject::Update(uint32 diff)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_DOOR:
|
||||
case GAMEOBJECT_TYPE_BUTTON:
|
||||
if (GetGOInfo()->GetAutoCloseTime() && World::GetGameTimeMS() >= m_cooldownTime)
|
||||
if (GetGOInfo()->GetAutoCloseTime() && GameTime::GetGameTimeMS().count() >= m_cooldownTime)
|
||||
ResetDoorOrButton();
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
if (World::GetGameTimeMS() >= m_cooldownTime)
|
||||
if (GameTime::GetGameTimeMS().count() >= m_cooldownTime)
|
||||
{
|
||||
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
|
||||
@@ -825,7 +826,7 @@ void GameObject::Update(uint32 diff)
|
||||
return;
|
||||
}
|
||||
|
||||
m_respawnTime = time(nullptr) + m_respawnDelayTime;
|
||||
m_respawnTime = GameTime::GetGameTime().count() + m_respawnDelayTime;
|
||||
|
||||
// if option not set then object will be saved at grid unload
|
||||
if (GetMap()->IsDungeon())
|
||||
@@ -1092,7 +1093,7 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
|
||||
m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId);
|
||||
|
||||
// ready to respawn
|
||||
if (m_respawnTime && m_respawnTime <= time(nullptr))
|
||||
if (m_respawnTime && m_respawnTime <= GameTime::GetGameTime().count())
|
||||
{
|
||||
m_respawnTime = 0;
|
||||
GetMap()->RemoveGORespawnTime(m_spawnId);
|
||||
@@ -1172,9 +1173,9 @@ Unit* GameObject::GetOwner() const
|
||||
|
||||
void GameObject::SaveRespawnTime(uint32 forceDelay)
|
||||
{
|
||||
if (m_goData && m_goData->dbData && (forceDelay || m_respawnTime > time(nullptr)) && m_spawnedByDefault)
|
||||
if (m_goData && m_goData->dbData && (forceDelay || m_respawnTime > GameTime::GetGameTime().count()) && m_spawnedByDefault)
|
||||
{
|
||||
time_t respawnTime = forceDelay ? time(nullptr) + forceDelay : m_respawnTime;
|
||||
time_t respawnTime = forceDelay ? GameTime::GetGameTime().count() + forceDelay : m_respawnTime;
|
||||
GetMap()->SaveGORespawnTime(m_spawnId, respawnTime);
|
||||
}
|
||||
}
|
||||
@@ -1232,7 +1233,7 @@ bool GameObject::IsInvisibleDueToDespawn() const
|
||||
|
||||
void GameObject::SetRespawnTime(int32 respawn)
|
||||
{
|
||||
m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0;
|
||||
m_respawnTime = respawn > 0 ? GameTime::GetGameTime().count() + respawn : 0;
|
||||
SetRespawnDelay(respawn);
|
||||
if (respawn && !m_spawnedByDefault)
|
||||
{
|
||||
@@ -1249,7 +1250,7 @@ void GameObject::Respawn()
|
||||
{
|
||||
if (m_spawnedByDefault && m_respawnTime > 0)
|
||||
{
|
||||
m_respawnTime = time(nullptr);
|
||||
m_respawnTime = GameTime::GetGameTime().count();
|
||||
GetMap()->RemoveGORespawnTime(m_spawnId);
|
||||
}
|
||||
}
|
||||
@@ -1367,7 +1368,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
|
||||
SwitchDoorOrButton(true, alternative);
|
||||
SetLootState(GO_ACTIVATED, user);
|
||||
|
||||
m_cooldownTime = World::GetGameTimeMS() + time_to_restore;
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + time_to_restore;
|
||||
}
|
||||
|
||||
void GameObject::SetGoArtKit(uint8 kit)
|
||||
@@ -1430,10 +1431,10 @@ void GameObject::Use(Unit* user)
|
||||
// If cooldown data present in template
|
||||
if (uint32 cooldown = GetGOInfo()->GetCooldown())
|
||||
{
|
||||
if (World::GetGameTimeMS() < m_cooldownTime)
|
||||
if (GameTime::GetGameTimeMS().count() < m_cooldownTime)
|
||||
return;
|
||||
|
||||
m_cooldownTime = World::GetGameTimeMS() + cooldown * IN_MILLISECONDS;
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + cooldown * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
switch (GetGoType())
|
||||
@@ -1467,7 +1468,7 @@ void GameObject::Use(Unit* user)
|
||||
if (goInfo->trap.spellId)
|
||||
CastSpell(user, goInfo->trap.spellId);
|
||||
|
||||
m_cooldownTime = World::GetGameTimeMS() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + (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);
|
||||
@@ -1634,7 +1635,7 @@ void GameObject::Use(Unit* user)
|
||||
if (info->goober.customAnim)
|
||||
SendCustomAnim(GetGoAnimProgress());
|
||||
|
||||
m_cooldownTime = World::GetGameTimeMS() + info->GetAutoCloseTime();
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + info->GetAutoCloseTime();
|
||||
|
||||
// cast this spell later if provided
|
||||
spellId = info->goober.spellId;
|
||||
@@ -1806,7 +1807,7 @@ void GameObject::Use(Unit* user)
|
||||
if (!info->summoningRitual.animSpell)
|
||||
m_cooldownTime = 0;
|
||||
else // channel ready, maintain this
|
||||
m_cooldownTime = World::GetGameTimeMS() + 5 * IN_MILLISECONDS;
|
||||
m_cooldownTime = GameTime::GetGameTimeMS().count() + 5 * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -2726,6 +2727,20 @@ void GameObject::UpdateModelPosition()
|
||||
}
|
||||
}
|
||||
|
||||
time_t GameObject::GetRespawnTimeEx() const
|
||||
{
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
if (m_respawnTime > now)
|
||||
return m_respawnTime;
|
||||
else
|
||||
return now;
|
||||
}
|
||||
|
||||
void GameObject::SetLootGenerationTime()
|
||||
{
|
||||
m_lootGenerationTime = GameTime::GetGameTime().count();
|
||||
}
|
||||
|
||||
std::unordered_map<int, goEventFlag> GameObject::gameObjectToEventFlag = { };
|
||||
|
||||
class GameObjectModelOwnerImpl : public GameObjectModelOwnerBase
|
||||
|
||||
Reference in New Issue
Block a user