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

@@ -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);
}
}