feat(Core/Time): Implement saparated manager for game time (#8630)

This commit is contained in:
Kargatum
2022-01-24 17:55:00 +07:00
committed by GitHub
parent 12da792a90
commit 8b7df23f06
129 changed files with 1147 additions and 817 deletions

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "Group.h"
#include "Player.h"
#include "ScriptMgr.h"
@@ -348,7 +349,7 @@ public:
c->DespawnOrUnsummon(10000);
if( Creature* c = instance->GetCreature(NPC_DreadscaleGUID) )
c->DespawnOrUnsummon(10000);
if( AchievementTimer + 10 >= time(nullptr) )
if( AchievementTimer + 10 >= GameTime::GetGameTime().count() )
DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_JORMUNGAR_ACHIEV);
AchievementTimer = 0;
@@ -365,7 +366,7 @@ public:
}
else // first one died, start timer for achievement
{
AchievementTimer = time(nullptr);
AchievementTimer = GameTime::GetGameTime().count();
}
}
else
@@ -447,14 +448,14 @@ public:
HandleGameObject(GO_EnterGateGUID, true);
if( AchievementTimer + 60 >= time(nullptr) )
if( AchievementTimer + 60 >= GameTime::GetGameTime().count() )
DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_RESILIENCE_WILL_FIX_IT_CREDIT);
AchievementTimer = 0;
SaveToDB();
}
else if( Counter == 1 )
AchievementTimer = time(nullptr);
AchievementTimer = GameTime::GetGameTime().count();
}
break;
case TYPE_FACTION_CHAMPIONS_START:

View File

