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:
hondacrx
2019-09-01 10:37:14 -04:00
parent dccded6a96
commit 87d30caa49
38 changed files with 302 additions and 169 deletions
@@ -1170,7 +1170,6 @@ namespace Framework.Constants
IntervalChangeweather,
IntervalDisconnectTolerance,
IntervalGridclean,
IntervalLogUpdate,
IntervalMapupdate,
IntervalSave,
IpBasedActionLogging,
@@ -1194,7 +1193,6 @@ namespace Framework.Constants
MinCharterName,
MinDualspecLevel,
MinLevelStatSave,
MinLogUpdate,
MinPetName,
MinPetitionSigns,
MinPlayerName,
+2 -2
View File
@@ -438,7 +438,7 @@ namespace Game
public void Update()
{
long curTime = Global.WorldMgr.GetGameTime();
long curTime = GameTime.GetGameTime();
// Handle expired auctions
// If storage is empty, no need to update. next == NULL in this case.
@@ -507,7 +507,7 @@ namespace Game
public void BuildListAuctionItems(AuctionListItemsResult packet, Player player, string searchedname, uint listfrom, byte levelmin, byte levelmax, bool usable, Optional<AuctionSearchFilters> filters, uint quality)
{
long curTime = Global.WorldMgr.GetGameTime();
long curTime = GameTime.GetGameTime();
foreach (var Aentry in AuctionsMap.Values)
{
+2 -2
View File
@@ -206,7 +206,7 @@ namespace Game.BattleGrounds
var bgPlayer = m_Players.LookupByKey(guid);
if (bgPlayer != null)
{
if (bgPlayer.OfflineRemoveTime <= Global.WorldMgr.GetGameTime())
if (bgPlayer.OfflineRemoveTime <= GameTime.GetGameTime())
{
RemovePlayerAtLeave(guid, true, true);// remove player from BG
m_OfflineQueue.RemoveAt(0); // remove from offline queue
@@ -1113,7 +1113,7 @@ namespace Game.BattleGrounds
// player is correct pointer, it is checked in WorldSession.LogoutPlayer()
m_OfflineQueue.Add(player.GetGUID());
m_Players[guid].OfflineRemoveTime = Global.WorldMgr.GetGameTime() + BattlegroundConst.MaxOfflineTime;
m_Players[guid].OfflineRemoveTime = GameTime.GetGameTime() + BattlegroundConst.MaxOfflineTime;
if (GetStatus() == BattlegroundStatus.InProgress)
{
// drop flag and handle other cleanups
@@ -66,7 +66,7 @@ namespace Game.BattleGrounds
ginfo.ArenaTeamId = arenateamid;
ginfo.IsRated = isRated;
ginfo.IsInvitedToBGInstanceGUID = 0;
ginfo.JoinTime = Time.GetMSTime();
ginfo.JoinTime = GameTime.GetGameTimeMS();
ginfo.RemoveInviteTime = 0;
ginfo.Team = leader.GetTeam();
ginfo.ArenaTeamRating = ArenaRating;
@@ -84,7 +84,7 @@ namespace Game.BattleGrounds
index++;
Log.outDebug(LogFilter.Battleground, "Adding Group to BattlegroundQueue bgTypeId : {0}, bracket_id : {1}, index : {2}", BgTypeId, bracketId, index);
uint lastOnlineTime = Time.GetMSTime();
uint lastOnlineTime = GameTime.GetGameTimeMS();
//announce world (this don't need mutex)
if (isRated && WorldConfig.GetBoolValue(WorldCfg.ArenaQueueAnnouncerEnable))
@@ -169,7 +169,7 @@ namespace Game.BattleGrounds
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo ginfo, BattlegroundBracketId bracket_id)
{
uint timeInQueue = Time.GetMSTimeDiff(ginfo.JoinTime, Time.GetMSTime());
uint timeInQueue = Time.GetMSTimeDiff(ginfo.JoinTime, GameTime.GetGameTimeMS());
uint team_index = TeamId.Alliance; //default set to TeamIndex.Alliance - or non rated arenas!
if (ginfo.ArenaType == 0)
{
@@ -388,7 +388,7 @@ namespace Game.BattleGrounds
if (bg.isArena() && bg.isRated())
bg.SetArenaTeamIdForTeam(ginfo.Team, ginfo.ArenaTeamId);
ginfo.RemoveInviteTime = Time.GetMSTime() + BattlegroundConst.InviteAcceptWaitTime;
ginfo.RemoveInviteTime = GameTime.GetGameTimeMS() + BattlegroundConst.InviteAcceptWaitTime;
// loop through the players
foreach (var guid in ginfo.Players.Keys)
@@ -586,7 +586,7 @@ namespace Game.BattleGrounds
// this could be 2 cycles but i'm checking only first team in queue - it can cause problem -
// if first is invited to BG and seconds timer expired, but we can ignore it, because players have only 80 seconds to click to enter bg
// and when they click or after 80 seconds the queue info is removed from queue
uint time_before = (uint)(Time.GetMSTime() - WorldConfig.GetIntValue(WorldCfg.BattlegroundPremadeGroupWaitForMatch));
uint time_before = (uint)(GameTime.GetGameTimeMS() - WorldConfig.GetIntValue(WorldCfg.BattlegroundPremadeGroupWaitForMatch));
for (uint i = 0; i < SharedConst.BGTeamsCount; i++)
{
if (!m_QueuedGroups[(int)bracket_id][BattlegroundConst.BgQueuePremadeAlliance + i].Empty())
@@ -881,7 +881,7 @@ namespace Game.BattleGrounds
// (after what time the ratings aren't taken into account when making teams) then
// the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account
// else leave the discard time on 0, this way all ratings will be discarded
int discardTime = (int)(Time.GetMSTime() - Global.BattlegroundMgr.GetRatingDiscardTimer());
int discardTime = (int)(GameTime.GetGameTimeMS() - Global.BattlegroundMgr.GetRatingDiscardTimer());
// we need to find 2 teams which will play next game
GroupQueueInfo[] queueArray = new GroupQueueInfo[SharedConst.BGTeamsCount];
@@ -1008,11 +1008,11 @@ namespace Game.BattleGrounds.Zones
// Demolisher is not in list
if (!DemoliserRespawnList.ContainsKey(i))
{
DemoliserRespawnList[i] = Time.GetMSTime() + 30000;
DemoliserRespawnList[i] = GameTime.GetGameTimeMS() + 30000;
}
else
{
if (DemoliserRespawnList[i] < Time.GetMSTime())
if (DemoliserRespawnList[i] < GameTime.GetGameTimeMS())
{
Demolisher.Relocate(SAMiscConst.NpcSpawnlocs[i]);
Demolisher.Respawn();
+2 -2
View File
@@ -49,8 +49,8 @@ namespace Game.Chat
int queuedClientsNum = Global.WorldMgr.GetQueuedSessionCount();
uint maxActiveClientsNum = Global.WorldMgr.GetMaxActiveSessionCount();
uint maxQueuedClientsNum = Global.WorldMgr.GetMaxQueuedSessionCount();
string uptime = Time.secsToTimeString(Global.WorldMgr.GetUptime());
uint updateTime = Global.WorldMgr.GetUpdateTime();
string uptime = Time.secsToTimeString(GameTime.GetUptime());
uint updateTime = Global.WorldMgr.GetWorldUpdateTime().GetLastUpdateTime();
handler.SendSysMessage(CypherStrings.ConnectedPlayers, playersNum, maxPlayersNum);
handler.SendSysMessage(CypherStrings.ConnectedUsers, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+11 -11
View File
@@ -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()
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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
+7 -5
View File
@@ -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);
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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();
}
}
+2 -2
View File
@@ -663,7 +663,7 @@ namespace Game
AccountDataTimes accountDataTimes = new AccountDataTimes();
accountDataTimes.PlayerGuid = playerGuid;
accountDataTimes.ServerTime = (uint)Global.WorldMgr.GetGameTime();
accountDataTimes.ServerTime = (uint)GameTime.GetGameTime();
for (AccountDataTypes i = 0; i < AccountDataTypes.Max; ++i)
accountDataTimes.AccountTimes[(int)i] = (uint)GetAccountData(i).Time;
@@ -759,7 +759,7 @@ namespace Game
stmt.AddValue(0, GetAccountId());
DB.Login.Execute(stmt);
pCurrChar.SetInGameTime(Time.GetMSTime());
pCurrChar.SetInGameTime(GameTime.GetGameTimeMS());
// announce group about member online (must be after add to player list to receive announce to self)
Group group = pCurrChar.GetGroup();
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Game
if (store.HasRecord(record.RecordID))
{
dbReply.Allow = true;
dbReply.Timestamp = (uint)Global.WorldMgr.GetGameTime();
dbReply.Timestamp = (uint)GameTime.GetGameTime();
store.WriteRecord(record.RecordID, GetSessionDbcLocale(), dbReply.Data);
}
else
+1 -1
View File
@@ -146,7 +146,7 @@ namespace Game
plrMover.SetInWater(!plrMover.IsInWater() || plrMover.GetMap().IsUnderWater(plrMover.GetPhaseShift(), movementInfo.Pos.posX, movementInfo.Pos.posY, movementInfo.Pos.posZ));
}
uint mstime = Time.GetMSTime();
uint mstime = GameTime.GetGameTimeMS();
if (m_clientTimeDelay == 0)
m_clientTimeDelay = mstime - movementInfo.Time;
+1 -1
View File
@@ -42,7 +42,7 @@ namespace Game
Log.outDebug(LogFilter.Network, "Time sync received: counter {0}, client ticks {1}, time since last sync {2}", packet.SequenceIndex, packet.ClientTime, packet.ClientTime - _player.m_timeSyncClient);
uint ourTicks = packet.ClientTime + (Time.GetMSTime() - _player.m_timeSyncServer);
uint ourTicks = packet.ClientTime + (GameTime.GetGameTimeMS() - _player.m_timeSyncServer);
// diff should be small
Log.outDebug(LogFilter.Network, "Our ticks: {0}, diff {1}, latency {2}", ourTicks, ourTicks - packet.ClientTime, GetLatency());
+3 -3
View File
@@ -3446,7 +3446,7 @@ namespace Game.Maps
sa.ownerGUID = ownerGUID;
sa.script = script.Value;
m_scriptSchedule.Add(Global.WorldMgr.GetGameTime() + script.Key, sa);
m_scriptSchedule.Add(GameTime.GetGameTime() + script.Key, sa);
if (script.Key == 0)
immedScript = true;
@@ -3476,7 +3476,7 @@ namespace Game.Maps
sa.ownerGUID = ownerGUID;
sa.script = script;
m_scriptSchedule.Add(Global.WorldMgr.GetGameTime() + delay, sa);
m_scriptSchedule.Add(GameTime.GetGameTime() + delay, sa);
Global.MapMgr.IncreaseScheduledScriptsCount();
@@ -3674,7 +3674,7 @@ namespace Game.Maps
// Process overdue queued scripts
KeyValuePair<long, ScriptAction> iter = m_scriptSchedule.First();
while (!m_scriptSchedule.Empty() && (iter.Key <= Global.WorldMgr.GetGameTime()))
while (!m_scriptSchedule.Empty() && (iter.Key <= GameTime.GetGameTime()))
{
ScriptAction step = iter.Value;
-2
View File
@@ -806,8 +806,6 @@ namespace Game
Values[WorldCfg.ShowKickInWorld] = GetDefaultValue("ShowKickInWorld", false);
Values[WorldCfg.ShowMuteInWorld] = GetDefaultValue("ShowMuteInWorld", false);
Values[WorldCfg.ShowBanInWorld] = GetDefaultValue("ShowBanInWorld", false);
Values[WorldCfg.IntervalLogUpdate] = GetDefaultValue("RecordUpdateTimeDiffInterval", 60000);
Values[WorldCfg.MinLogUpdate] = GetDefaultValue("MinRecordUpdateTimeDiff", 100);
Values[WorldCfg.Numthreads] = GetDefaultValue("MapUpdate.Threads", 1);
Values[WorldCfg.MaxResultsLookupCommands] = GetDefaultValue("Command.LookupMaxResults", 0);
+38 -81
View File
@@ -43,10 +43,10 @@ namespace Game
m_timers[timer] = new IntervalTimer();
m_allowedSecurityLevel = AccountTypes.Player;
m_gameTime = Time.UnixTime;
m_startTime = m_gameTime;
_realm = new Realm();
_worldUpdateTime = new WorldUpdateTime();
}
public Player FindPlayerInZone(uint zone)
@@ -841,10 +841,9 @@ namespace Game
// Initialize game time and timers
Log.outInfo(LogFilter.ServerLoading, "Initialize game time and timers");
m_gameTime = Time.UnixTime;
m_startTime = m_gameTime;
GameTime.UpdateGameTimers();
DB.Login.Execute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES({0}, {1}, 0, '{2}')", _realm.Id.Realm, m_startTime, ""); // One-time query
DB.Login.Execute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES({0}, {1}, 0, '{2}')", _realm.Id.Realm, GameTime.GetStartTime(), ""); // One-time query
m_timers[WorldTimers.Auctions].SetInterval(Time.Minute * Time.InMilliseconds);
m_timers[WorldTimers.AuctionsPending].SetInterval(250);
@@ -871,7 +870,7 @@ namespace Game
//mailtimer is increased when updating auctions
//one second is 1000 -(tested on win system)
// @todo Get rid of magic numbers
var localTime = Time.UnixTimeToDateTime(m_gameTime).ToLocalTime();
var localTime = Time.UnixTimeToDateTime(GameTime.GetGameTime()).ToLocalTime();
mail_timer = ((((localTime.Hour + 20) % 24) * Time.Hour * Time.InMilliseconds) / m_timers[WorldTimers.Auctions].GetInterval());
//1440
mail_timer_expires = ((Time.Day * Time.InMilliseconds) / (m_timers[(int)WorldTimers.Auctions].GetInterval()));
@@ -1091,28 +1090,6 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, @"VMap data directory is: {0}\vmaps", GetDataPath());
}
void ResetTimeDiffRecord()
{
if (m_updateTimeCount != 1)
return;
m_currentTime = Time.GetMSTime();
}
void RecordTimeDiff(string text)
{
if (m_updateTimeCount != 1)
return;
uint thisTime = Time.GetMSTime();
uint diff = Time.GetMSTimeDiff(m_currentTime, thisTime);
if (diff > WorldConfig.GetIntValue(WorldCfg.MinLogUpdate))
Log.outInfo(LogFilter.Server, "Difftime {0}: {1}.", text, diff);
m_currentTime = thisTime;
}
public void LoadAutobroadcasts()
{
uint oldMSTime = Time.GetMSTime();
@@ -1142,22 +1119,14 @@ namespace Game
public void Update(uint diff)
{
m_updateTime = diff;
///- Update the game time and check for shutdown time
_UpdateGameTime();
long currentGameTime = GameTime.GetGameTime();
if (diff > 100)
{
if (m_updateTimeSum > 60000)
{
Log.outDebug(LogFilter.Server, "Update time diff: {0}. Players online: {1}.", m_updateTimeSum / m_updateTimeCount, GetActiveSessionCount());
m_updateTimeSum = m_updateTime;
m_updateTimeCount = 1;
}
else
{
m_updateTimeSum += m_updateTime;
++m_updateTimeCount;
}
}
_worldUpdateTime.UpdateWithDiff(diff);
// Record update if recording set in log and diff is greater then minimum set in log
_worldUpdateTime.RecordUpdateTime(GameTime.GetGameTimeMS(), diff, (uint)GetActiveSessionCount());
// Update the different timers
for (WorldTimers i = 0; i < WorldTimers.Max; ++i)
@@ -1175,31 +1144,28 @@ namespace Game
Global.WhoListStorageMgr.Update();
}
// Update the game time and check for shutdown time
_UpdateGameTime();
// Handle daily quests reset time
if (m_gameTime > m_NextDailyQuestReset)
if (currentGameTime > m_NextDailyQuestReset)
{
DailyReset();
InitDailyQuestResetTime(false);
}
// Handle weekly quests reset time
if (m_gameTime > m_NextWeeklyQuestReset)
if (currentGameTime > m_NextWeeklyQuestReset)
ResetWeeklyQuests();
// Handle monthly quests reset time
if (m_gameTime > m_NextMonthlyQuestReset)
if (currentGameTime > m_NextMonthlyQuestReset)
ResetMonthlyQuests();
if (m_gameTime > m_NextRandomBGReset)
if (currentGameTime > m_NextRandomBGReset)
ResetRandomBG();
if (m_gameTime > m_NextGuildReset)
if (currentGameTime > m_NextGuildReset)
ResetGuildCap();
if (m_gameTime > m_NextCurrencyReset)
if (currentGameTime > m_NextCurrencyReset)
ResetCurrencyWeekCap();
//Handle auctions when the timer has passed
@@ -1243,14 +1209,14 @@ namespace Game
}
//Handle session updates when the timer has passed
ResetTimeDiffRecord();
_worldUpdateTime.RecordUpdateTimeReset();
UpdateSessions(diff);
RecordTimeDiff("UpdateSessions");
_worldUpdateTime.RecordUpdateTimeDuration("UpdateSessions");
// <li> Update uptime table
if (m_timers[WorldTimers.UpTime].Passed())
{
uint tmpDiff = (uint)(m_gameTime - m_startTime);
uint tmpDiff = GameTime.GetUptime();
uint maxOnlinePlayers = GetMaxPlayerCount();
m_timers[WorldTimers.UpTime].Reset();
@@ -1260,7 +1226,7 @@ namespace Game
stmt.AddValue(0, tmpDiff);
stmt.AddValue(1, maxOnlinePlayers);
stmt.AddValue(2, _realm.Id.Realm);
stmt.AddValue(3, m_startTime);
stmt.AddValue(3, (uint)GameTime.GetStartTime());
DB.Login.Execute(stmt);
}
@@ -1281,9 +1247,9 @@ namespace Game
}
}
ResetTimeDiffRecord();
_worldUpdateTime.RecordUpdateTimeReset();
Global.MapMgr.Update(diff);
RecordTimeDiff("UpdateMapMgr");
_worldUpdateTime.RecordUpdateTimeDuration("UpdateMapMgr");
if (WorldConfig.GetBoolValue(WorldCfg.AutoBroadcast))
{
@@ -1295,13 +1261,13 @@ namespace Game
}
Global.BattlegroundMgr.Update(diff);
RecordTimeDiff("UpdateBattlegroundMgr");
_worldUpdateTime.RecordUpdateTimeDuration("UpdateBattlegroundMgr");
Global.OutdoorPvPMgr.Update(diff);
RecordTimeDiff("UpdateOutdoorPvPMgr");
_worldUpdateTime.RecordUpdateTimeDuration("UpdateOutdoorPvPMgr");
Global.BattleFieldMgr.Update(diff);
RecordTimeDiff("BattlefieldMgr");
_worldUpdateTime.RecordUpdateTimeDuration("BattlefieldMgr");
//- Delete all characters which have been deleted X days before
if (m_timers[WorldTimers.DeleteChars].Passed())
@@ -1311,14 +1277,14 @@ namespace Game
}
Global.LFGMgr.Update(diff);
RecordTimeDiff("UpdateLFGMgr");
_worldUpdateTime.RecordUpdateTimeDuration("UpdateLFGMgr");
Global.GroupMgr.Update(diff);
RecordTimeDiff("GroupMgr");
_worldUpdateTime.RecordUpdateTimeDuration("GroupMgr");
// execute callbacks from sql queries that were queued recently
ProcessQueryCallbacks();
RecordTimeDiff("ProcessQueryCallbacks");
_worldUpdateTime.RecordUpdateTimeDuration("ProcessQueryCallbacks");
// Erase corpses once every 20 minutes
if (m_timers[WorldTimers.Corpses].Passed())
@@ -1647,9 +1613,10 @@ namespace Game
void _UpdateGameTime()
{
// update the time
long thisTime = Time.UnixTime;
uint elapsed = (uint)(thisTime - m_gameTime);
m_gameTime = thisTime;
long lastGameTime = GameTime.GetGameTime();
GameTime.UpdateGameTimers();
uint elapsed = (uint)(GameTime.GetGameTime() - lastGameTime);
//- if there is a shutdown timer
if (!IsStopped && m_ShutdownTimer > 0 && elapsed > 0)
@@ -2218,15 +2185,6 @@ namespace Game
public void SetDataPath(string path) { _dataPath = path; }
// When server started?
long GetStartTime() { return m_startTime; }
// What time is it?
public long GetGameTime() { return m_gameTime; }
// Uptime (in secs)
public uint GetUptime() { return (uint)(m_gameTime - m_startTime); }
// Update time
public uint GetUpdateTime() { return m_updateTime; }
public long GetNextDailyQuestsResetTime() { return m_NextDailyQuestReset; }
public long GetNextWeeklyQuestsResetTime() { return m_NextWeeklyQuestReset; }
long GetNextRandomBGResetTime() { return m_NextRandomBGReset; }
@@ -2310,6 +2268,8 @@ namespace Game
public CleaningFlags GetCleaningFlags() { return m_CleaningFlags; }
public void SetCleaningFlags(CleaningFlags flags) { m_CleaningFlags = flags; }
public WorldUpdateTime GetWorldUpdateTime() { return _worldUpdateTime; }
#region Fields
uint m_ShutdownTimer;
ShutdownMask m_ShutdownMask;
@@ -2330,15 +2290,10 @@ namespace Game
bool m_isClosed;
long m_startTime;
long m_gameTime;
Dictionary<WorldTimers, IntervalTimer> m_timers = new Dictionary<WorldTimers, IntervalTimer>();
long mail_timer;
long mail_timer_expires;
long blackmarket_timer;
uint m_updateTime, m_updateTimeSum;
uint m_updateTimeCount;
uint m_currentTime;
ConcurrentDictionary<uint, WorldSession> m_sessions = new ConcurrentDictionary<uint, WorldSession>();
Dictionary<uint, long> m_disconnects = new Dictionary<uint, long>();
@@ -2371,6 +2326,8 @@ namespace Game
Realm _realm;
string _dataPath;
WorldUpdateTime _worldUpdateTime;
#endregion
}
+1 -1
View File
@@ -1835,7 +1835,7 @@ namespace Game.Spells
float ppm = m_spellInfo.CalcProcPPM(actor, m_castItemLevel);
float averageProcInterval = 60.0f / ppm;
var currentTime = DateTime.Now;
var currentTime = GameTime.GetGameTimeSteadyPoint();
float secondsSinceLastAttempt = Math.Min((float)(currentTime - m_lastProcAttemptTime).TotalSeconds, 10.0f);
float secondsSinceLastProc = Math.Min((float)(currentTime - m_lastProcSuccessTime).TotalSeconds, 1000.0f);
+1 -1
View File
@@ -1729,7 +1729,7 @@ namespace Game.Spells
if (unit.IsAlive() != target.alive)
return;
if (getState() == SpellState.Delayed && !m_spellInfo.IsPositive() && (Time.GetMSTime() - target.timeDelay) <= unit.m_lastSanctuaryTime)
if (getState() == SpellState.Delayed && !m_spellInfo.IsPositive() && (GameTime.GetGameTimeMS() - target.timeDelay) <= unit.m_lastSanctuaryTime)
return; // No missinfo in that case
// Get original caster (if exist) and calculate damage/healing from him data
+1 -1
View File
@@ -3400,7 +3400,7 @@ namespace Game.Spells
unit.AttackStop();
}
unitTarget.m_lastSanctuaryTime = Time.GetMSTime();
unitTarget.m_lastSanctuaryTime = GameTime.GetGameTimeMS();
// Vanish allows to remove all threat and cast regular stealth so other spells can be used
if (m_caster.IsTypeId(TypeId.Player)
+16 -16
View File
@@ -159,7 +159,7 @@ namespace Game.Spells
public void Update()
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
foreach (var pair in _categoryCooldowns.ToList())
{
if (pair.Value.CategoryEnd < now)
@@ -233,7 +233,7 @@ namespace Game.Spells
public void WritePacket(SendSpellHistory sendSpellHistory)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
foreach (var p in _spellCooldowns)
{
SpellHistoryEntry historyEntry = new SpellHistoryEntry();
@@ -263,7 +263,7 @@ namespace Game.Spells
public void WritePacket(SendSpellCharges sendSpellCharges)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
foreach (var key in _categoryCharges.Keys)
{
var list = _categoryCharges[key];
@@ -284,7 +284,7 @@ namespace Game.Spells
public void WritePacket(PetSpells petSpells)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
foreach (var pair in _spellCooldowns)
{
@@ -337,7 +337,7 @@ namespace Game.Spells
GetCooldownDurations(spellInfo, itemId, ref cooldown, ref categoryId, ref categoryCooldown);
DateTime curTime = DateTime.Now;
DateTime curTime = GameTime.GetGameTimeSystemPoint();
DateTime catrecTime;
DateTime recTime;
bool needsCooldownPacket = false;
@@ -407,7 +407,7 @@ namespace Game.Spells
SpellCategoryRecord categoryEntry = CliDB.SpellCategoryStorage.LookupByKey(categoryId);
if (categoryEntry.Flags.HasAnyFlag(SpellCategoryFlags.CooldownExpiresAtDailyReset))
categoryCooldown = (int)(Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - DateTime.Now).TotalMilliseconds;
categoryCooldown = (int)(Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - GameTime.GetGameTimeSystemPoint()).TotalMilliseconds;
}
// replace negative cooldowns by 0
@@ -472,7 +472,7 @@ namespace Game.Spells
public void AddCooldown(uint spellId, uint itemId, TimeSpan cooldownDuration)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
AddCooldown(spellId, itemId, now + cooldownDuration, 0, now);
}
@@ -503,7 +503,7 @@ namespace Game.Spells
if (offset.TotalMilliseconds == 0 || cooldownEntry == null)
return;
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
if (cooldownEntry.CooldownEnd + offset > now)
cooldownEntry.CooldownEnd += offset;
@@ -619,7 +619,7 @@ namespace Game.Spells
end = cooldownEntry.CategoryEnd;
}
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
if (end < now)
return 0;
@@ -629,7 +629,7 @@ namespace Game.Spells
public void LockSpellSchool(SpellSchoolMask schoolMask, uint lockoutTime)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
DateTime lockoutEnd = now + TimeSpan.FromMilliseconds(lockoutTime);
for (int i = 0; i < (int)SpellSchools.Max; ++i)
if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask))
@@ -685,7 +685,7 @@ namespace Game.Spells
public bool IsSchoolLocked(SpellSchoolMask schoolMask)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
for (int i = 0; i < (int)SpellSchools.Max; ++i)
if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask))
if (_schoolLockouts[i] > now)
@@ -705,7 +705,7 @@ namespace Game.Spells
DateTime recoveryStart;
var charges = _categoryCharges.LookupByKey(chargeCategoryId);
if (charges.Empty())
recoveryStart = DateTime.Now;
recoveryStart = GameTime.GetGameTimeSystemPoint();
else
recoveryStart = charges.Last().RechargeEnd;
@@ -729,7 +729,7 @@ namespace Game.Spells
SetSpellCharges setSpellCharges = new SetSpellCharges();
setSpellCharges.Category = chargeCategoryId;
if (!chargeList.Empty())
setSpellCharges.NextRecoveryTime = (uint)(chargeList.FirstOrDefault().RechargeEnd - DateTime.Now).TotalMilliseconds;
setSpellCharges.NextRecoveryTime = (uint)(chargeList.FirstOrDefault().RechargeEnd - GameTime.GetGameTimeSystemPoint()).TotalMilliseconds;
setSpellCharges.ConsumedCharges = (byte)chargeList.Count;
setSpellCharges.IsPet = player != _owner;
@@ -817,12 +817,12 @@ namespace Game.Spells
public bool HasGlobalCooldown(SpellInfo spellInfo)
{
return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > DateTime.Now;
return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > GameTime.GetGameTimeSystemPoint();
}
public void AddGlobalCooldown(SpellInfo spellInfo, uint duration)
{
_globalCooldowns[spellInfo.StartRecoveryCategory] = DateTime.Now + TimeSpan.FromMilliseconds(duration);
_globalCooldowns[spellInfo.StartRecoveryCategory] = GameTime.GetGameTimeSystemPoint() + TimeSpan.FromMilliseconds(duration);
}
public void CancelGlobalCooldown(SpellInfo spellInfo)
@@ -924,7 +924,7 @@ namespace Game.Spells
foreach (var c in _spellCooldowns)
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
uint cooldownDuration = c.Value.CooldownEnd > now ? (uint)(c.Value.CooldownEnd - now).TotalMilliseconds : 0;
// cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs
+52
View File
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
public class GameTime
{
static long StartTime = Time.UnixTime;
static long _gameTime = 0;
static uint _gameMSTime = 0;
static DateTime _gameTimeSystemPoint = DateTime.MinValue;
static DateTime _gameTimeSteadyPoint = DateTime.MinValue;
public static long GetStartTime()
{
return StartTime;
}
public static long GetGameTime()
{
return _gameTime;
}
public static uint GetGameTimeMS()
{
return _gameMSTime;
}
public static DateTime GetGameTimeSystemPoint()
{
return _gameTimeSystemPoint;
}
public static DateTime GetGameTimeSteadyPoint()
{
return _gameTimeSteadyPoint;
}
public static uint GetUptime()
{
return (uint)(_gameTime - StartTime);
}
public static void UpdateGameTimers()
{
_gameTime = Time.UnixTime;
_gameMSTime = Time.GetMSTime();
_gameTimeSystemPoint = DateTime.Now;
_gameTimeSteadyPoint = DateTime.Now;
}
}
+126
View File
@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Text;
using Framework;
namespace Game
{
public class UpdateTime
{
uint[] _updateTimeDataTable = new uint[500];
uint _averageUpdateTime;
uint _totalUpdateTime;
uint _updateTimeTableIndex;
uint _maxUpdateTime;
uint _maxUpdateTimeOfLastTable;
uint _maxUpdateTimeOfCurrentTable;
uint _recordedTime;
public uint GetAverageUpdateTime()
{
return _averageUpdateTime;
}
public uint GetTimeWeightedAverageUpdateTime()
{
uint sum = 0, weightsum = 0;
foreach (uint diff in _updateTimeDataTable)
{
sum += diff * diff;
weightsum += diff;
}
return sum / weightsum;
}
public uint GetMaxUpdateTime()
{
return _maxUpdateTime;
}
public uint GetMaxUpdateTimeOfCurrentTable()
{
return Math.Max(_maxUpdateTimeOfCurrentTable, _maxUpdateTimeOfLastTable);
}
public uint GetLastUpdateTime()
{
return _updateTimeDataTable[_updateTimeTableIndex != 0 ? _updateTimeTableIndex - 1 : _updateTimeDataTable.Length - 1u];
}
public void UpdateWithDiff(uint diff)
{
_totalUpdateTime = _totalUpdateTime - _updateTimeDataTable[_updateTimeTableIndex] + diff;
_updateTimeDataTable[_updateTimeTableIndex] = diff;
if (diff > _maxUpdateTime)
_maxUpdateTime = diff;
if (diff > _maxUpdateTimeOfCurrentTable)
_maxUpdateTimeOfCurrentTable = diff;
if (++_updateTimeTableIndex >= _updateTimeDataTable.Length)
{
_updateTimeTableIndex = 0;
_maxUpdateTimeOfLastTable = _maxUpdateTimeOfCurrentTable;
_maxUpdateTimeOfCurrentTable = 0;
}
if (_updateTimeDataTable[_updateTimeDataTable.Length - 1] != 0)
_averageUpdateTime = (uint)(_totalUpdateTime / _updateTimeDataTable.Length);
else if (_updateTimeTableIndex != 0)
_averageUpdateTime = _totalUpdateTime / _updateTimeTableIndex;
}
public void RecordUpdateTimeReset()
{
_recordedTime = Time.GetMSTime();
}
public void RecordUpdateTimeDuration(string text, uint minUpdateTime)
{
uint thisTime = Time.GetMSTime();
uint diff = Time.GetMSTimeDiff(_recordedTime, thisTime);
if (diff > minUpdateTime)
Log.outInfo(LogFilter.Misc, $"Recored Update Time of {text}: {diff}.");
_recordedTime = thisTime;
}
}
public class WorldUpdateTime : UpdateTime
{
uint _recordUpdateTimeInverval;
uint _recordUpdateTimeMin;
uint _lastRecordTime;
public void LoadFromConfig()
{
_recordUpdateTimeInverval = WorldConfig.GetDefaultValue("RecordUpdateTimeDiffInterval", 60000u);
_recordUpdateTimeMin = WorldConfig.GetDefaultValue("MinRecordUpdateTimeDiff", 100u);
}
public void SetRecordUpdateTimeInterval(uint t)
{
_recordUpdateTimeInverval = t;
}
public void RecordUpdateTime(uint gameTimeMs, uint diff, uint sessionCount)
{
if (_recordUpdateTimeInverval > 0 && diff > _recordUpdateTimeMin)
{
if (Time.GetMSTimeDiff(_lastRecordTime, gameTimeMs) > _recordUpdateTimeInverval)
{
Log.outDebug(LogFilter.Misc, $"Update time diff: {GetAverageUpdateTime()}. Players online: {sessionCount}.");
_lastRecordTime = gameTimeMs;
}
}
}
public void RecordUpdateTimeDuration(string text)
{
RecordUpdateTimeDuration(text, _recordUpdateTimeMin);
}
}
}
+1 -1
View File
@@ -87,7 +87,7 @@ namespace Game
{
if (_initialized)
{
uint currentTimestamp = Time.GetMSTime();
uint currentTimestamp = GameTime.GetGameTimeMS();
uint diff = currentTimestamp - _previousTimestamp;
_previousTimestamp = currentTimestamp;
+3 -3
View File
@@ -148,7 +148,7 @@ namespace Game
_initialized = true;
_previousTimestamp = Time.GetMSTime();
_previousTimestamp = GameTime.GetGameTimeMS();
}
public override void RequestData()
@@ -162,7 +162,7 @@ namespace Game
if (_otherChecksTodo.Empty())
_otherChecksTodo.AddRange(Global.WardenCheckMgr.OtherChecksIdPool);
_serverTicks = Time.GetMSTime();
_serverTicks = GameTime.GetGameTimeMS();
ushort id;
WardenCheckType type;
@@ -323,7 +323,7 @@ namespace Game
uint newClientTicks = buff.ReadUInt32();
uint ticksNow = Time.GetMSTime();
uint ticksNow = GameTime.GetGameTimeMS();
uint ourTicks = newClientTicks + (ticksNow - _serverTicks);
Log.outDebug(LogFilter.Warden, "ServerTicks {0}", ticksNow); // Now
+1 -1
View File
@@ -150,7 +150,7 @@ namespace Game
WeatherType old_type = m_type;
float old_grade = m_grade;
long gtime = Global.WorldMgr.GetGameTime();
long gtime = GameTime.GetGameTime();
var ltime = Time.UnixTimeToDateTime(gtime).ToLocalTime();
uint season = (uint)((ltime.DayOfYear - 78 + 365) / 91) % 4;
@@ -1449,7 +1449,7 @@ namespace Scripts.Northrend.IcecrownCitadel
GameObject trap = GetCaster().FindNearestGameObject(trapId, 5.0f);
if (trap)
trap.SetRespawnTime((int)trap.GetGoInfo().GetAutoCloseTime());
trap.SetRespawnTime((int)trap.GetGoInfo().GetAutoCloseTime() / Time.InMilliseconds);
List<Creature> wards = new List<Creature>();
GetCaster().GetCreatureListWithEntryInGrid(wards, CreatureIds.DeathboundWard, 150.0f);
@@ -269,7 +269,7 @@ namespace Scripts.Northrend.Nexus.Nexus
while (time[i] != 0)
++i;
time[i] = Global.WorldMgr.GetGameTime();
time[i] = GameTime.GetGameTime();
if (i == 2 && (time[2] - time[1] < 5) && (time[1] - time[0] < 5))
++splitPersonality;
}
+2 -2
View File
@@ -2661,7 +2661,7 @@ namespace Scripts.Spells.Generic
void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
// store stack apply times, so we can pop them while they expire
_applyTimes.Add(Time.GetMSTime());
_applyTimes.Add(GameTime.GetGameTimeMS());
Unit target = GetTarget();
// on stack 15 cast the achievement crediting spell
@@ -2675,7 +2675,7 @@ namespace Scripts.Spells.Generic
return;
// pop stack if it expired for us
if (_applyTimes.First() + GetMaxDuration() < Time.GetMSTime())
if (_applyTimes.First() + GetMaxDuration() < GameTime.GetGameTimeMS())
ModStackAmount(-1, AuraRemoveMode.Expire);
}
+4 -4
View File
@@ -276,7 +276,7 @@ namespace Scripts.World
{
uint triggerId = trigger.Id;
// Second trigger happened too early after first, skip for now
if (Global.WorldMgr.GetGameTime() - _triggerTimes[triggerId] < AreaTriggerConst.AreatriggerTalkCooldown)
if (GameTime.GetGameTime() - _triggerTimes[triggerId] < AreaTriggerConst.AreatriggerTalkCooldown)
return false;
switch (triggerId)
@@ -295,7 +295,7 @@ namespace Scripts.World
break;
}
_triggerTimes[triggerId] = Global.WorldMgr.GetGameTime();
_triggerTimes[triggerId] = GameTime.GetGameTime();
return false;
}
@@ -318,7 +318,7 @@ namespace Scripts.World
return false;
uint triggerId = trigger.Id;
if (Global.WorldMgr.GetGameTime() - _triggerTimes[trigger.Id] < AreaTriggerConst.SummonCooldown)
if (GameTime.GetGameTime() - _triggerTimes[trigger.Id] < AreaTriggerConst.SummonCooldown)
return false;
switch (triggerId)
@@ -347,7 +347,7 @@ namespace Scripts.World
player.SummonCreature(AreaTriggerConst.NpcSpotlight, x, y, z, 0.0f, TempSummonType.TimedDespawn, 5000);
player.AddAura(AreaTriggerConst.SpellA52Neuralyzer, player);
_triggerTimes[trigger.Id] = Global.WorldMgr.GetGameTime();
_triggerTimes[trigger.Id] = GameTime.GetGameTime();
return false;
}
+1 -1
View File
@@ -97,7 +97,7 @@ namespace Scripts.World
// remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold
player.GetSpellHistory().ResetCooldowns(pair =>
{
DateTime now = DateTime.Now;
DateTime now = GameTime.GetGameTimeSystemPoint();
uint cooldownDuration = pair.Value.CooldownEnd > now ? (uint)(pair.Value.CooldownEnd - now).TotalMilliseconds : 0;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(pair.Key);
return spellInfo.RecoveryTime < 10 * Time.Minute * Time.InMilliseconds