Ensure that all actions are compared to fixed point in time (ie. world update start)
Port From (https://github.com/TrinityCore/TrinityCore/commit/60663d1374beef3103f4787152654034fa4a8897)
This commit is contained in:
@@ -2082,7 +2082,7 @@ namespace Game.Entities
|
||||
return true;
|
||||
|
||||
// don't check distance to home position if recently damaged, this should include taunt auras
|
||||
if (!isWorldBoss() && (GetLastDamagedTime() > Global.WorldMgr.GetGameTime() || HasAuraType(AuraType.ModTaunt)))
|
||||
if (!isWorldBoss() && (GetLastDamagedTime() > GameTime.GetGameTime() || HasAuraType(AuraType.ModTaunt)))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2824,7 +2824,7 @@ namespace Game.Entities
|
||||
ClearUnitState(UnitState.CannotTurn);
|
||||
|
||||
_focusSpell = null;
|
||||
_focusDelay = (!IsPet() && withDelay) ? Time.GetMSTime() : 0; // don't allow re-target right away to prevent visual bugs
|
||||
_focusDelay = (!IsPet() && withDelay) ? GameTime.GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs
|
||||
}
|
||||
|
||||
public void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next Update call
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Game.Entities
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.SpellXSpellVisualID), spellXSpellVisualId);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.SpellID), spell.Id);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.Radius), radius);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.CastTime), Time.GetMSTime());
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.CastTime), GameTime.GetGameTimeMS());
|
||||
|
||||
if (IsWorldObject())
|
||||
setActive(true); //must before add to map to be put in world container
|
||||
|
||||
@@ -422,11 +422,11 @@ namespace Game.Entities
|
||||
// Bombs
|
||||
Unit owner = GetOwner();
|
||||
if (goInfo.Trap.charges == 2)
|
||||
m_cooldownTime = (uint)Time.UnixTime + 10; // Hardcoded tooltip value
|
||||
m_cooldownTime = GameTime.GetGameTimeMS() + 10 * Time.InMilliseconds; // Hardcoded tooltip value
|
||||
else if (owner)
|
||||
{
|
||||
if (owner.IsInCombat())
|
||||
m_cooldownTime = (uint)Time.UnixTime + goInfo.Trap.startDelay;
|
||||
m_cooldownTime = GameTime.GetGameTimeMS() + goInfo.Trap.startDelay * Time.InMilliseconds;
|
||||
}
|
||||
m_lootState = LootState.Ready;
|
||||
break;
|
||||
@@ -589,7 +589,7 @@ namespace Game.Entities
|
||||
uint max_charges;
|
||||
if (goInfo.type == GameObjectTypes.Trap)
|
||||
{
|
||||
if (m_cooldownTime >= Time.UnixTime)
|
||||
if (GameTime.GetGameTimeMS() < m_cooldownTime)
|
||||
break;
|
||||
|
||||
// Type 2 (bomb) does not need to be triggered by a unit and despawns after casting its spell.
|
||||
@@ -654,11 +654,11 @@ namespace Game.Entities
|
||||
{
|
||||
case GameObjectTypes.Door:
|
||||
case GameObjectTypes.Button:
|
||||
if (GetGoInfo().GetAutoCloseTime() != 0 && (m_cooldownTime < Time.UnixTime))
|
||||
if (m_cooldownTime != 0 && GameTime.GetGameTimeMS() >= m_cooldownTime)
|
||||
ResetDoorOrButton();
|
||||
break;
|
||||
case GameObjectTypes.Goober:
|
||||
if (m_cooldownTime < Time.UnixTime)
|
||||
if (GameTime.GetGameTimeMS() >= m_cooldownTime)
|
||||
{
|
||||
RemoveFlag(GameObjectFlags.InUse);
|
||||
|
||||
@@ -699,7 +699,7 @@ namespace Game.Entities
|
||||
CastSpell(target, goInfo.Trap.spell);
|
||||
|
||||
// Template value or 4 seconds
|
||||
m_cooldownTime = (uint)(Time.UnixTime + (goInfo.Trap.cooldown != 0 ? goInfo.Trap.cooldown : 4u));
|
||||
m_cooldownTime = (GameTime.GetGameTimeMS() + (goInfo.Trap.cooldown != 0 ? goInfo.Trap.cooldown : 4u)) * Time.InMilliseconds;
|
||||
|
||||
if (goInfo.Trap.charges == 1)
|
||||
SetLootState(LootState.JustDeactivated);
|
||||
@@ -1258,7 +1258,7 @@ namespace Game.Entities
|
||||
SwitchDoorOrButton(true, alternative);
|
||||
SetLootState(LootState.Activated, user);
|
||||
|
||||
m_cooldownTime = time_to_restore != 0 ? (uint)Time.UnixTime + time_to_restore : 0;
|
||||
m_cooldownTime = time_to_restore != 0 ? GameTime.GetGameTimeMS() + time_to_restore : 0;
|
||||
}
|
||||
|
||||
public void SetGoArtKit(byte kit)
|
||||
@@ -1318,10 +1318,10 @@ namespace Game.Entities
|
||||
uint cooldown = GetGoInfo().GetCooldown();
|
||||
if (cooldown != 0)
|
||||
{
|
||||
if (m_cooldownTime > Global.WorldMgr.GetGameTime())
|
||||
if (m_cooldownTime > GameTime.GetGameTime())
|
||||
return;
|
||||
|
||||
m_cooldownTime = (uint)(Global.WorldMgr.GetGameTime() + cooldown);
|
||||
m_cooldownTime = GameTime.GetGameTimeMS() + cooldown * Time.InMilliseconds;
|
||||
}
|
||||
|
||||
switch (GetGoType())
|
||||
@@ -1348,7 +1348,7 @@ namespace Game.Entities
|
||||
if (goInfo.Trap.spell != 0)
|
||||
CastSpell(user, goInfo.Trap.spell);
|
||||
|
||||
m_cooldownTime = (uint)Time.UnixTime + (goInfo.Trap.cooldown != 0 ? goInfo.Trap.cooldown : 4); // template or 4 seconds
|
||||
m_cooldownTime = GameTime.GetGameTimeMS() + (goInfo.Trap.cooldown != 0 ? goInfo.Trap.cooldown : 4) * Time.InMilliseconds; // template or 4 seconds
|
||||
|
||||
if (goInfo.Trap.charges == 1) // Deactivate after trigger
|
||||
SetLootState(LootState.JustDeactivated);
|
||||
@@ -1505,7 +1505,7 @@ namespace Game.Entities
|
||||
else
|
||||
SetGoState(GameObjectState.Active);
|
||||
|
||||
m_cooldownTime = (uint)Time.UnixTime + info.GetAutoCloseTime();
|
||||
m_cooldownTime = GameTime.GetGameTimeMS() + info.GetAutoCloseTime();
|
||||
|
||||
// cast this spell later if provided
|
||||
spellId = info.Goober.spell;
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace Game.Entities
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return autoCloseTime / Time.InMilliseconds; // prior to 3.0.3, conversion was / 0x10000;
|
||||
return autoCloseTime; // prior to 3.0.3, conversion was / 0x10000;
|
||||
}
|
||||
|
||||
public uint GetLootId()
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace Game.Entities
|
||||
if (go1 && go1.ToTransport()) // ServerTime
|
||||
data.WriteUInt32(go1.GetGoValue().Transport.PathProgress);
|
||||
else
|
||||
data.WriteUInt32(Time.GetMSTime());
|
||||
data.WriteUInt32(GameTime.GetGameTimeMS());
|
||||
}
|
||||
|
||||
if (flags.Vehicle)
|
||||
|
||||
@@ -694,10 +694,10 @@ namespace Game.Entities
|
||||
{
|
||||
AddTimedQuest(quest_id);
|
||||
|
||||
if (quest_time <= Global.WorldMgr.GetGameTime())
|
||||
if (quest_time <= GameTime.GetGameTime())
|
||||
questStatusData.Timer = 1;
|
||||
else
|
||||
questStatusData.Timer = (uint)((quest_time - Global.WorldMgr.GetGameTime()) * Time.InMilliseconds);
|
||||
questStatusData.Timer = (uint)((quest_time - GameTime.GetGameTime()) * Time.InMilliseconds);
|
||||
}
|
||||
else
|
||||
quest_time = 0;
|
||||
@@ -1824,7 +1824,7 @@ namespace Game.Entities
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
stmt.AddValue(1, save.Key);
|
||||
stmt.AddValue(2, data.Status);
|
||||
stmt.AddValue(3, data.Timer / Time.InMilliseconds + Global.WorldMgr.GetGameTime());
|
||||
stmt.AddValue(3, data.Timer / Time.InMilliseconds + GameTime.GetGameTime());
|
||||
trans.Append(stmt);
|
||||
|
||||
// Save objectives
|
||||
|
||||
@@ -4309,7 +4309,7 @@ namespace Game.Entities
|
||||
if (proto.GetFlags().HasAnyFlag(ItemFlags.NoEquipCooldown))
|
||||
return;
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
for (byte i = 0; i < proto.Effects.Count; ++i)
|
||||
{
|
||||
var effectData = proto.Effects[i];
|
||||
|
||||
@@ -446,7 +446,7 @@ namespace Game.Entities
|
||||
return 10 * MoneyConstants.Gold;
|
||||
else
|
||||
{
|
||||
ulong months = (ulong)(Global.WorldMgr.GetGameTime() - GetTalentResetTime()) / Time.Month;
|
||||
ulong months = (ulong)(GameTime.GetGameTime() - GetTalentResetTime()) / Time.Month;
|
||||
if (months > 0)
|
||||
{
|
||||
// This cost will be reduced by a rate of 5 gold per month
|
||||
|
||||
@@ -72,6 +72,8 @@ namespace Game.Entities
|
||||
m_logintime = Time.UnixTime;
|
||||
m_Last_tick = m_logintime;
|
||||
|
||||
m_timeSyncServer = GameTime.GetGameTimeMS();
|
||||
|
||||
m_dungeonDifficulty = Difficulty.Normal;
|
||||
m_raidDifficulty = Difficulty.NormalRaid;
|
||||
m_legacyRaidDifficulty = Difficulty.Raid10N;
|
||||
@@ -451,7 +453,7 @@ namespace Game.Entities
|
||||
_cinematicMgr.m_cinematicDiff += diff;
|
||||
if (_cinematicMgr.m_activeCinematicCameraId != 0 && Time.GetMSTimeDiffToNow(_cinematicMgr.m_lastCinematicCheck) > 500)
|
||||
{
|
||||
_cinematicMgr.m_lastCinematicCheck = Time.GetMSTime();
|
||||
_cinematicMgr.m_lastCinematicCheck = GameTime.GetGameTimeMS();
|
||||
_cinematicMgr.UpdateCinematicLocation(diff);
|
||||
}
|
||||
|
||||
@@ -951,7 +953,7 @@ namespace Game.Entities
|
||||
{
|
||||
m_timeSyncTimer = 0;
|
||||
m_timeSyncClient = 0;
|
||||
m_timeSyncServer = Time.GetMSTime();
|
||||
m_timeSyncServer = GameTime.GetGameTimeMS();
|
||||
}
|
||||
void SendTimeSync()
|
||||
{
|
||||
@@ -963,7 +965,7 @@ namespace Game.Entities
|
||||
|
||||
// Schedule next sync in 10 sec
|
||||
m_timeSyncTimer = 10000;
|
||||
m_timeSyncServer = Time.GetMSTime();
|
||||
m_timeSyncServer = GameTime.GetGameTimeMS();
|
||||
|
||||
if (m_timeSyncQueue.Count > 3)
|
||||
Log.outError(LogFilter.Network, "Not received CMSG_TIME_SYNC_RESP for over 30 seconds from player {0} ({1}), possible cheater", GetGUID().ToString(), GetName());
|
||||
@@ -5640,8 +5642,8 @@ namespace Game.Entities
|
||||
float TimeSpeed = 0.01666667f;
|
||||
LoginSetTimeSpeed loginSetTimeSpeed = new LoginSetTimeSpeed();
|
||||
loginSetTimeSpeed.NewSpeed = TimeSpeed;
|
||||
loginSetTimeSpeed.GameTime = (uint)Global.WorldMgr.GetGameTime();
|
||||
loginSetTimeSpeed.ServerTime = (uint)Global.WorldMgr.GetGameTime();
|
||||
loginSetTimeSpeed.GameTime = (uint)GameTime.GetGameTime();
|
||||
loginSetTimeSpeed.ServerTime = (uint)GameTime.GetGameTime();
|
||||
loginSetTimeSpeed.GameTimeHolidayOffset = 0; // @todo
|
||||
loginSetTimeSpeed.ServerTimeHolidayOffset = 0; // @todo
|
||||
SendPacket(loginSetTimeSpeed);
|
||||
|
||||
@@ -1104,7 +1104,7 @@ namespace Game.Entities
|
||||
{
|
||||
// Part of Evade mechanics. DoT's and Thorns / Retribution Aura do not contribute to this
|
||||
if (damagetype != DamageEffectType.DOT && damage > 0 && !victim.GetOwnerGUID().IsPlayer() && (spellProto == null || !spellProto.HasAura(GetMap().GetDifficultyID(), AuraType.DamageShield)))
|
||||
victim.ToCreature().SetLastDamagedTime(Global.WorldMgr.GetGameTime() + SharedConst.MaxAggroResetTime);
|
||||
victim.ToCreature().SetLastDamagedTime(GameTime.GetGameTime() + SharedConst.MaxAggroResetTime);
|
||||
|
||||
victim.AddThreat(this, damage, damageSchoolMask, spellProto);
|
||||
}
|
||||
|
||||
@@ -1809,7 +1809,7 @@ namespace Game.Entities
|
||||
|
||||
void GetProcAurasTriggeredOnEvent(List<Tuple<uint, AuraApplication>> aurasTriggeringProc, List<AuraApplication> procAuras, ProcEventInfo eventInfo)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
|
||||
// use provided list of auras which can proc
|
||||
if (procAuras != null)
|
||||
@@ -2788,7 +2788,7 @@ namespace Game.Entities
|
||||
|
||||
// Remember time after last aura from group removed
|
||||
if (diminish.Stack == 0)
|
||||
diminish.HitTime = Time.GetMSTime();
|
||||
diminish.HitTime = GameTime.GetGameTimeMS();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user