feat(core): Ensure that all actions are compared to fixed point in time (#1236) (#1458)

i.e. world update start
This commit is contained in:
Viste(Кирилл)
2019-02-14 21:22:17 +03:00
committed by Francesco Borzì
parent 1b7522ff0e
commit 51b8773528
108 changed files with 933 additions and 509 deletions

View File

@@ -6,6 +6,7 @@
#include "ScriptedCreature.h"
#include "trial_of_the_crusader.h"
#include "Group.h"
#include "GameTime.h"
#include "Player.h"
#define CLEANUP_CHECK_INTERVAL 5000
@@ -322,7 +323,7 @@ public:
c->DespawnOrUnsummon(10000);
if( Creature* c = instance->GetCreature(NPC_DreadscaleGUID) )
c->DespawnOrUnsummon(10000);
if( AchievementTimer+10 >= time(NULL) )
if( AchievementTimer+10 >= GameTime::GetGameTime() )
DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_JORMUNGAR_ACHIEV);
AchievementTimer = 0;
@@ -339,7 +340,7 @@ public:
}
else // first one died, start timer for achievement
{
AchievementTimer = time(NULL);
AchievementTimer = GameTime::GetGameTime();
}
}
else
@@ -428,14 +429,14 @@ public:
HandleGameObject(GO_EnterGateGUID, true);
if( AchievementTimer+60 >= time(NULL) )
if( AchievementTimer+60 >= GameTime::GetGameTime() )
DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_RESILIENCE_WILL_FIX_IT_CREDIT);
AchievementTimer = 0;
SaveToDB();
}
else if( Counter == 1 )
AchievementTimer = time(NULL);
AchievementTimer = GameTime::GetGameTime();
}
break;
case TYPE_FACTION_CHAMPIONS_START:

View File

@@ -7,6 +7,7 @@
#include "ScriptedGossip.h"
#include "trial_of_the_crusader.h"
#include "Player.h"
#include "GameTime.h"
enum MenuTexts
{

View File

@@ -11,6 +11,7 @@
#include "TransportMgr.h"
#include "Vehicle.h"
#include "icecrown_citadel.h"
#include "GameTime.h"
enum Texts
{
@@ -406,7 +407,7 @@ public:
return false;
bool summoned = false;
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
for (int32 i = first; i <= last; ++i)
{
if (_respawnCooldowns[i] > now)
@@ -442,7 +443,7 @@ public:
void ClearSlot(PassengerSlots slot)
{
_controlledSlots[slot] = 0;
_respawnCooldowns[slot] = time(NULL) + _slotInfo[slot].Cooldown;
_respawnCooldowns[slot] = GameTime::GetGameTime() + _slotInfo[slot].Cooldown;
}
private:
@@ -731,7 +732,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript
_controller.ResetSlots(TEAM_HORDE, creature->GetTransport()->ToMotionTransport());
me->SetRegeneratingHealth(false);
me->m_CombatDistance = 70.0f;
_firstMageCooldown = time(NULL) + 45;
_firstMageCooldown = GameTime::GetGameTime() + 45;
_axethrowersYellCooldown = time_t(0);
_rocketeersYellCooldown = time_t(0);
checkTimer = 1000;
@@ -796,7 +797,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript
}
else if (action == ACTION_SPAWN_MAGE)
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (_firstMageCooldown > now)
_events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS);
else
@@ -971,10 +972,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript
case EVENT_CHECK_RIFLEMAN:
if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4))
{
if (_axethrowersYellCooldown < time(NULL))
if (_axethrowersYellCooldown < GameTime::GetGameTime())
{
Talk(SAY_SAURFANG_AXETHROWERS);
_axethrowersYellCooldown = time(NULL) + 5;
_axethrowersYellCooldown = GameTime::GetGameTime() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500);
@@ -982,10 +983,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript
case EVENT_CHECK_MORTAR:
if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2))
{
if (_rocketeersYellCooldown < time(NULL))
if (_rocketeersYellCooldown < GameTime::GetGameTime())
{
Talk(SAY_SAURFANG_ROCKETEERS);
_rocketeersYellCooldown = time(NULL) + 5;
_rocketeersYellCooldown = GameTime::GetGameTime() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500);
@@ -1066,7 +1067,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript
_controller.ResetSlots(TEAM_ALLIANCE, creature->GetTransport()->ToMotionTransport());
me->SetRegeneratingHealth(false);
me->m_CombatDistance = 70.0f;
_firstMageCooldown = time(NULL) + 45;
_firstMageCooldown = GameTime::GetGameTime() + 45;
_riflemanYellCooldown = time_t(0);
_mortarYellCooldown = time_t(0);
checkTimer = 1000;
@@ -1132,7 +1133,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript
}
else if (action == ACTION_SPAWN_MAGE)
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (_firstMageCooldown > now)
_events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS);
else
@@ -1310,10 +1311,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript
case EVENT_CHECK_RIFLEMAN:
if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4))
{
if (_riflemanYellCooldown < time(NULL))
if (_riflemanYellCooldown < GameTime::GetGameTime())
{
Talk(SAY_MURADIN_RIFLEMAN);
_riflemanYellCooldown = time(NULL) + 5;
_riflemanYellCooldown = GameTime::GetGameTime() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500);
@@ -1321,10 +1322,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript
case EVENT_CHECK_MORTAR:
if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2))
{
if (_mortarYellCooldown < time(NULL))
if (_mortarYellCooldown < GameTime::GetGameTime())
{
Talk(SAY_MURADIN_MORTAR);
_mortarYellCooldown = time(NULL) + 5;
_mortarYellCooldown = GameTime::GetGameTime() + 5;
}
}
_events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500);