@@ -16,6 +16,7 @@
*/
#include "CreatureTextMgr.h"
#include "GameTime.h"
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "ScriptMgr.h"
@@ -424,7 +425,7 @@ public:
return false;
bool summoned = false;
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
for (int32 i = first; i <= last; ++i)
{
if (_respawnCooldowns[i] > now)
@@ -460,7 +461,7 @@ public:
void ClearSlot(PassengerSlots slot)
{
_controlledSlots[slot].Clear();
_respawnCooldowns[slot] = time(nullptr) + _slotInfo[slot].Cooldown;
_respawnCooldowns[slot] = GameTime::GetGameTime().count() + _slotInfo[slot].Cooldown;
}
private:
@@ -749,7 +750,7 @@ public:
_controller.ResetSlots(TEAM_HORDE, creature->GetTransport()->ToMotionTransport());
me->SetRegeneratingHealth(false);
me->m_CombatDistance = 70.0f;
_firstMageCooldown = time(nullptr) + 45;
_firstMageCooldown = GameTime::GetGameTime().count() + 45;
_axethrowersYellCooldown = time_t(0);
_rocketeersYellCooldown = time_t(0);
checkTimer = 1000;
@@ -814,7 +815,7 @@ public:
}
else if (action == ACTION_SPAWN_MAGE)
{
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
if (_firstMageCooldown > now)
_events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS);
else
@@ -989,10 +990,10 @@ public:
case EVENT_CHECK_RIFLEMAN:
if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4))
{
if (_axethrowersYellCooldown < time(nullptr))
if (_axethrowersYellCooldown < GameTime::GetGameTime().count())
{
Talk(SAY_SAURFANG_AXETHROWERS);
_axethrowersYellCooldown = time(nullptr) + 5;
_axethrowersYellCooldown = GameTime::GetGameTime().count() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500);
@@ -1000,10 +1001,10 @@ public:
case EVENT_CHECK_MORTAR:
if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2))
{
if (_rocketeersYellCooldown < time(nullptr))
if (_rocketeersYellCooldown < GameTime::GetGameTime().count())
{
Talk(SAY_SAURFANG_ROCKETEERS);
_rocketeersYellCooldown = time(nullptr) + 5;
_rocketeersYellCooldown = GameTime::GetGameTime().count() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500);
@@ -1084,7 +1085,7 @@ public:
_controller.ResetSlots(TEAM_ALLIANCE, creature->GetTransport()->ToMotionTransport());
me->SetRegeneratingHealth(false);
me->m_CombatDistance = 70.0f;
_firstMageCooldown = time(nullptr) + 45;
_firstMageCooldown = GameTime::GetGameTime().count() + 45;
_riflemanYellCooldown = time_t(0);
_mortarYellCooldown = time_t(0);
checkTimer = 1000;
@@ -1150,7 +1151,7 @@ public:
}
else if (action == ACTION_SPAWN_MAGE)
{
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
if (_firstMageCooldown > now)
_events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS);
else
@@ -1328,10 +1329,10 @@ public:
case EVENT_CHECK_RIFLEMAN:
if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4))
{
if (_riflemanYellCooldown < time(nullptr))
if (_riflemanYellCooldown < GameTime::GetGameTime().count())
{
Talk(SAY_MURADIN_RIFLEMAN);
_riflemanYellCooldown = time(nullptr) + 5;
_riflemanYellCooldown = GameTime::GetGameTime().count() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500);
@@ -1339,10 +1340,10 @@ public:
case EVENT_CHECK_MORTAR:
if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2))
{
if (_mortarYellCooldown < time(nullptr))
if (_mortarYellCooldown < GameTime::GetGameTime().count())
{
Talk(SAY_MURADIN_MORTAR);
_mortarYellCooldown = time(nullptr) + 5;
_mortarYellCooldown = GameTime::GetGameTime().count() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500);

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "GridNotifiers.h"
#include "ObjectMgr.h"
#include "Player.h"
@@ -950,7 +951,7 @@ public:
if (!spellInfo)
return false;
uint32 currMSTime = World::GetGameTimeMS();
uint32 currMSTime = GameTime::GetGameTimeMS().count();
std::map<uint32, uint32>::iterator itr = _lastMSTimeForSpell.find(spellInfo->Id);
if (itr != _lastMSTimeForSpell.end())
{

View File

@@ -18,6 +18,7 @@
#include "Cell.h"
#include "CellImpl.h"
#include "CreatureTextMgr.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "ObjectMgr.h"
@@ -720,9 +721,9 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill + 5 < time(nullptr))
if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill + 5 < GameTime::GetGameTime().count())
{
_lastTalkTimeKill = time(nullptr);
_lastTalkTimeKill = GameTime::GetGameTime().count();
Talk(SAY_LK_KILL);
}
}
@@ -751,7 +752,7 @@ public:
events.RescheduleEvent(EVENT_START_ATTACK, 1000);
EntryCheckPredicate pred(NPC_STRANGULATE_VEHICLE);
summons.DoAction(ACTION_TELEPORT_BACK, pred);
if (!IsHeroic() && _phase != PHASE_OUTRO && me->IsInCombat() && _lastTalkTimeBuff + 5 <= time(nullptr))
if (!IsHeroic() && _phase != PHASE_OUTRO && me->IsInCombat() && _lastTalkTimeBuff + 5 <= GameTime::GetGameTime().count())
Talk(SAY_LK_FROSTMOURNE_ESCAPE);
}
break;
@@ -906,9 +907,9 @@ public:
void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override
{
if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff + 5 <= time(nullptr))
if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff + 5 <= GameTime::GetGameTime().count())
{
_lastTalkTimeBuff = time(nullptr);
_lastTalkTimeBuff = GameTime::GetGameTime().count();
Talk(SAY_LK_FROSTMOURNE_KILL);
}
}

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -276,10 +277,10 @@ public:
if (id == 1337)
{
if (lastShatterMSTime)
if (getMSTimeDiff(lastShatterMSTime, World::GetGameTimeMS()) <= 5000)
if (getMSTimeDiff(lastShatterMSTime, GameTime::GetGameTimeMS().count()) <= 5000)
bShattered = true;
lastShatterMSTime = World::GetGameTimeMS();
lastShatterMSTime = GameTime::GetGameTimeMS().count();
}
}

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "MapMgr.h"
#include "PassiveAI.h"
#include "Player.h"
@@ -455,7 +456,7 @@ public:
case EVENT_SPAWN_FLAMES_INITIAL:
{
if (changeAllowedFlameSpreadTime)
allowedFlameSpreadTime = time(nullptr);
allowedFlameSpreadTime = GameTime::GetGameTime().count();
std::vector<Player*> pg;
Map::PlayerList const& pl = me->GetMap()->GetPlayers();
@@ -2204,7 +2205,7 @@ public:
bool Load() override
{
lastMSTime = World::GetGameTimeMS();
lastMSTime = GameTime::GetGameTimeMS().count();
lastOrientation = -1.0f;
return true;
}
@@ -2215,14 +2216,14 @@ public:
{
if (c->GetTypeId() != TYPEID_UNIT)
return;
uint32 diff = getMSTimeDiff(lastMSTime, World::GetGameTimeMS());
uint32 diff = getMSTimeDiff(lastMSTime, GameTime::GetGameTimeMS().count());
if (lastOrientation == -1.0f)
{
lastOrientation = (c->ToCreature()->AI()->GetData(0) * 2 * M_PI) / 100.0f;
diff = 0;
}
float new_o = Position::NormalizeOrientation(lastOrientation - (M_PI / 60) * (diff / 250.0f));
lastMSTime = World::GetGameTimeMS();
lastMSTime = GameTime::GetGameTimeMS().count();
lastOrientation = new_o;
c->SetFacingTo(new_o);
@@ -2283,7 +2284,7 @@ public:
{
npc_ulduar_flames_initialAI(Creature* pCreature) : NullCreatureAI(pCreature)
{
CreateTime = time(nullptr);
CreateTime = GameTime::GetGameTime().count();
events.Reset();
events.ScheduleEvent(EVENT_FLAMES_SPREAD, 5750);
if( Creature* flame = me->SummonCreature(NPC_FLAMES_SPREAD, me->GetPositionX(), me->GetPositionY(), 364.32f, 0.0f) )

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -1013,10 +1014,10 @@ public:
}
else if (unit->GetTypeId() == TYPEID_UNIT && unit->GetAreaId() == 4656 /*Conservatory of Life*/)
{
if (time(nullptr) > (m_conspeedatoryAttempt + DAY))
if (GameTime::GetGameTime().count() > (m_conspeedatoryAttempt + DAY))
{
DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, 21597 /*CON-SPEED-ATORY_TIMED_CRITERIA*/);
m_conspeedatoryAttempt = time(nullptr);
m_conspeedatoryAttempt = GameTime::GetGameTime().count();
SaveToDB();
}
}

View File

@@ -17,6 +17,7 @@
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "GameTime.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -190,13 +191,13 @@ public:
switch (type)
{
case EVENT_ARCHAVON:
ArchavonDeath = time(nullptr);
ArchavonDeath = GameTime::GetGameTime().count();
break;
case EVENT_EMALON:
EmalonDeath = time(nullptr);
EmalonDeath = GameTime::GetGameTime().count();
break;
case EVENT_KORALON:
KoralonDeath = time(nullptr);
KoralonDeath = GameTime::GetGameTime().count();
break;
default:
return;

View File

@@ -21,6 +21,7 @@
#include "CombatAI.h"
#include "GameGraveyard.h"
#include "GameObjectAI.h"
#include "GameTime.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "PoolMgr.h"
@@ -294,7 +295,7 @@ public:
else
{
uint32 timer = wintergrasp->GetTimer() / 1000;
player->SendUpdateWorldState(4354, time(nullptr) + timer);
player->SendUpdateWorldState(4354, GameTime::GetGameTime().count() + timer);
if (timer < 15 * MINUTE)
{
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Queue for Wintergrasp.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);