Ensure that all actions are compared to fixed point in time (ie. world update start)

This commit is contained in:
Aokromes
2017-04-14 15:02:49 +02:00
parent 00babf222a
commit adae2fec26
43 changed files with 479 additions and 185 deletions

View File

@@ -30,6 +30,8 @@ EndScriptData */
#include "ScriptMgr.h"
#include "GitRevision.h"
#include "Util.h"
#include "GameTime.h"
#include "UpdateTime.h"
class server_commandscript : public CommandScript
{
@@ -108,8 +110,8 @@ public:
uint32 queuedClientsNum = sWorld->GetQueuedSessionCount();
uint32 maxActiveClientsNum = sWorld->GetMaxActiveSessionCount();
uint32 maxQueuedClientsNum = sWorld->GetMaxQueuedSessionCount();
std::string uptime = secsToTimeString(sWorld->GetUptime());
uint32 updateTime = sWorld->GetUpdateTime();
std::string uptime = secsToTimeString(GameTime::GetUptime());
uint32 updateTime = sWorldUpdateTime.GetLastUpdateTime();
handler->SendSysMessage(GitRevision::GetFullVersion());
handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
@@ -304,7 +306,7 @@ public:
if (newTime < 0)
return false;
sWorld->SetRecordDiffInterval(newTime);
sWorldUpdateTime.SetRecordUpdateTimeInterval(newTime);
printf("Record diff every %i ms\n", newTime);
return true;

View File

@@ -19,6 +19,7 @@
#include "GameObjectAI.h"
#include "CreatureAIImpl.h"
#include "GameEventMgr.h"
#include "GameTime.h"
enum FireworksShowTypeObjects
{
@@ -792,7 +793,7 @@ public:
{
_events.Update(diff);
time_t time = sWorld->GetGameTime();
time_t time = GameTime::GetGameTime();
tm localTm;
localtime_r(&time, &localTm);

View File

@@ -1836,7 +1836,7 @@ class spell_icc_sprit_alarm : public SpellScriptLoader
}
if (GameObject* trap = GetCaster()->FindNearestGameObject(trapId, 5.0f))
trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime());
trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime() / IN_MILLISECONDS);
std::list<Creature*> wards;
GetCaster()->GetCreatureListWithEntryInGrid(wards, NPC_DEATHBOUND_WARD, 150.0f);

View File

@@ -16,6 +16,7 @@
*/
#include "Player.h"
#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
@@ -327,7 +328,7 @@ struct boss_four_horsemen_baseAI : public BossAI
}
Talk(SAY_DEATH);
_timeDied = getMSTime();
_timeDied = GameTime::GetGameTimeMS();
for (Horseman boss : horsemen)
{
if (Creature* cBoss = getHorsemanHandle(boss))

View File

@@ -17,6 +17,7 @@
*/
#include "GameEventMgr.h"
#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "nexus.h"
@@ -167,7 +168,7 @@ public:
while (time[i] != 0)
++i;
time[i] = sWorld->GetGameTime();
time[i] = GameTime::GetGameTime();
if (i == 2 && (time[2] - time[1] < 5) && (time[1] - time[0] < 5))
++splitPersonality;
}

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
@@ -194,7 +195,7 @@ class boss_ignis : public CreatureScript
me->RemoveAuraFromStack(SPELL_STRENGHT);
// Shattered Achievement
time_t secondKill = sWorld->GetGameTime();
time_t secondKill = GameTime::GetGameTime();
if ((secondKill - _firstConstructKill) < 5)
_shattered = true;
_firstConstructKill = secondKill;

View File

@@ -23,6 +23,7 @@
*/
#include "ScriptMgr.h"
#include "GameTime.h"
#include "Battleground.h"
#include "Cell.h"
#include "CellImpl.h"
@@ -3199,7 +3200,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader
void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
// store stack apply times, so we can pop them while they expire
_applyTimes.push_back(getMSTime());
_applyTimes.push_back(GameTime::GetGameTimeMS());
Unit* target = GetTarget();
// on stack 15 cast the achievement crediting spell
@@ -3213,7 +3214,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader
return;
// pop stack if it expired for us
if (_applyTimes.front() + GetMaxDuration() < getMSTime())
if (_applyTimes.front() + GetMaxDuration() < GameTime::GetGameTimeMS())
ModStackAmount(-1, AURA_REMOVE_BY_EXPIRE);
}

View File

@@ -35,6 +35,7 @@ at_brewfest
at_area_52_entrance
EndContentData */
#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "Player.h"
@@ -314,7 +315,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript
{
uint32 triggerId = trigger->id;
// Second trigger happened too early after first, skip for now
if (sWorld->GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
if (GameTime::GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
return false;
switch (triggerId)
@@ -331,7 +332,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript
break;
}
_triggerTimes[triggerId] = sWorld->GetGameTime();
_triggerTimes[triggerId] = GameTime::GetGameTime();
return false;
}
@@ -371,7 +372,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
return false;
uint32 triggerId = trigger->id;
if (sWorld->GetGameTime() - _triggerTimes[trigger->id] < SUMMON_COOLDOWN)
if (GameTime::GetGameTime() - _triggerTimes[trigger->id] < SUMMON_COOLDOWN)
return false;
switch (triggerId)
@@ -400,7 +401,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5000);
player->AddAura(SPELL_A52_NEURALYZER, player);
_triggerTimes[trigger->id] = sWorld->GetGameTime();
_triggerTimes[trigger->id] = GameTime::GetGameTime();
return false;
}

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameTime.h"
#include "ScriptMgr.h"
#include "Player.h"
#include "Pet.h"
@@ -103,7 +104,7 @@ class DuelResetScript : public PlayerScript
// remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold
player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool
{
SpellHistory::Clock::time_point now = SpellHistory::Clock::now();
SpellHistory::Clock::time_point now = GameTime::GetGameTimeSystemPoint();
uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0;
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS

View File

@@ -53,6 +53,7 @@ EndContentData */
#include "Player.h"
#include "WorldSession.h"
#include "GameEventMgr.h"
#include "GameTime.h"
/*######
## go_cat_figurine
@@ -1573,7 +1574,7 @@ public:
{
if (eventId == GAME_EVENT_HOURLY_BELLS && start)
{
time_t time = sWorld->GetGameTime();
time_t time = GameTime::GetGameTime();
tm localTm;
localtime_r(&time, &localTm);
uint8 _rings = (localTm.tm_hour - 1) % 12 + 1;