View File

@@ -5,6 +5,7 @@
#include "ObjectMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "icecrown_citadel.h"
#include "Player.h"
@@ -948,7 +949,7 @@ class spell_sindragosa_unchained_magic : public SpellScriptLoader
if (!spellInfo)
return false;
uint32 currMSTime = World::GetGameTimeMS();
uint32 currMSTime = GameTime::GetGameTimeMS();
std::map<uint32, uint32>::iterator itr = _lastMSTimeForSpell.find(spellInfo->Id);
if (itr != _lastMSTimeForSpell.end())
{

View File

@@ -8,6 +8,7 @@
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "Spell.h"
#include "GameTime.h"
#include "Vehicle.h"
#include "Unit.h"
#include "Cell.h"
@@ -686,9 +687,9 @@ class boss_the_lich_king : public CreatureScript
void KilledUnit(Unit* victim)
{
if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill+5 < time(NULL))
if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill+5 < GameTime::GetGameTime())
{
_lastTalkTimeKill = time(NULL);
_lastTalkTimeKill = GameTime::GetGameTime();
Talk(SAY_LK_KILL);
}
}
@@ -717,7 +718,7 @@ class boss_the_lich_king : public CreatureScript
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(NULL))
if (!IsHeroic() && _phase != PHASE_OUTRO && me->IsInCombat() && _lastTalkTimeBuff+5 <= GameTime::GetGameTime())
Talk(SAY_LK_FROSTMOURNE_ESCAPE);
}
break;
@@ -874,9 +875,9 @@ class boss_the_lich_king : public CreatureScript
void SpellHit(Unit* /*caster*/, SpellInfo const* spell)
{
if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff+5 <= time(NULL))
if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff+5 <= GameTime::GetGameTime())
{
_lastTalkTimeBuff = time(NULL);
_lastTalkTimeBuff = GameTime::GetGameTime();
Talk(SAY_LK_FROSTMOURNE_KILL);
}
}

View File

@@ -5,6 +5,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "GameTime.h"
#include "ulduar.h"
#include "Vehicle.h"
#include "SpellAuras.h"
@@ -261,10 +262,10 @@ public:
if (id == 1337)
{
if (lastShatterMSTime)
if (getMSTimeDiff(lastShatterMSTime, World::GetGameTimeMS()) <= 5000)
if (getMSTimeDiff(lastShatterMSTime, GameTime::GetGameTimeMS()) <= 5000)
bShattered = true;
lastShatterMSTime = World::GetGameTimeMS();
lastShatterMSTime = GameTime::GetGameTimeMS();
}
}

View File

@@ -5,6 +5,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "GameTime.h"
#include "ulduar.h"
#include "Vehicle.h"
#include "Spell.h"
@@ -452,7 +453,7 @@ public:
case EVENT_SPAWN_FLAMES_INITIAL:
{
if (changeAllowedFlameSpreadTime)
allowedFlameSpreadTime = time(NULL);
allowedFlameSpreadTime = GameTime::GetGameTime();
std::vector<Player*> pg;
Map::PlayerList const &pl = me->GetMap()->GetPlayers();
@@ -2236,7 +2237,7 @@ public:
bool Load()
{
lastMSTime = World::GetGameTimeMS();
lastMSTime = GameTime::GetGameTimeMS();
lastOrientation = -1.0f;
return true;
}
@@ -2247,14 +2248,14 @@ public:
{
if (c->GetTypeId() != TYPEID_UNIT)
return;
uint32 diff = getMSTimeDiff(lastMSTime, World::GetGameTimeMS());
uint32 diff = getMSTimeDiff(lastMSTime, GameTime::GetGameTimeMS());
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();
lastOrientation = new_o;
c->SetOrientation(new_o);
c->SetFacingTo(new_o);
@@ -2316,7 +2317,7 @@ public:
{
npc_ulduar_flames_initialAI(Creature *pCreature) : NullCreatureAI(pCreature)
{
CreateTime = time(NULL);
CreateTime = GameTime::GetGameTime();
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

@@ -7,6 +7,7 @@
#include "ulduar.h"
#include "Vehicle.h"
#include "Player.h"
#include "GameTime.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Transport.h"
@@ -887,10 +888,10 @@ public:
}
else if (unit->GetTypeId() == TYPEID_UNIT && unit->GetAreaId() == 4656 /*Conservatory of Life*/)
{
if (time(NULL) > (m_conspeedatoryAttempt + DAY))
if (GameTime::GetGameTime() > (m_conspeedatoryAttempt + DAY))
{
DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, 21597 /*CON-SPEED-ATORY_TIMED_CRITERIA*/);
m_conspeedatoryAttempt = time(NULL);
m_conspeedatoryAttempt = GameTime::GetGameTime();
SaveToDB();
}
}

View File

@@ -11,6 +11,7 @@
#include "BattlefieldMgr.h"
#include "SpellAuras.h"
#include "Player.h"
#include "GameTime.h"
/* Vault of Archavon encounters:
1 - Archavon the Stone Watcher event
@@ -179,13 +180,13 @@ class instance_vault_of_archavon : public InstanceMapScript
switch (type)
{
case EVENT_ARCHAVON:
ArchavonDeath = time(NULL);
ArchavonDeath = GameTime::GetGameTime();
break;
case EVENT_EMALON:
EmalonDeath = time(NULL);
EmalonDeath = GameTime::GetGameTime();
break;
case EVENT_KORALON:
KoralonDeath = time(NULL);
KoralonDeath = GameTime::GetGameTime();
break;
default:
return;

View File

@@ -29,6 +29,7 @@
#include "Player.h"
#include "PoolMgr.h"
#include "GameGraveyard.h"
#include "GameTime.h"
#include "World.h"
#define GOSSIP_HELLO_DEMO1 "Build catapult."
@@ -294,7 +295,7 @@ class npc_wg_queue : public CreatureScript
else
{
uint32 timer = wintergrasp->GetTimer() / 1000;
player->SendUpdateWorldState(4354, time(NULL) + timer);
player->SendUpdateWorldState(4354, GameTime::GetGameTime() + timer);
if (timer < 15 * MINUTE)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Queue for Wintergrasp.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);