From 6c4308bce6ab424bb38166f3816ab1d41cd7b71b Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 13 Mar 2021 01:32:04 -0800 Subject: [PATCH] fix(core): Caches DateTime.NowUtc (#548) - [X] Caches DateTime.NowUtc on the game loop (not other threads) - [X] Replaces all locations where it makes sense - [X] Adds Min/Max for `IComparable` (TimeSpan, DateTimes, etc) Closes #261 --- Projects/Server.Tests/Helpers/Packet.cs | 2 +- Projects/Server/Items/Item.cs | 8 +- Projects/Server/Main.cs | 28 ++++--- Projects/Server/Mobiles/AggressorInfo.cs | 4 +- Projects/Server/Mobiles/Mobile.cs | 26 +++---- Projects/Server/Network/NetState/NetState.cs | 8 +- .../Network/Packets/IncomingAccountPackets.cs | 2 +- .../Network/Packets/OutgoingPlayerPackets.cs | 3 +- Projects/Server/Serialization/BufferWriter.cs | 2 + Projects/Server/Serialization/Persistence.cs | 6 +- Projects/Server/Targeting/Target.cs | 8 +- Projects/Server/TileMatrix/TileMatrix.cs | 8 +- Projects/Server/Utilities/Utility.cs | 7 +- .../Network/Packets/BuffIconPacketTests.cs | 2 +- .../Tests/Network/Packets/BuffIconPackets.cs | 11 +-- .../Accounting/AccessRestrictions.cs | 2 +- Projects/UOContent/Accounting/Account.cs | 14 ++-- .../Accounting/AccountAttackLimiter.cs | 8 +- .../UOContent/Accounting/AccountComment.cs | 6 +- .../UOContent/Accounting/AccountHandler.cs | 6 +- Projects/UOContent/Commands/Logging.cs | 9 +-- .../UOContent/Commands/Object Creation/Add.cs | 4 +- Projects/UOContent/Commands/Profiling.cs | 6 +- Projects/UOContent/Commands/ShardTime.cs | 2 +- .../Engines/CannedEvil/ChampionSpawn.cs | 10 +-- .../Engines/CannedEvil/StarRoomGate.cs | 4 +- .../Engines/ConPVP/AcceptDuelGump.cs | 7 +- .../UOContent/Engines/ConPVP/DuelContext.cs | 10 +-- .../UOContent/Engines/ConPVP/Games/CTF.cs | 8 +- .../Engines/ConPVP/Gumps/ConfirmSignupGump.cs | 2 +- .../ConPVP/Gumps/TournamentBracketGump.cs | 2 +- .../UOContent/Engines/ConPVP/Tournament.cs | 4 +- .../Engines/ConPVP/TournamentController.cs | 2 +- Projects/UOContent/Engines/ConPVP/Trophy.cs | 2 +- .../UOContent/Engines/Ethics/Core/Player.cs | 12 +-- .../Engines/Events/EventScheduler.cs | 4 +- .../Engines/Factions/Core/Election.cs | 19 ++--- .../Engines/Factions/Core/Faction.cs | 14 ++-- .../Engines/Factions/Core/FactionItem.cs | 4 +- .../Engines/Factions/Core/FactionState.cs | 14 ++-- .../Engines/Factions/Core/Keywords.cs | 2 +- .../Engines/Factions/Core/SilverGivenEntry.cs | 4 +- .../UOContent/Engines/Factions/Core/Town.cs | 8 +- .../Engines/Factions/Gumps/ElectionGump.cs | 6 +- .../Engines/Factions/Gumps/FinanceGump.cs | 4 +- .../Factions/Gumps/LeaveFactionGump.cs | 4 +- .../Power Faction Items/PowerFactionItem.cs | 2 +- .../UOContent/Engines/Factions/Items/Sigil.cs | 31 ++------ .../Factions/Items/Traps/BaseFactionTrap.cs | 4 +- .../Mobiles/Guards/BaseFactionGuard.cs | 6 +- .../Factions/Mobiles/Guards/GuardAI.cs | 17 ++-- .../Engines/Harvest/Core/HarvestBank.cs | 4 +- Projects/UOContent/Engines/Help/HelpGump.cs | 2 +- Projects/UOContent/Engines/Help/PageQueue.cs | 2 +- Projects/UOContent/Engines/Help/SpeechLog.cs | 4 +- Projects/UOContent/Engines/Help/StuckMenu.cs | 8 +- .../UOContent/Engines/Khaldun/PuzzleChest.cs | 4 +- .../UOContent/Engines/Khaldun/RaisableItem.cs | 4 +- .../UOContent/Engines/ML Quests/MLQuest.cs | 2 +- .../Engines/ML Quests/MLQuestEntry.cs | 6 +- .../Engines/ML Quests/Mobiles/SirHelper.cs | 4 +- .../ML Quests/Objectives/BaseObjective.cs | 4 +- .../ML Quests/Objectives/EscortObjective.cs | 12 +-- .../Objectives/GainSkillObjective.cs | 4 +- .../UOContent/Engines/Pathing/PathFollower.cs | 4 +- .../UOContent/Engines/Plants/PlantSystem.cs | 12 +-- .../Engines/Quests/Collector/Objectives.cs | 4 +- .../Engines/Quests/Core/QuestRestartInfo.cs | 2 +- .../Engines/Quests/Core/QuestSystem.cs | 2 +- .../Study of the Solen Hive/Objectives.cs | 4 +- .../UOContent/Engines/Spawners/BaseSpawner.cs | 6 +- .../Engines/Spawners/ProximitySpawner.cs | 6 +- .../Character Statue Maker/CharacterStatue.cs | 4 +- .../Engines/Veteran Rewards/RewardSystem.cs | 15 +--- .../UOContent/Engines/Virtues/Compassion.cs | 4 +- Projects/UOContent/Engines/Virtues/Honor.cs | 8 +- Projects/UOContent/Engines/Virtues/Justice.cs | 4 +- .../UOContent/Engines/Virtues/Sacrifice.cs | 8 +- Projects/UOContent/Engines/Virtues/Valor.cs | 4 +- .../UOContent/Engines/Virtues/VirtueHelper.cs | 4 +- Projects/UOContent/Gumps/AdminGump.cs | 14 +--- Projects/UOContent/Gumps/BanDurationGump.cs | 2 +- .../Gumps/Guilds/GuildChangeTypeGump.cs | 2 +- .../Guilds/New Guild System/OtherGuildInfo.cs | 8 +- Projects/UOContent/Gumps/HouseGumpAOS.cs | 2 +- Projects/UOContent/Gumps/ReportMurderer.cs | 4 +- .../UOContent/Gumps/VendorInventoryGump.cs | 2 +- .../Halloween/2006/Engines/TrickOrTreat.cs | 6 +- .../Halloween/2009/Engines/PumpkinPatch.cs | 2 +- .../Halloween/2012/Engines/PlayerZombies.cs | 6 +- .../Valentine/2011/Items/StValentinesBears.cs | 4 +- .../Valentine/2012/Items/CupidsArrow.cs | 2 +- .../Items/Addons/ArcheryButteAddon.cs | 4 +- .../Items/Addons/RejuvinationAnkhs.cs | 4 +- .../UOContent/Items/Addons/SHTeleporter.cs | 4 +- Projects/UOContent/Items/Aquarium/Aquarium.cs | 8 +- .../Items/Bulletin Boards/BulletinBoard.cs | 8 +- .../Items/Bulletin Boards/BulletinMessage.cs | 2 +- .../UOContent/Items/Clothing/OuterTorso.cs | 4 +- .../Items/Containers/FillableContainers.cs | 4 +- .../Items/Containers/MarkContainer.cs | 4 +- .../Items/Containers/TreasureMapChest.cs | 4 +- .../StealableArtifactsSpawner.cs | 6 +- .../UOContent/Items/Deeds/HolidayTreeDeed.cs | 2 +- .../Items/Games/Mahjong/MahjongGame.cs | 12 +-- Projects/UOContent/Items/Lights/BaseLight.cs | 17 +--- Projects/UOContent/Items/Misc/AcidSlime.cs | 4 +- .../UOContent/Items/Misc/Corpses/Corpse.cs | 20 ++--- .../Items/Misc/Corpses/DecayedCorpse.cs | 4 +- .../UOContent/Items/Misc/DeceitBrazier.cs | 10 +-- Projects/UOContent/Items/Misc/Firebomb.cs | 4 +- Projects/UOContent/Items/Misc/Guillotine.cs | 4 +- .../Items/Misc/PlayerBulletinBoards.cs | 2 +- Projects/UOContent/Items/Misc/PoolOfAcid.cs | 4 +- .../UOContent/Items/Misc/PowerGenerator.cs | 8 +- Projects/UOContent/Items/Misc/Teleporter.cs | 4 +- Projects/UOContent/Items/Misc/WarningItem.cs | 4 +- .../Items/Skill Items/Camping/Campfire.cs | 6 +- .../BaseConflagrationPotion.cs | 8 +- .../BaseConfusionBlastPotion.cs | 6 +- .../Items/Skill Items/Magical/Runebook.cs | 4 +- .../Musical Instruments/BaseInstrument.cs | 8 +- .../Items/Skill Items/Thief/DisguiseKit.cs | 10 +-- .../Skill Items/Thief/DisguisePersistance.cs | 2 +- .../Items/Skill Items/Tinkering/Clocks.cs | 4 +- .../8th Anniversary Items/FountainOfLife.cs | 2 +- .../Items/Special/Gifts/RoseOfTrinsic.cs | 4 +- .../Special/House Raffle/HouseRaffleDeed.cs | 2 +- .../Special/House Raffle/HouseRaffleStone.cs | 8 +- .../Special/Solen Items/BallOfSummoning.cs | 4 +- Projects/UOContent/Items/Special/SoulStone.cs | 6 +- .../Special Scrolls/ScrollofAlacrity.cs | 4 +- .../Special Scrolls/ScrollofTranscendence.cs | 2 +- .../Veteran Rewards/AnkhOfSacrifice.cs | 6 +- .../Special/Veteran Rewards/MiningCart.cs | 8 +- .../Special/Veteran Rewards/TreeStump.cs | 8 +- .../Items/Talismans/TalismanSummons.cs | 4 +- Projects/UOContent/Items/Traps/BaseTrap.cs | 8 +- .../UOContent/Items/Weapons/BaseWeapon.cs | 2 +- Projects/UOContent/Misc/AttackMessage.cs | 4 +- Projects/UOContent/Misc/BuffIcons.cs | 10 +-- Projects/UOContent/Misc/ClientVerification.cs | 2 +- Projects/UOContent/Misc/Email.cs | 4 +- Projects/UOContent/Misc/Guild.cs | 12 +-- Projects/UOContent/Misc/HardwareInfo.cs | 2 +- Projects/UOContent/Misc/Notoriety.cs | 2 +- Projects/UOContent/Misc/Profile.cs | 2 +- Projects/UOContent/Misc/ShardPoller.cs | 32 ++------ Projects/UOContent/Misc/SkillCheck.cs | 20 ++--- Projects/UOContent/Mobiles/AI/BaseAI.cs | 6 +- .../UOContent/Mobiles/Animals/Cows/Cow.cs | 4 +- .../UOContent/Mobiles/Animals/Misc/Sheep.cs | 8 +- .../Mobiles/Animals/Mounts/BaseMount.cs | 4 +- Projects/UOContent/Mobiles/BaseCreature.cs | 42 +++++----- .../UOContent/Mobiles/ChampionTitleInfo.cs | 4 +- .../UOContent/Mobiles/Familiars/DarkWolf.cs | 4 +- .../Mobiles/Familiars/HordeMinion.cs | 4 +- .../UOContent/Mobiles/Familiars/ShadowWisp.cs | 4 +- .../UOContent/Mobiles/Healers/BaseHealer.cs | 4 +- .../Mobiles/Monsters/AOS/Revenant.cs | 4 +- .../Monsters/Humanoid/Magic/Betrayer.cs | 6 +- .../Humanoid/Melee/KhaldunRevenant.cs | 4 +- .../Monsters/Humanoid/Melee/OrcBomber.cs | 6 +- .../Mobiles/Monsters/LBR/Jukas/JukaMage.cs | 8 +- .../Mobiles/Monsters/LBR/Meers/MeerCaptain.cs | 6 +- .../Mobiles/Monsters/LBR/Meers/MeerEternal.cs | 6 +- .../Mobiles/Monsters/LBR/Meers/MeerMage.cs | 6 +- .../Monsters/ML/Humanoid/Magic/MLDryad.cs | 12 +-- .../Monsters/ML/Humanoid/Magic/Satyr.cs | 20 ++--- .../Monsters/ML/Twisted Weald/Changeling.cs | 8 +- .../Monsters/Misc/Magic/EtherealWarrior.cs | 4 +- .../Monsters/Misc/Melee/PlagueSpawn.cs | 4 +- .../Mobiles/Monsters/Misc/Melee/SandVortex.cs | 4 +- Projects/UOContent/Mobiles/PlayerMobile.cs | 78 ++++++------------- .../Mobiles/Townfolk/BaseEscortable.cs | 22 +++--- .../UOContent/Mobiles/Townfolk/TownCrier.cs | 27 +------ .../UOContent/Mobiles/Vendors/BaseVendor.cs | 14 ++-- .../NPC/Guildmasters/BaseGuildmaster.cs | 8 +- .../Mobiles/Vendors/NPC/RealEstateBroker.cs | 4 +- .../UOContent/Mobiles/Vendors/NPC/Scribe.cs | 4 +- .../UOContent/Mobiles/Vendors/PlayerVendor.cs | 14 ++-- .../UOContent/Mobiles/Vendors/RentedVendor.cs | 8 +- .../Mobiles/Vendors/VendorInventory.cs | 4 +- Projects/UOContent/Multis/Boats/BaseBoat.cs | 18 ++--- Projects/UOContent/Multis/Camps/BaseCamp.cs | 2 +- Projects/UOContent/Multis/Houses/BaseHouse.cs | 22 +++--- Projects/UOContent/Multis/Houses/HouseSign.cs | 2 +- Projects/UOContent/Regions/HouseRegion.cs | 4 +- Projects/UOContent/Skills/AnimalTaming.cs | 4 +- Projects/UOContent/Skills/Discordance.cs | 8 +- Projects/UOContent/Skills/Inscribe.cs | 4 +- Projects/UOContent/Skills/Peacemaking.cs | 4 +- Projects/UOContent/Skills/Stealing.cs | 10 +-- .../Special Systems/Engines/GiftGiving.cs | 2 +- Projects/UOContent/Spells/Base/Spell.cs | 8 +- Projects/UOContent/Spells/Base/SpellHelper.cs | 4 +- .../UOContent/Spells/Fifth/PoisonField.cs | 4 +- Projects/UOContent/Spells/Fourth/FireField.cs | 4 +- .../Spells/Necromancy/BloodOathSpell.cs | 4 +- .../UOContent/Spells/Necromancy/MindRot.cs | 4 +- .../UOContent/Spells/Necromancy/PainSpike.cs | 2 +- .../UOContent/Spells/Necromancy/Strangle.cs | 6 +- .../UOContent/Spells/Ninjitsu/MirrorImage.cs | 2 +- .../UOContent/Spells/Sixth/ParalyzeField.cs | 4 +- .../Spells/Spellweaving/ArcaneCircle.cs | 2 +- .../Spellweaving/Items/TransientItem.cs | 6 +- .../Spells/Targeting/SpellTargetPoint3D.cs | 2 +- .../UOContent/Spells/Third/WallOfStone.cs | 6 +- 208 files changed, 660 insertions(+), 793 deletions(-) diff --git a/Projects/Server.Tests/Helpers/Packet.cs b/Projects/Server.Tests/Helpers/Packet.cs index 314375694..9432fc44e 100644 --- a/Projects/Server.Tests/Helpers/Packet.cs +++ b/Projects/Server.Tests/Helpers/Packet.cs @@ -206,7 +206,7 @@ namespace Server.Network using var op = new StreamWriter("compression_overflow.log", true); op.WriteLine( "{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", - DateTime.UtcNow, + Core.Now, PacketID, GetType().Name, length diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs index c6286d742..cb14751ea 100644 --- a/Projects/Server/Items/Item.cs +++ b/Projects/Server/Items/Item.cs @@ -955,7 +955,7 @@ namespace Server /* begin last moved time optimization */ var ticks = LastMoved.Ticks; - var now = DateTime.UtcNow.Ticks; + var now = Core.Now.Ticks; var minutes = new TimeSpan(now - ticks).TotalMinutes; @@ -2280,7 +2280,7 @@ namespace Server public void SetLastMoved() { - LastMoved = DateTime.UtcNow; + LastMoved = Core.Now; } public virtual bool CanStackWith(Item dropped) => @@ -2598,11 +2598,11 @@ namespace Server try { - LastMoved = DateTime.UtcNow - TimeSpan.FromMinutes(minutes); + LastMoved = Core.Now - TimeSpan.FromMinutes(minutes); } catch { - LastMoved = DateTime.UtcNow; + LastMoved = Core.Now; } } diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index 4ced23a24..c30b33643 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -37,8 +37,8 @@ namespace Server private static string _baseDirectory; private static bool _profiling; - private static DateTime _profileStart; - private static TimeSpan _profileTime; + private static long _profileStart; + private static long _profileTime; #nullable enable private static bool? _isRunningFromXUnit; #nullable restore @@ -95,19 +95,17 @@ namespace Server _profiling = value; - if (_profileStart > DateTime.MinValue) + if (_profileStart > 0) { - _profileTime += DateTime.UtcNow - _profileStart; + _profileTime += TickCount - _profileStart; } - _profileStart = _profiling ? DateTime.UtcNow : DateTime.MinValue; + _profileStart = _profiling ? TickCount : 0; } } public static TimeSpan ProfileTime => - _profileStart > DateTime.MinValue - ? _profileTime + (DateTime.UtcNow - _profileStart) - : _profileTime; + TimeSpan.FromMilliseconds(_profileStart > 0 ? _profileTime + (TickCount - _profileStart) : _profileTime); public static Assembly Assembly { get; set; } @@ -118,7 +116,11 @@ namespace Server public static Thread Thread { get; private set; } - [ThreadStatic] private static long _tickCount; + [ThreadStatic] + private static long _tickCount; + + [ThreadStatic] + private static DateTime _now; [MethodImpl(MethodImplOptions.AggressiveInlining)] private static long GetTicks() => 1000L * Stopwatch.GetTimestamp() / Stopwatch.Frequency; @@ -129,6 +131,12 @@ namespace Server set => _tickCount = value; } + public static DateTime Now + { + get => _now == DateTime.MinValue ? DateTime.UtcNow : _now; + set => _now = value; + } + public static bool MultiProcessor { get; private set; } public static int ProcessorCount { get; private set; } @@ -488,6 +496,7 @@ namespace Server while (!Closing) { _tickCount = TickCount; + _now = DateTime.UtcNow; var events = Mobile.ProcessDeltaQueue(); events += Item.ProcessDeltaQueue(); @@ -502,6 +511,7 @@ namespace Server events += _eventLoopContext.ExecuteTasks(); _tickCount = 0; + _now = DateTime.MinValue; if (events > 0) { diff --git a/Projects/Server/Mobiles/AggressorInfo.cs b/Projects/Server/Mobiles/AggressorInfo.cs index 5cef50d3d..1a4b72d52 100644 --- a/Projects/Server/Mobiles/AggressorInfo.cs +++ b/Projects/Server/Mobiles/AggressorInfo.cs @@ -38,7 +38,7 @@ namespace Server DumpAccess(); } - return m_Attacker.Deleted || m_Defender.Deleted || DateTime.UtcNow >= m_LastCombatTime + ExpireDelay; + return m_Attacker.Deleted || m_Defender.Deleted || Core.Now >= m_LastCombatTime + ExpireDelay; } } @@ -200,7 +200,7 @@ namespace Server DumpAccess(); } - m_LastCombatTime = DateTime.UtcNow; + m_LastCombatTime = Core.Now; m_Reported = false; } } diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index af401a00b..2eda04241 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -34,7 +34,7 @@ namespace Server private readonly DateTime m_Expire; public TimedSkillMod(SkillName skill, bool relative, double value, TimeSpan delay) - : this(skill, relative, value, DateTime.UtcNow + delay) + : this(skill, relative, value, Core.Now + delay) { } @@ -42,7 +42,7 @@ namespace Server : base(skill, relative, value) => m_Expire = expire; - public override bool CheckCondition() => DateTime.UtcNow < m_Expire; + public override bool CheckCondition() => Core.Now < m_Expire; } public class EquippedSkillMod : SkillMod @@ -240,7 +240,7 @@ namespace Server Name = name; Offset = offset; m_Duration = duration; - m_Added = DateTime.UtcNow; + m_Added = Core.Now; } public StatType Type { get; } @@ -249,15 +249,7 @@ namespace Server public int Offset { get; } - public bool HasElapsed() - { - if (m_Duration == TimeSpan.Zero) - { - return false; - } - - return DateTime.UtcNow - m_Added >= m_Duration; - } + public bool HasElapsed() => m_Duration != TimeSpan.Zero && Core.Now - m_Added >= m_Duration; } public class DamageEntry @@ -270,7 +262,7 @@ namespace Server public DateTime LastDamage { get; set; } - public bool HasExpired => DateTime.UtcNow > LastDamage + ExpireDelay; + public bool HasExpired => Core.Now > LastDamage + ExpireDelay; public List Responsible { get; set; } @@ -3747,7 +3739,7 @@ namespace Server return; } - var now = DateTime.UtcNow; + var now = Core.Now; var next = m_NextWarmodeChange; if (now > next || m_WarmodeChanges == 0) @@ -5996,7 +5988,7 @@ namespace Server var de = FindDamageEntryFor(from) ?? new DamageEntry(from); de.DamageGiven += amount; - de.LastDamage = DateTime.UtcNow; + de.LastDamage = Core.Now; DamageEntries.Remove(de); DamageEntries.Add(de); @@ -6028,7 +6020,7 @@ namespace Server } resp.DamageGiven += amount; - resp.LastDamage = DateTime.UtcNow; + resp.LastDamage = Core.Now; } return de; @@ -7925,7 +7917,7 @@ namespace Server DamageEntries = new List(); NextSkillTime = Core.TickCount; - CreationTime = DateTime.UtcNow; + CreationTime = Core.Now; } public virtual void Delta(MobileDelta flag) diff --git a/Projects/Server/Network/NetState/NetState.cs b/Projects/Server/Network/NetState/NetState.cs index 6218af426..152617e9c 100644 --- a/Projects/Server/Network/NetState/NetState.cs +++ b/Projects/Server/Network/NetState/NetState.cs @@ -148,14 +148,14 @@ namespace Server.Network _toString = "(error)"; } - ConnectedOn = DateTime.UtcNow; + ConnectedOn = Core.Now; CreatedCallback?.Invoke(this); } public DateTime ConnectedOn { get; } - public TimeSpan ConnectedFor => DateTime.UtcNow - ConnectedOn; + public TimeSpan ConnectedFor => Core.Now - ConnectedOn; public IPAddress Address { get; } @@ -1034,7 +1034,7 @@ namespace Server.Network try { using var op = new StreamWriter("network-errors.log", true); - op.WriteLine("# {0}", DateTime.UtcNow); + op.WriteLine("# {0}", Core.Now); op.WriteLine(ex); @@ -1083,7 +1083,7 @@ namespace Server.Network try { using StreamWriter op = new StreamWriter("network-disconnects.log", true); - op.WriteLine($"# {DateTime.UtcNow}"); + op.WriteLine($"# {Core.Now}"); op.WriteLine($"NetState: {ip}"); op.WriteLine(reason); diff --git a/Projects/Server/Network/Packets/IncomingAccountPackets.cs b/Projects/Server/Network/Packets/IncomingAccountPackets.cs index 229934a4f..fab4bdffd 100644 --- a/Projects/Server/Network/Packets/IncomingAccountPackets.cs +++ b/Projects/Server/Network/Packets/IncomingAccountPackets.cs @@ -33,7 +33,7 @@ namespace Server.Network public AuthIDPersistence(ClientVersion v) { - Age = DateTime.UtcNow; + Age = Core.Now; Version = v; } } diff --git a/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs b/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs index 59a59919d..5c76326f4 100644 --- a/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs +++ b/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs @@ -326,9 +326,8 @@ namespace Server.Network ns.Send(writer.Span); } - // TODO: Use DateTime caching against core loop [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void SendCurrentTime(this NetState ns) => ns.SendCurrentTime(DateTime.UtcNow); + public static void SendCurrentTime(this NetState ns) => ns.SendCurrentTime(Core.Now); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void SendCurrentTime(this NetState ns, DateTime date) => diff --git a/Projects/Server/Serialization/BufferWriter.cs b/Projects/Server/Serialization/BufferWriter.cs index 81f764c3b..27bb551fb 100644 --- a/Projects/Server/Serialization/BufferWriter.cs +++ b/Projects/Server/Serialization/BufferWriter.cs @@ -205,6 +205,8 @@ namespace Server Write(ticks); } + // TODO: Find a way to speed this up. + // Maybe used a special cached value? public void WriteDeltaTime(DateTime value) { var ticks = (value.Kind switch diff --git a/Projects/Server/Serialization/Persistence.cs b/Projects/Server/Serialization/Persistence.cs index c2b91309a..9c93638c7 100644 --- a/Projects/Server/Serialization/Persistence.cs +++ b/Projects/Server/Serialization/Persistence.cs @@ -84,14 +84,14 @@ namespace Server [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteConsole(string message) { - var now = DateTime.UtcNow; + var now = Core.Now; Console.Write("[{0} {1}] Persistence: {2}", now.ToShortDateString(), now.ToLongTimeString(), message); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteConsoleLine(string message) { - var now = DateTime.UtcNow; + var now = Core.Now; Console.WriteLine("[{0} {1}] Persistence: {2}", now.ToShortDateString(), now.ToLongTimeString(), message); } @@ -100,7 +100,7 @@ namespace Server try { using var op = new StreamWriter("save-errors.log", true); - op.WriteLine("# {0}", DateTime.UtcNow); + op.WriteLine("# {0}", Core.Now); op.WriteLine(ex); diff --git a/Projects/Server/Targeting/Target.cs b/Projects/Server/Targeting/Target.cs index 26ab65ec0..65e0a5f33 100644 --- a/Projects/Server/Targeting/Target.cs +++ b/Projects/Server/Targeting/Target.cs @@ -19,7 +19,7 @@ namespace Server.Targeting CheckLOS = true; } - public DateTime TimeoutTime { get; private set; } + public long TimeoutTime { get; private set; } public bool CheckLOS { get; set; } @@ -41,13 +41,13 @@ namespace Server.Targeting m.Target?.OnTargetCancel(m, TargetCancelType.Canceled); } - public void BeginTimeout(Mobile from, TimeSpan delay) + public void BeginTimeout(Mobile from, long delay) { - TimeoutTime = DateTime.UtcNow + delay; + TimeoutTime = Core.TickCount + delay; m_TimeoutTimer?.Stop(); - m_TimeoutTimer = new TimeoutTimer(this, from, delay); + m_TimeoutTimer = new TimeoutTimer(this, from, TimeSpan.FromMilliseconds(delay)); m_TimeoutTimer.Start(); } diff --git a/Projects/Server/TileMatrix/TileMatrix.cs b/Projects/Server/TileMatrix/TileMatrix.cs index 74fb818f2..beab68993 100644 --- a/Projects/Server/TileMatrix/TileMatrix.cs +++ b/Projects/Server/TileMatrix/TileMatrix.cs @@ -390,10 +390,10 @@ namespace Server } catch (EndOfStreamException ex) { - if (DateTime.UtcNow >= m_NextStaticWarning) + if (Core.Now >= m_NextStaticWarning) { Console.WriteLine("Warning: Static EOS for {0} ({1}, {2})", _map, x, y); - m_NextStaticWarning = DateTime.UtcNow + TimeSpan.FromMinutes(1.0); + m_NextStaticWarning = Core.Now + TimeSpan.FromMinutes(1.0); } return _emptyStaticBlock; @@ -438,10 +438,10 @@ namespace Server } catch (Exception ex) { - if (DateTime.UtcNow >= m_NextLandWarning) + if (Core.Now >= m_NextLandWarning) { Console.WriteLine("Warning: Land EOS for {0} ({1}, {2})", _map, x, y); - m_NextLandWarning = DateTime.UtcNow + TimeSpan.FromMinutes(1.0); + m_NextLandWarning = Core.Now + TimeSpan.FromMinutes(1.0); } return _invalidLandBlock; diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 30e02fe4a..3a0e2eee5 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -1338,7 +1338,10 @@ namespace Server val.CompareTo(max) > 0 ? max : val; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TimeSpan Max(this TimeSpan val, TimeSpan max) => val > max ? max : val; + public static T Min(T val, T min) where T : IComparable => val.CompareTo(min) < 0 ? val : min; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static T Max(T val, T max) where T : IComparable => val.CompareTo(max) > 0 ? val : max; public static string TrimMultiline(this string str, string lineSeparator = "\n") { @@ -1434,6 +1437,6 @@ namespace Server } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string GetTimeStamp() => DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss"); + public static string GetTimeStamp() => Core.Now.ToString("yyyy-MM-dd-HH-mm-ss"); } } diff --git a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs index e0dbed9d1..69963afe2 100644 --- a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs @@ -20,7 +20,7 @@ namespace UOContent.Tests ).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); - BuffInfo.SendAddBuffPacket(ns, mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan); + BuffInfo.SendAddBuffPacket(ns, mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); diff --git a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPackets.cs b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPackets.cs index 0723bb9c8..208d15207 100644 --- a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPackets.cs +++ b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPackets.cs @@ -11,7 +11,9 @@ namespace Server.Network info.TitleCliloc, info.SecondaryCliloc, info.Args, - info.TimeStart != DateTime.MinValue ? info.TimeStart + info.TimeLength - DateTime.UtcNow : TimeSpan.Zero + info.TimeStart != 0 ? + TimeSpan.FromMilliseconds(info.TimeStart + (long)info.TimeLength.TotalMilliseconds - Core.TickCount) : + TimeSpan.Zero ) { } @@ -37,12 +39,7 @@ namespace Server.Network Stream.Fill(4); - if (length < TimeSpan.Zero) - { - length = TimeSpan.Zero; - } - - Stream.Write((short)length.TotalSeconds); // Time in seconds + Stream.Write((short)Math.Max(length.TotalSeconds, 0)); // Time in seconds Stream.Fill(3); Stream.Write(titleCliloc); diff --git a/Projects/UOContent/Accounting/AccessRestrictions.cs b/Projects/UOContent/Accounting/AccessRestrictions.cs index d9f1f8824..cd794d6fd 100644 --- a/Projects/UOContent/Accounting/AccessRestrictions.cs +++ b/Projects/UOContent/Accounting/AccessRestrictions.cs @@ -31,7 +31,7 @@ namespace Server using (var op = new StreamWriter("ipLimits.log", true)) { - op.WriteLine("{0}\tPast IP limit threshold\t{1}", ip, DateTime.UtcNow); + op.WriteLine("{0}\tPast IP limit threshold\t{1}", ip, Core.Now); } e.AllowConnection = false; diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs index ee070b29c..a413ed3af 100644 --- a/Projects/UOContent/Accounting/Account.cs +++ b/Projects/UOContent/Accounting/Account.cs @@ -33,7 +33,7 @@ namespace Server.Accounting m_AccessLevel = AccessLevel.Player; - Created = LastLogin = DateTime.UtcNow; + Created = LastLogin = Core.Now; m_TotalGameTime = TimeSpan.Zero; m_Mobiles = new Mobile[7]; @@ -99,8 +99,8 @@ namespace Server.Accounting Enum.TryParse(Utility.GetText(node["accessLevel"], "Player"), true, out m_AccessLevel); Flags = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0); - Created = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.UtcNow); - LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.UtcNow); + Created = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), Core.Now); + LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), Core.Now); TotalGold = Utility.GetXMLInt32(Utility.GetText(node["totalGold"], "0"), 0); TotalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0); @@ -193,7 +193,7 @@ namespace Server.Accounting if (GetBanTags(out var banTime, out var banDuration)) { - if (banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= banTime + banDuration) + if (banDuration != TimeSpan.MaxValue && Core.Now >= banTime + banDuration) { SetUnspecifiedBan(null); // clear Banned = false; @@ -244,7 +244,7 @@ namespace Server.Accounting return false; } - var inactiveLength = DateTime.UtcNow - LastLogin; + var inactiveLength = Core.Now - LastLogin; return inactiveLength > (Count == 0 ? EmptyInactiveDuration : InactiveDuration); } @@ -262,7 +262,7 @@ namespace Server.Accounting { if (m_Mobiles[i] is PlayerMobile m && m.NetState != null) { - return m_TotalGameTime + (DateTime.UtcNow - m.SessionStart); + return m_TotalGameTime + (Core.Now - m.SessionStart); } } @@ -873,7 +873,7 @@ namespace Server.Accounting return; } - acc.m_TotalGameTime += DateTime.UtcNow - pm.SessionStart; + acc.m_TotalGameTime += Core.Now - pm.SessionStart; } private static void EventSink_Login(Mobile m) diff --git a/Projects/UOContent/Accounting/AccountAttackLimiter.cs b/Projects/UOContent/Accounting/AccountAttackLimiter.cs index 9cf167396..97bbc90df 100644 --- a/Projects/UOContent/Accounting/AccountAttackLimiter.cs +++ b/Projects/UOContent/Accounting/AccountAttackLimiter.cs @@ -39,7 +39,7 @@ namespace Server.Accounting return true; } - var date = DateTime.UtcNow; + var date = Core.Now; var access = accessLog.LastAccessTime + ComputeThrottle(accessLog.Counts); var allow = date >= access; drop = !allow; @@ -96,7 +96,7 @@ namespace Server.Accounting using var op = new StreamWriter("throttle.log", true); op.WriteLine( "{0}\t{1}\t{2}", - DateTime.UtcNow, + Core.Now, ns, accessLog.Counts ); @@ -151,13 +151,13 @@ namespace Server.Accounting public DateTime LastAccessTime { get; set; } - public bool HasExpired => DateTime.UtcNow >= LastAccessTime + TimeSpan.FromHours(1.0); + public bool HasExpired => Core.Now >= LastAccessTime + TimeSpan.FromHours(1.0); public int Counts { get; set; } public void RefreshAccessTime() { - LastAccessTime = DateTime.UtcNow; + LastAccessTime = Core.Now; } } } diff --git a/Projects/UOContent/Accounting/AccountComment.cs b/Projects/UOContent/Accounting/AccountComment.cs index b966490a2..b1066439f 100644 --- a/Projects/UOContent/Accounting/AccountComment.cs +++ b/Projects/UOContent/Accounting/AccountComment.cs @@ -16,7 +16,7 @@ namespace Server.Accounting { AddedBy = addedBy; m_Content = content; - LastModified = DateTime.UtcNow; + LastModified = Core.Now; } /// @@ -26,7 +26,7 @@ namespace Server.Accounting public AccountComment(XmlElement node) { AddedBy = Utility.GetAttribute(node, "addedBy", "empty"); - LastModified = Utility.GetXMLDateTime(Utility.GetAttribute(node, "lastModified"), DateTime.UtcNow); + LastModified = Utility.GetXMLDateTime(Utility.GetAttribute(node, "lastModified"), Core.Now); m_Content = Utility.GetText(node, ""); } @@ -55,7 +55,7 @@ namespace Server.Accounting set { m_Content = value; - LastModified = DateTime.UtcNow; + LastModified = Core.Now; } } diff --git a/Projects/UOContent/Accounting/AccountHandler.cs b/Projects/UOContent/Accounting/AccountHandler.cs index b2d8c6caa..cf07e57d1 100644 --- a/Projects/UOContent/Accounting/AccountHandler.cs +++ b/Projects/UOContent/Accounting/AccountHandler.cs @@ -238,7 +238,7 @@ namespace Server.Misc { res = DeleteResultType.CharBeingPlayed; } - else if (RestrictDeletion && DateTime.UtcNow < m.CreationTime + DeleteDelay) + else if (RestrictDeletion && Core.Now < m.CreationTime + DeleteDelay) { res = DeleteResultType.CharTooYoung; } @@ -336,7 +336,7 @@ namespace Server.Misc Console.WriteLine("Login: {0}: Past IP limit threshold", e.State); using var op = new StreamWriter("ipLimits.log", true); - op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow); + op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now); return; } @@ -404,7 +404,7 @@ namespace Server.Misc Console.WriteLine("Login: {0}: Past IP limit threshold", e.State); using var op = new StreamWriter("ipLimits.log", true); - op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow); + op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now); return; } diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index a116e3dea..2abf6b2cb 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -30,12 +30,11 @@ namespace Server.Commands try { - Output = new StreamWriter(Path.Combine(directory, $"{DateTime.UtcNow.ToLongDateString()}.log"), true); - + Output = new StreamWriter(Path.Combine(directory, $"{Core.Now.ToLongDateString()}.log"), true); Output.AutoFlush = true; Output.WriteLine("##############################"); - Output.WriteLine("Log started on {0}", DateTime.UtcNow); + Output.WriteLine("Log started on {0}", Core.Now); Output.WriteLine(); } catch @@ -71,7 +70,7 @@ namespace Server.Commands try { - Output.WriteLine("{0}: {1}: {2}", DateTime.UtcNow, from.NetState, text); + Output.WriteLine("{0}: {1}: {2}", Core.Now, from.NetState, text); var path = Core.BaseDirectory; @@ -83,7 +82,7 @@ namespace Server.Commands path = Path.Combine(path, $"{name}.log"); using var sw = new StreamWriter(path, true); - sw.WriteLine("{0}: {1}: {2}", DateTime.UtcNow, from.NetState, text); + sw.WriteLine("{0}: {1}: {2}", Core.Now, from.NetState, text); } catch { diff --git a/Projects/UOContent/Commands/Object Creation/Add.cs b/Projects/UOContent/Commands/Object Creation/Add.cs index 5a9491c1b..aa2a23828 100644 --- a/Projects/UOContent/Commands/Object Creation/Add.cs +++ b/Projects/UOContent/Commands/Object Creation/Add.cs @@ -119,7 +119,7 @@ namespace Server.Commands return; } - var time = DateTime.UtcNow; + var time = Core.Now; var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg); @@ -129,7 +129,7 @@ namespace Server.Commands "{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : "", - (DateTime.UtcNow - time).TotalSeconds + (Core.Now - time).TotalSeconds ); } else diff --git a/Projects/UOContent/Commands/Profiling.cs b/Projects/UOContent/Commands/Profiling.cs index b38bd3fb9..44dde487c 100644 --- a/Projects/UOContent/Commands/Profiling.cs +++ b/Projects/UOContent/Commands/Profiling.cs @@ -25,7 +25,7 @@ namespace Server.Commands try { using var sw = new StreamWriter("profiles.log", true); - sw.WriteLine("# Dump on {0:f}", DateTime.UtcNow); + sw.WriteLine("# Dump on {0:f}", Core.Now); sw.WriteLine($"# Core profiling for {Core.ProfileTime}"); sw.WriteLine("# Packet send"); @@ -114,7 +114,7 @@ namespace Server.Commands items.Sort(new CountSorter()); mobiles.Sort(new CountSorter()); - op.WriteLine("# Object count table generated on {0}", DateTime.UtcNow); + op.WriteLine("# Object count table generated on {0}", Core.Now); op.WriteLine(); op.WriteLine(); @@ -362,7 +362,7 @@ namespace Server.Commands using var op = new StreamWriter(opFile); op.WriteLine("# Profile of world {0}", type); - op.WriteLine("# Generated on {0}", DateTime.UtcNow); + op.WriteLine("# Generated on {0}", Core.Now); op.WriteLine(); op.WriteLine(); diff --git a/Projects/UOContent/Commands/ShardTime.cs b/Projects/UOContent/Commands/ShardTime.cs index c4ca0aa6f..8453de7a1 100644 --- a/Projects/UOContent/Commands/ShardTime.cs +++ b/Projects/UOContent/Commands/ShardTime.cs @@ -13,7 +13,7 @@ namespace Server.Commands [Usage("Time"), Description("Returns the server's local time.")] private static void Time_OnCommand(CommandEventArgs e) { - e.Mobile.SendMessage(DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); + e.Mobile.SendMessage(Core.Now.ToString(CultureInfo.InvariantCulture)); } } } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs index 877ed2ca5..ee97597bf 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs @@ -301,7 +301,7 @@ namespace Server.Engines.CannedEvil { m_RestartTimer?.Stop(); - RestartTime = DateTime.UtcNow + ts; + RestartTime = Core.Now + ts; m_RestartTimer = new RestartTimer(this, ts); m_RestartTimer.Start(); @@ -564,7 +564,7 @@ namespace Server.Engines.CannedEvil SetWhiteSkullCount(p / 20); } - if (DateTime.UtcNow >= ExpireTime) + if (Core.Now >= ExpireTime) { Expire(); } @@ -575,7 +575,7 @@ namespace Server.Engines.CannedEvil public void AdvanceLevel() { - ExpireTime = DateTime.UtcNow + ExpireDelay; + ExpireTime = Core.Now + ExpireDelay; if (Level < 16) { @@ -811,7 +811,7 @@ namespace Server.Engines.CannedEvil SetWhiteSkullCount(0); } - ExpireTime = DateTime.UtcNow + ExpireDelay; + ExpireTime = Core.Now + ExpireDelay; } public Point3D GetRedSkullLocation(int index) @@ -1293,7 +1293,7 @@ namespace Server.Engines.CannedEvil if (reader.ReadBool()) { RestartTime = reader.ReadDeltaTime(); - BeginRestart(RestartTime - DateTime.UtcNow); + BeginRestart(RestartTime - Core.Now); } if (version < 4) diff --git a/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs b/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs index 5c1b05c54..0eb74b62f 100644 --- a/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs +++ b/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs @@ -24,7 +24,7 @@ namespace Server.Items if (decays) { m_Decays = true; - m_DecayTime = DateTime.UtcNow + TimeSpan.FromMinutes(2.0); + m_DecayTime = Core.Now + TimeSpan.FromMinutes(2.0); m_Timer = new InternalTimer(this, m_DecayTime); m_Timer.Start(); @@ -87,7 +87,7 @@ namespace Server.Items { private readonly Item m_Item; - public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item; + public InternalTimer(Item item, DateTime end) : base(end - Core.Now) => m_Item = item; protected override void OnTick() { diff --git a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs index 942f5e575..0c65a1a21 100644 --- a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs +++ b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs @@ -310,12 +310,9 @@ namespace Server.Engines.ConPVP } public Mobile Ignored => m_Ignored; - public bool Expired => DateTime.UtcNow >= m_Expire; + public bool Expired => Core.Now >= m_Expire; - public void Refresh() - { - m_Expire = DateTime.UtcNow + ExpireDelay; - } + public void Refresh() => m_Expire = Core.Now + ExpireDelay; } } } diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index e8dab53ab..6f40bfce3 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -1298,7 +1298,7 @@ namespace Server.Engines.ConPVP { foreach (var info in m.Aggressed) { - if (info.Defender.Player && DateTime.UtcNow - info.LastCombatTime < CombatDelay) + if (info.Defender.Player && Core.Now - info.LastCombatTime < CombatDelay) { return true; } @@ -1306,7 +1306,7 @@ namespace Server.Engines.ConPVP foreach (var info in m.Aggressors) { - if (info.Attacker.Player && DateTime.UtcNow - info.LastCombatTime < CombatDelay) + if (info.Attacker.Player && Core.Now - info.LastCombatTime < CombatDelay) { return true; } @@ -2601,7 +2601,7 @@ namespace Server.Engines.ConPVP Mobile = mob; Location = loc; Facet = facet; - m_Expire = DateTime.UtcNow + TimeSpan.FromMinutes(30.0); + m_Expire = Core.Now + TimeSpan.FromMinutes(30.0); } public Mobile Mobile { get; } @@ -2610,7 +2610,7 @@ namespace Server.Engines.ConPVP public Map Facet { get; private set; } - public bool Expired => DateTime.UtcNow >= m_Expire; + public bool Expired => Core.Now >= m_Expire; public void Return() { @@ -2633,7 +2633,7 @@ namespace Server.Engines.ConPVP public void Update() { - m_Expire = DateTime.UtcNow + TimeSpan.FromMinutes(30.0); + m_Expire = Core.Now + TimeSpan.FromMinutes(30.0); if (Mobile.Map == Map.Internal) { diff --git a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs index 8e6fb29c3..b2b65e7a9 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs @@ -313,7 +313,7 @@ namespace Server.Engines.ConPVP } m_Returner = from; - m_ReturnTime = DateTime.UtcNow; + m_ReturnTime = Core.Now; SendHome(); @@ -356,7 +356,7 @@ namespace Server.Engines.ConPVP public void DropTo(Mobile mob, Mobile killer) { m_Fragger = killer; - m_FragTime = DateTime.UtcNow; + m_FragTime = Core.Now; if (mob != null) { @@ -464,7 +464,7 @@ namespace Server.Engines.ConPVP var teamFlag = useTeam.Flag; if (teamFlag.m_Fragger != null && - DateTime.UtcNow < teamFlag.m_FragTime + TimeSpan.FromSeconds(5.0) && + Core.Now < teamFlag.m_FragTime + TimeSpan.FromSeconds(5.0) && m_TeamInfo.Game.GetTeamInfo(teamFlag.m_Fragger) == useTeam) { var assistInfo = useTeam[teamFlag.m_Fragger]; @@ -476,7 +476,7 @@ namespace Server.Engines.ConPVP } if (teamFlag.m_Returner != null && - DateTime.UtcNow < teamFlag.m_ReturnTime + TimeSpan.FromSeconds(5.0)) + Core.Now < teamFlag.m_ReturnTime + TimeSpan.FromSeconds(5.0)) { var assistInfo = useTeam[teamFlag.m_Returner]; diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs index 6913769c4..40554a6b4 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs @@ -514,7 +514,7 @@ namespace Server.Engines.ConPVP string timeUntil; var minutesUntil = (int)Math.Round( - (tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow) + (tourney.SignupStart + tourney.SignupPeriod - Core.Now) .TotalMinutes ); diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs index d35084f89..5e7dfcddc 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -99,7 +99,7 @@ namespace Server.Engines.ConPVP if (m_Tournament.Stage == TournamentStage.Signup) { - var until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow; + var until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - Core.Now; string text; var secs = (int)until.TotalSeconds; diff --git a/Projects/UOContent/Engines/ConPVP/Tournament.cs b/Projects/UOContent/Engines/ConPVP/Tournament.cs index 1c7aa3e16..55b581977 100644 --- a/Projects/UOContent/Engines/ConPVP/Tournament.cs +++ b/Projects/UOContent/Engines/ConPVP/Tournament.cs @@ -681,7 +681,7 @@ namespace Server.Engines.ConPVP { if (CurrentStage == TournamentStage.Signup) { - var until = SignupStart + SignupPeriod - DateTime.UtcNow; + var until = SignupStart + SignupPeriod - Core.Now; if (until <= TimeSpan.Zero) { @@ -741,7 +741,7 @@ namespace Server.Engines.ConPVP else { /*Alert( "Is this all?", "Pitiful. Signup extended." ); - m_SignupStart = DateTime.UtcNow;*/ + m_SignupStart = Core.Now;*/ Alert("Is this all?", "Pitiful. Tournament cancelled."); CurrentStage = TournamentStage.Inactive; diff --git a/Projects/UOContent/Engines/ConPVP/TournamentController.cs b/Projects/UOContent/Engines/ConPVP/TournamentController.cs index 3555a75b5..9c403d33c 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentController.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentController.cs @@ -128,7 +128,7 @@ namespace Server.Engines.ConPVP { if (m_Tournament.Stage == TournamentStage.Inactive) { - m_Tournament.SignupStart = DateTime.UtcNow; + m_Tournament.SignupStart = Core.Now; m_Tournament.Stage = TournamentStage.Signup; m_Tournament.Participants.Clear(); m_Tournament.Pyramid.Levels.Clear(); diff --git a/Projects/UOContent/Engines/ConPVP/Trophy.cs b/Projects/UOContent/Engines/ConPVP/Trophy.cs index d4f8859e1..c82aa8763 100644 --- a/Projects/UOContent/Engines/ConPVP/Trophy.cs +++ b/Projects/UOContent/Engines/ConPVP/Trophy.cs @@ -19,7 +19,7 @@ namespace Server.Items { Title = title; m_Rank = rank; - Date = DateTime.UtcNow; + Date = Core.Now; LootType = LootType.Blessed; diff --git a/Projects/UOContent/Engines/Ethics/Core/Player.cs b/Projects/UOContent/Engines/Ethics/Core/Player.cs index 2ab302521..23eee750e 100644 --- a/Projects/UOContent/Engines/Ethics/Core/Player.cs +++ b/Projects/UOContent/Engines/Ethics/Core/Player.cs @@ -73,7 +73,7 @@ namespace Server.Ethics return false; } - if (DateTime.UtcNow < m_Shield + TimeSpan.FromHours(1.0)) + if (Core.Now < m_Shield + TimeSpan.FromHours(1.0)) { return true; } @@ -119,15 +119,9 @@ namespace Server.Ethics return pl; } - public void BeginShield() - { - m_Shield = DateTime.UtcNow; - } + public void BeginShield() => m_Shield = Core.Now; - public void FinishShield() - { - m_Shield = DateTime.MinValue; - } + public void FinishShield() => m_Shield = DateTime.MinValue; public void CheckAttach() { diff --git a/Projects/UOContent/Engines/Events/EventScheduler.cs b/Projects/UOContent/Engines/Events/EventScheduler.cs index 01b7889ce..363bfa320 100644 --- a/Projects/UOContent/Engines/Events/EventScheduler.cs +++ b/Projects/UOContent/Engines/Events/EventScheduler.cs @@ -58,7 +58,7 @@ namespace Server.Engines.Events public void ScheduleEvent(IEvent e, int hour, int min, TimeSpan interval) { - var now = DateTime.UtcNow; + var now = Core.Now; var firstRun = new DateTime(now.Year, now.Month, now.Day, hour, min, 0); while (now > firstRun) @@ -85,7 +85,7 @@ namespace Server.Engines.Events { foreach (var entry in _schedule) { - if (entry.NextOccurrence <= DateTime.UtcNow) + if (entry.NextOccurrence <= Core.Now) { entry.Occur(); } diff --git a/Projects/UOContent/Engines/Factions/Core/Election.cs b/Projects/UOContent/Engines/Factions/Core/Election.cs index 292fb1439..251085a69 100644 --- a/Projects/UOContent/Engines/Factions/Core/Election.cs +++ b/Projects/UOContent/Engines/Factions/Core/Election.cs @@ -67,7 +67,7 @@ namespace Server.Factions set { CurrentState = value; - LastStateTime = DateTime.UtcNow; + LastStateTime = Core.Now; } } @@ -89,12 +89,7 @@ namespace Server.Factions _ => PendingPeriod }; - var until = LastStateTime + period - DateTime.UtcNow; - - if (until < TimeSpan.Zero) - { - until = TimeSpan.Zero; - } + var until = Utility.Max(LastStateTime + period - Core.Now, TimeSpan.Zero); return until; } @@ -108,7 +103,7 @@ namespace Server.Factions _ => PendingPeriod }; - LastStateTime = DateTime.UtcNow - period + value; + LastStateTime = Core.Now - period + value; } } @@ -290,7 +285,7 @@ namespace Server.Factions { case ElectionState.Pending: { - if (LastStateTime + PendingPeriod > DateTime.UtcNow) + if (LastStateTime + PendingPeriod > Core.Now) { break; } @@ -304,7 +299,7 @@ namespace Server.Factions } case ElectionState.Campaign: { - if (LastStateTime + CampaignPeriod > DateTime.UtcNow) + if (LastStateTime + CampaignPeriod > Core.Now) { break; } @@ -346,7 +341,7 @@ namespace Server.Factions } case ElectionState.Election: { - if (LastStateTime + VotingPeriod > DateTime.UtcNow) + if (LastStateTime + VotingPeriod > Core.Now) { break; } @@ -413,7 +408,7 @@ namespace Server.Factions Address = IPAddress.None; } - Time = DateTime.UtcNow; + Time = Core.Now; } public Voter(IGenericReader reader, Mobile candidate) diff --git a/Projects/UOContent/Engines/Factions/Core/Faction.cs b/Projects/UOContent/Engines/Factions/Core/Faction.cs index e8f8f3dcd..c3e331c4b 100644 --- a/Projects/UOContent/Engines/Factions/Core/Faction.cs +++ b/Projects/UOContent/Engines/Factions/Core/Faction.cs @@ -235,7 +235,7 @@ namespace Server.Factions } else { - recvState.LastHonorTime = DateTime.UtcNow; + recvState.LastHonorTime = Core.Now; giveState.KillPoints -= 5; recvState.KillPoints += 4; @@ -604,7 +604,7 @@ namespace Server.Factions return false; } - if (pl.Leaving + LeavePeriod >= DateTime.UtcNow) + if (pl.Leaving + LeavePeriod >= Core.Now) { return false; } @@ -911,13 +911,13 @@ namespace Server.Factions var sigil = sigils[i]; if (!sigil.IsBeingCorrupted && sigil.GraceStart != DateTime.MinValue && - sigil.GraceStart + Sigil.CorruptionGrace < DateTime.UtcNow) + sigil.GraceStart + Sigil.CorruptionGrace < Core.Now) { if (sigil.LastMonolith is StrongholdMonolith && (sigil.Corrupted == null || sigil.LastMonolith.Faction != sigil.Corrupted)) { sigil.Corrupting = sigil.LastMonolith.Faction; - sigil.CorruptionStart = DateTime.UtcNow; + sigil.CorruptionStart = Core.Now; } else { @@ -930,21 +930,21 @@ namespace Server.Factions if (sigil.LastMonolith?.Sigil == null) { - if (sigil.LastStolen + Sigil.ReturnPeriod < DateTime.UtcNow) + if (sigil.LastStolen + Sigil.ReturnPeriod < Core.Now) { sigil.ReturnHome(); } } else { - if (sigil.IsBeingCorrupted && sigil.CorruptionStart + Sigil.CorruptionPeriod < DateTime.UtcNow) + if (sigil.IsBeingCorrupted && sigil.CorruptionStart + Sigil.CorruptionPeriod < Core.Now) { sigil.Corrupted = sigil.Corrupting; sigil.Corrupting = null; sigil.CorruptionStart = DateTime.MinValue; sigil.GraceStart = DateTime.MinValue; } - else if (sigil.IsPurifying && sigil.PurificationStart + Sigil.PurificationPeriod < DateTime.UtcNow) + else if (sigil.IsPurifying && sigil.PurificationStart + Sigil.PurificationPeriod < Core.Now) { sigil.PurificationStart = DateTime.MinValue; sigil.Corrupted = null; diff --git a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs index 320b74a37..f84925ed2 100644 --- a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs +++ b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs @@ -49,13 +49,13 @@ namespace Server.Factions return true; } - return Expiration != DateTime.MinValue && DateTime.UtcNow >= Expiration; + return Expiration != DateTime.MinValue && Core.Now >= Expiration; } } public void StartExpiration() { - Expiration = DateTime.UtcNow + ExpirationPeriod; + Expiration = Core.Now + ExpirationPeriod; } public void CheckAttach() diff --git a/Projects/UOContent/Engines/Factions/Core/FactionState.cs b/Projects/UOContent/Engines/Factions/Core/FactionState.cs index 883772ace..88d892b42 100644 --- a/Projects/UOContent/Engines/Factions/Core/FactionState.cs +++ b/Projects/UOContent/Engines/Factions/Core/FactionState.cs @@ -65,7 +65,7 @@ namespace Server.Factions if (version < 5) { - LastAtrophy = DateTime.UtcNow; + LastAtrophy = Core.Now; } if (version < 4) @@ -161,7 +161,7 @@ namespace Server.Factions { for (var i = 0; i < m_LastBroadcasts.Length; ++i) { - if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod) + if (Core.Now >= m_LastBroadcasts[i] + BroadcastPeriod) { return true; } @@ -171,7 +171,7 @@ namespace Server.Factions } } - public bool IsAtrophyReady => DateTime.UtcNow >= LastAtrophy + TimeSpan.FromHours(47.0); + public bool IsAtrophyReady => Core.Now >= LastAtrophy + TimeSpan.FromHours(47.0); public List FactionItems { get; set; } @@ -217,13 +217,13 @@ namespace Server.Factions public int CheckAtrophy() { - if (DateTime.UtcNow < LastAtrophy + TimeSpan.FromHours(47.0)) + if (Core.Now < LastAtrophy + TimeSpan.FromHours(47.0)) { return 0; } var distrib = 0; - LastAtrophy = DateTime.UtcNow; + LastAtrophy = Core.Now; var members = new List(Members); @@ -252,9 +252,9 @@ namespace Server.Factions { for (var i = 0; i < m_LastBroadcasts.Length; ++i) { - if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod) + if (Core.Now >= m_LastBroadcasts[i] + BroadcastPeriod) { - m_LastBroadcasts[i] = DateTime.UtcNow; + m_LastBroadcasts[i] = Core.Now; break; } } diff --git a/Projects/UOContent/Engines/Factions/Core/Keywords.cs b/Projects/UOContent/Engines/Factions/Core/Keywords.cs index 6f4b9d348..4af72108f 100644 --- a/Projects/UOContent/Engines/Factions/Core/Keywords.cs +++ b/Projects/UOContent/Engines/Factions/Core/Keywords.cs @@ -121,7 +121,7 @@ namespace Server.Factions break; } - var remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow; + var remaining = pl.Leaving + Faction.LeavePeriod - Core.Now; if (remaining.TotalDays >= 1) { diff --git a/Projects/UOContent/Engines/Factions/Core/SilverGivenEntry.cs b/Projects/UOContent/Engines/Factions/Core/SilverGivenEntry.cs index 2c24c5df0..9e2423bcf 100644 --- a/Projects/UOContent/Engines/Factions/Core/SilverGivenEntry.cs +++ b/Projects/UOContent/Engines/Factions/Core/SilverGivenEntry.cs @@ -9,13 +9,13 @@ namespace Server.Factions public SilverGivenEntry(Mobile givenTo) { GivenTo = givenTo; - TimeOfGift = DateTime.UtcNow; + TimeOfGift = Core.Now; } public Mobile GivenTo { get; } public DateTime TimeOfGift { get; } - public bool IsExpired => TimeOfGift + ExpirePeriod < DateTime.UtcNow; + public bool IsExpired => TimeOfGift + ExpirePeriod < Core.Now; } } diff --git a/Projects/UOContent/Engines/Factions/Core/Town.cs b/Projects/UOContent/Engines/Factions/Core/Town.cs index 6952a5bb3..c4a86e7e7 100644 --- a/Projects/UOContent/Engines/Factions/Core/Town.cs +++ b/Projects/UOContent/Engines/Factions/Core/Town.cs @@ -71,7 +71,7 @@ namespace Server.Factions set => m_State.LastTaxChange = value; } - public bool TaxChangeReady => m_State.LastTaxChange + TaxChangePeriod < DateTime.UtcNow; + public bool TaxChangeReady => m_State.LastTaxChange + TaxChangePeriod < Core.Now; public int FinanceUpkeep { @@ -236,7 +236,7 @@ namespace Server.Factions public void CheckIncome() { - if (LastIncome + IncomePeriod > DateTime.UtcNow || Owner == null) + if (LastIncome + IncomePeriod > Core.Now || Owner == null) { return; } @@ -246,7 +246,7 @@ namespace Server.Factions public void ProcessIncome() { - LastIncome = DateTime.UtcNow; + LastIncome = Core.Now; var flow = NetCashFlow; @@ -454,7 +454,7 @@ namespace Server.Factions if (m_State.Owner == null) // going from unowned to owned { - LastIncome = DateTime.UtcNow; + LastIncome = Core.Now; f.Silver += SilverCaptureBonus; } else if (f == null) // going from owned to unowned diff --git a/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs index 9e55b0b57..20cf53d93 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs @@ -28,7 +28,7 @@ namespace Server.Factions { case ElectionState.Pending: { - var toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow; + var toGo = election.LastStateTime + Election.PendingPeriod - Core.Now; var days = (int)(toGo.TotalDays + 0.5); AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending @@ -47,7 +47,7 @@ namespace Server.Factions } case ElectionState.Campaign: { - var toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow; + var toGo = election.LastStateTime + Election.CampaignPeriod - Core.Now; var days = (int)(toGo.TotalDays + 0.5); AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress. @@ -81,7 +81,7 @@ namespace Server.Factions } case ElectionState.Election: { - var toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow; + var toGo = election.LastStateTime + Election.VotingPeriod - Core.Now; var days = (int)Math.Ceiling(toGo.TotalDays); AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress. diff --git a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs index 2e060bae1..6fe8e204d 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs @@ -209,7 +209,7 @@ namespace Server.Factions if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady) { - var remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod); + var remaining = Core.Now - (m_Town.LastTaxChange + Town.TaxChangePeriod); if (remaining.TotalMinutes < 4) { @@ -243,7 +243,7 @@ namespace Server.Factions if (m_From.AccessLevel == AccessLevel.Player) { - m_Town.LastTaxChange = DateTime.UtcNow; + m_Town.LastTaxChange = Core.Now; } } diff --git a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs index 97fdccba3..f13ffa4b8 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs @@ -56,7 +56,7 @@ namespace Server.Factions if (pl != null) { - pl.Leaving = DateTime.UtcNow; + pl.Leaving = Core.Now; if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) { @@ -87,7 +87,7 @@ namespace Server.Factions if (pl != null) { - pl.Leaving = DateTime.UtcNow; + pl.Leaving = Core.Now; if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) { diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs index a5e0800a0..20e20e3fd 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs @@ -72,7 +72,7 @@ namespace Server try { using var op = new StreamWriter("faction-power-items.log", true); - op.WriteLine("{0}\t{1}\t{2}\t{3}", DateTime.UtcNow, killer, victim, obj); + op.WriteLine("{0}\t{1}\t{2}\t{3}", Core.Now, killer, victim, obj); } catch { diff --git a/Projects/UOContent/Engines/Factions/Items/Sigil.cs b/Projects/UOContent/Engines/Factions/Items/Sigil.cs index 648848178..66606eef3 100644 --- a/Projects/UOContent/Engines/Factions/Items/Sigil.cs +++ b/Projects/UOContent/Engines/Factions/Items/Sigil.cs @@ -101,25 +101,10 @@ namespace Server.Factions public bool IsCorrupting => m_Corrupting != null && m_Corrupting != m_Corrupted; [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan TimeUntilCorruption - { - get - { - if (!IsBeingCorrupted) - { - return TimeSpan.Zero; - } - - var ts = CorruptionStart + CorruptionPeriod - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - return ts; - } - } + public TimeSpan TimeUntilCorruption => + !IsBeingCorrupted ? + TimeSpan.Zero : + Utility.Max(CorruptionStart + CorruptionPeriod - Core.Now, TimeSpan.Zero); public static List Sigils { get; } = new(); @@ -263,7 +248,7 @@ namespace Server.Factions private void BeginCorrupting(Faction faction) { m_Corrupting = faction; - CorruptionStart = DateTime.UtcNow; + CorruptionStart = Core.Now; } private void ClearCorrupting() @@ -340,7 +325,7 @@ namespace Server.Factions BeginCorrupting(newController); } } - else if (GraceStart > DateTime.MinValue && GraceStart + CorruptionGrace < DateTime.UtcNow) + else if (GraceStart > DateTime.MinValue && GraceStart + CorruptionGrace < Core.Now) { if (m_Corrupted != newController) { @@ -359,7 +344,7 @@ namespace Server.Factions } else if (GraceStart == DateTime.MinValue) { - GraceStart = DateTime.UtcNow; + GraceStart = Core.Now; } PurificationStart = DateTime.MinValue; @@ -381,7 +366,7 @@ namespace Server.Factions tm.Sigil = this; m_Corrupting = null; - PurificationStart = DateTime.UtcNow; + PurificationStart = Core.Now; CorruptionStart = DateTime.MinValue; m_Town.Capture(m_Corrupted); diff --git a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs index 932216d7f..7a2cf78d4 100644 --- a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs +++ b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs @@ -22,7 +22,7 @@ namespace Server.Factions Visible = false; Faction = f; - TimeOfPlacement = DateTime.UtcNow; + TimeOfPlacement = Core.Now; Placer = m; } @@ -204,7 +204,7 @@ namespace Server.Factions return false; } - if (TimeOfPlacement + decayPeriod < DateTime.UtcNow) + if (TimeOfPlacement + decayPeriod < Core.Now) { Timer.DelayCall(Delete); return true; diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs index c7a46716d..6344a7f95 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs @@ -225,17 +225,17 @@ namespace Server.Factions else if (Town.FromRegion(Region) == m_Town) { Say(1042180); // Your orders, sire? - m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + m_OrdersEnd = Core.Now + TimeSpan.FromSeconds(10.0); } } - else if (DateTime.UtcNow < m_OrdersEnd) + else if (Core.Now < m_OrdersEnd) { if (m_Town?.IsSheriff(from) != true || Town.FromRegion(Region) != m_Town) { return; } - m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + m_OrdersEnd = Core.Now + TimeSpan.FromSeconds(10.0); var understood = true; ReactionType newType = 0; diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs index 9826345ef..1b437d591 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -90,7 +90,7 @@ namespace Server.Factions if (entry.Chance > Utility.Random(100)) { - releaseTime = DateTime.UtcNow + entry.Hold; + releaseTime = Core.Now + entry.Hold; return entry.Spell.CreateInstance(mob, null); } } @@ -133,7 +133,7 @@ namespace Server.Factions return TimeSpan.MaxValue; } - var ts = m_BandageStart + m_Bandage.Timer.Delay - DateTime.UtcNow; + var ts = m_BandageStart + m_Bandage.Timer.Delay - Core.Now; if (ts < TimeSpan.FromSeconds(-1.0)) { @@ -141,12 +141,7 @@ namespace Server.Factions return TimeSpan.MaxValue; } - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - return ts; + return Utility.Max(ts, TimeSpan.Zero); } } @@ -187,7 +182,7 @@ namespace Server.Factions } m_Bandage = BandageContext.BeginHeal(m_Guard, m_Guard); - m_BandageStart = DateTime.UtcNow; + m_BandageStart = Core.Now; return m_Bandage != null; } @@ -487,10 +482,10 @@ namespace Server.Factions if (m_Guard.Target != null && m_ReleaseTarget == DateTime.MinValue) { - m_ReleaseTarget = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + m_ReleaseTarget = Core.Now + TimeSpan.FromSeconds(10.0); } - if (m_Guard.Target != null && DateTime.UtcNow > m_ReleaseTarget) + if (m_Guard.Target != null && Core.Now > m_ReleaseTarget) { var targ = m_Guard.Target; diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs index 8b9f517d8..32957abc7 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs @@ -51,7 +51,7 @@ namespace Server.Engines.Harvest public void CheckRespawn() { - if (m_Current == m_Maximum || m_NextRespawn > DateTime.UtcNow) + if (m_Current == m_Maximum || m_NextRespawn > Core.Now) { return; } @@ -84,7 +84,7 @@ namespace Server.Engines.Harvest minutes *= .75; // 25% off the time. } - m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes); + m_NextRespawn = Core.Now + TimeSpan.FromMinutes(minutes); } else { diff --git a/Projects/UOContent/Engines/Help/HelpGump.cs b/Projects/UOContent/Engines/Help/HelpGump.cs index d5b783117..de622407e 100644 --- a/Projects/UOContent/Engines/Help/HelpGump.cs +++ b/Projects/UOContent/Engines/Help/HelpGump.cs @@ -324,7 +324,7 @@ namespace Server.Engines.Help { var info = m.Aggressed[i]; - if (DateTime.UtcNow - info.LastCombatTime < TimeSpan.FromSeconds(30.0)) + if (Core.Now - info.LastCombatTime < TimeSpan.FromSeconds(30.0)) { return true; } diff --git a/Projects/UOContent/Engines/Help/PageQueue.cs b/Projects/UOContent/Engines/Help/PageQueue.cs index de72530a2..176337323 100644 --- a/Projects/UOContent/Engines/Help/PageQueue.cs +++ b/Projects/UOContent/Engines/Help/PageQueue.cs @@ -33,7 +33,7 @@ namespace Server.Engines.Help public PageEntry(Mobile sender, string message, PageType type) { Sender = sender; - Sent = DateTime.UtcNow; + Sent = Core.Now; Message = Utility.FixHtml(message); Type = type; PageLocation = sender.Location; diff --git a/Projects/UOContent/Engines/Help/SpeechLog.cs b/Projects/UOContent/Engines/Help/SpeechLog.cs index 9e79020ee..15b3f7848 100644 --- a/Projects/UOContent/Engines/Help/SpeechLog.cs +++ b/Projects/UOContent/Engines/Help/SpeechLog.cs @@ -66,7 +66,7 @@ namespace Server.Engines.Help { var entry = m_Queue.Peek(); - if (DateTime.UtcNow - entry.Created > EntryDuration) + if (Core.Now - entry.Created > EntryDuration) { m_Queue.Dequeue(); } @@ -128,7 +128,7 @@ namespace Server.Engines.Help { From = from; Speech = speech; - Created = DateTime.UtcNow; + Created = Core.Now; } public Mobile From { get; } diff --git a/Projects/UOContent/Engines/Help/StuckMenu.cs b/Projects/UOContent/Engines/Help/StuckMenu.cs index 9a95f1fc7..069605537 100644 --- a/Projects/UOContent/Engines/Help/StuckMenu.cs +++ b/Projects/UOContent/Engines/Help/StuckMenu.cs @@ -241,12 +241,12 @@ namespace Server.Menus.Questions public CloseTimer(Mobile m) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { m_Mobile = m; - m_End = DateTime.UtcNow + TimeSpan.FromMinutes(3.0); + m_End = Core.Now + TimeSpan.FromMinutes(3.0); } protected override void OnTick() { - if (m_Mobile.NetState == null || DateTime.UtcNow > m_End) + if (m_Mobile.NetState == null || Core.Now > m_End) { m_Mobile.Frozen = false; m_Mobile.CloseGump(); @@ -275,12 +275,12 @@ namespace Server.Menus.Questions m_Mobile = mobile; m_Destination = destination; - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; } protected override void OnTick() { - if (DateTime.UtcNow < m_End) + if (Core.Now < m_End) { m_Mobile.Frozen = true; } diff --git a/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs b/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs index 06d859842..216706930 100644 --- a/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs +++ b/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs @@ -316,7 +316,7 @@ namespace Server.Items } else { - m_Guesses[m] = new PuzzleChestSolutionAndTime(DateTime.UtcNow, solution); + m_Guesses[m] = new PuzzleChestSolutionAndTime(Core.Now, solution); m.SendGump(new StatusGump(correctCylinders, correctColors)); @@ -526,7 +526,7 @@ namespace Server.Items foreach (var kvp in m_Guesses) { - if (DateTime.UtcNow - kvp.Value.When > CleanupTime) + if (Core.Now - kvp.Value.When > CleanupTime) { toDelete.Add(kvp.Key); } diff --git a/Projects/UOContent/Engines/Khaldun/RaisableItem.cs b/Projects/UOContent/Engines/Khaldun/RaisableItem.cs index 1ca63b457..33e1635ff 100644 --- a/Projects/UOContent/Engines/Khaldun/RaisableItem.cs +++ b/Projects/UOContent/Engines/Khaldun/RaisableItem.cs @@ -121,7 +121,7 @@ namespace Server.Items public RaiseTimer(RaisableItem item) : base(TimeSpan.Zero, TimeSpan.FromSeconds(0.5)) { m_Item = item; - m_CloseTime = DateTime.UtcNow + item.CloseDelay; + m_CloseTime = Core.Now + item.CloseDelay; m_Up = true; Priority = TimerPriority.TenMS; @@ -153,7 +153,7 @@ namespace Server.Items m_Up = false; m_Step = 0; - var delay = m_CloseTime - DateTime.UtcNow; + var delay = m_CloseTime - Core.Now; DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, Start); return; diff --git a/Projects/UOContent/Engines/ML Quests/MLQuest.cs b/Projects/UOContent/Engines/ML Quests/MLQuest.cs index 52b1d171a..159a5c18c 100644 --- a/Projects/UOContent/Engines/ML Quests/MLQuest.cs +++ b/Projects/UOContent/Engines/ML Quests/MLQuest.cs @@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests return false; } - if (nextAvailable > DateTime.UtcNow) + if (nextAvailable > Core.Now) { if (message) { diff --git a/Projects/UOContent/Engines/ML Quests/MLQuestEntry.cs b/Projects/UOContent/Engines/ML Quests/MLQuestEntry.cs index fef958cf8..87e50b87e 100644 --- a/Projects/UOContent/Engines/ML Quests/MLQuestEntry.cs +++ b/Projects/UOContent/Engines/ML Quests/MLQuestEntry.cs @@ -30,7 +30,7 @@ namespace Server.Engines.MLQuests QuesterType = quester?.GetType(); Player = player; - Accepted = DateTime.UtcNow; + Accepted = Core.Now; m_Flags = MLQuestInstanceFlags.None; Objectives = new BaseObjectiveInstance[quest.Objectives.Count]; @@ -204,7 +204,7 @@ namespace Server.Engines.MLQuests { if (!obj.Expired) { - if (obj.IsTimed && obj.EndTime <= DateTime.UtcNow) + if (obj.IsTimed && obj.EndTime <= Core.Now) { Player.SendLocalizedMessage(1072258); // You failed to complete an objective in time! @@ -335,7 +335,7 @@ namespace Server.Engines.MLQuests if (Quest.HasRestartDelay) { - PlayerContext.SetDoneQuest(Quest, DateTime.UtcNow + Quest.GetRestartDelay()); + PlayerContext.SetDoneQuest(Quest, Core.Now + Quest.GetRestartDelay()); } // This is correct for ObjectiveType.Any as well diff --git a/Projects/UOContent/Engines/ML Quests/Mobiles/SirHelper.cs b/Projects/UOContent/Engines/ML Quests/Mobiles/SirHelper.cs index f846e95e8..53243193c 100644 --- a/Projects/UOContent/Engines/ML Quests/Mobiles/SirHelper.cs +++ b/Projects/UOContent/Engines/ML Quests/Mobiles/SirHelper.cs @@ -90,7 +90,7 @@ namespace Server.Engines.MLQuests.Mobiles { base.OnThink(); - if (m_NextShout > DateTime.UtcNow) + if (m_NextShout > Core.Now) { return; } @@ -117,7 +117,7 @@ namespace Server.Engines.MLQuests.Mobiles } } - m_NextShout = DateTime.UtcNow + m_ShoutDelay; + m_NextShout = Core.Now + m_ShoutDelay; } private void EndLock(Mobile m) diff --git a/Projects/UOContent/Engines/ML Quests/Objectives/BaseObjective.cs b/Projects/UOContent/Engines/ML Quests/Objectives/BaseObjective.cs index 89d841c69..4bf7d05f6 100644 --- a/Projects/UOContent/Engines/ML Quests/Objectives/BaseObjective.cs +++ b/Projects/UOContent/Engines/ML Quests/Objectives/BaseObjective.cs @@ -32,7 +32,7 @@ namespace Server.Engines.MLQuests.Objectives if (obj.IsTimed) { - EndTime = DateTime.UtcNow + obj.Duration; + EndTime = Core.Now + obj.Duration; } } @@ -50,7 +50,7 @@ namespace Server.Engines.MLQuests.Objectives { if (IsTimed) { - WriteTimeRemaining(g, ref y, EndTime > DateTime.UtcNow ? EndTime - DateTime.UtcNow : TimeSpan.Zero); + WriteTimeRemaining(g, ref y, Utility.Max(EndTime - Core.Now, TimeSpan.Zero)); } } diff --git a/Projects/UOContent/Engines/ML Quests/Objectives/EscortObjective.cs b/Projects/UOContent/Engines/ML Quests/Objectives/EscortObjective.cs index f5b793b7e..f1a0f9aa9 100644 --- a/Projects/UOContent/Engines/ML Quests/Objectives/EscortObjective.cs +++ b/Projects/UOContent/Engines/ML Quests/Objectives/EscortObjective.cs @@ -39,11 +39,11 @@ namespace Server.Engines.MLQuests.Objectives var nextEscort = pm.LastEscortTime + BaseEscortable.EscortDelay; - if (nextEscort > DateTime.UtcNow) + if (nextEscort > Core.Now) { if (message) { - var minutes = (int)Math.Ceiling((nextEscort - DateTime.UtcNow).TotalMinutes); + var minutes = (int)Math.Ceiling((nextEscort - Core.Now).TotalMinutes); if (minutes == 1) { @@ -106,7 +106,7 @@ namespace Server.Engines.MLQuests.Objectives m_Objective = objective; HasCompleted = false; m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), CheckDestination); - m_LastSeenEscorter = DateTime.UtcNow; + m_LastSeenEscorter = Core.Now; m_Escort = instance.Quester as BaseCreature; if (MLQuestSystem.Debug && m_Escort == null && instance.Quester != null) @@ -170,14 +170,14 @@ namespace Server.Engines.MLQuests.Objectives } else if (pm.Map != m_Escort.Map || !pm.InRange(m_Escort, 30)) // TODO: verify range { - if (m_LastSeenEscorter + BaseEscortable.AbandonDelay <= DateTime.UtcNow) + if (m_LastSeenEscorter + BaseEscortable.AbandonDelay <= Core.Now) { Abandon(); } } else { - m_LastSeenEscorter = DateTime.UtcNow; + m_LastSeenEscorter = Core.Now; } } @@ -225,7 +225,7 @@ namespace Server.Engines.MLQuests.Objectives var instance = Instance; var pm = instance.Player; - pm.LastEscortTime = DateTime.UtcNow; + pm.LastEscortTime = Core.Now; if (m_Escort != null) { diff --git a/Projects/UOContent/Engines/ML Quests/Objectives/GainSkillObjective.cs b/Projects/UOContent/Engines/ML Quests/Objectives/GainSkillObjective.cs index e6fc4333c..2df32b053 100644 --- a/Projects/UOContent/Engines/ML Quests/Objectives/GainSkillObjective.cs +++ b/Projects/UOContent/Engines/ML Quests/Objectives/GainSkillObjective.cs @@ -133,7 +133,7 @@ namespace Server.Engines.MLQuests.Objectives var pm = Instance.Player; pm.AcceleratedSkill = Objective.Skill; - pm.AcceleratedStart = DateTime.UtcNow + TimeSpan.FromMinutes(15); // TODO: Is there a max duration? + pm.AcceleratedStart = Core.Now + TimeSpan.FromMinutes(15); // TODO: Is there a max duration? } public override void OnQuestCancelled() @@ -145,7 +145,7 @@ namespace Server.Engines.MLQuests.Objectives var pm = Instance.Player; - pm.AcceleratedStart = DateTime.UtcNow; + pm.AcceleratedStart = Core.Now; pm.PlaySound(0x100); } diff --git a/Projects/UOContent/Engines/Pathing/PathFollower.cs b/Projects/UOContent/Engines/Pathing/PathFollower.cs index d3adfb9df..ecacdfd71 100644 --- a/Projects/UOContent/Engines/Pathing/PathFollower.cs +++ b/Projects/UOContent/Engines/Pathing/PathFollower.cs @@ -66,13 +66,13 @@ namespace Server var goal = GetGoalLocation(); - if (m_Path != null && (m_Path.Success && goal == m_LastGoalLoc || m_LastPathTime + RepathDelay > DateTime.Now) && + if (m_Path != null && (m_Path.Success && goal == m_LastGoalLoc || m_LastPathTime + RepathDelay > Core.Now) && !(m_Path.Success && Check(m_From.Location, m_LastGoalLoc, 0))) { return false; } - m_LastPathTime = DateTime.UtcNow; + m_LastPathTime = Core.Now; m_LastGoalLoc = goal; m_Path = new MovementPath(m_From, goal); diff --git a/Projects/UOContent/Engines/Plants/PlantSystem.cs b/Projects/UOContent/Engines/Plants/PlantSystem.cs index 041ab6ac3..abecd633c 100644 --- a/Projects/UOContent/Engines/Plants/PlantSystem.cs +++ b/Projects/UOContent/Engines/Plants/PlantSystem.cs @@ -50,7 +50,7 @@ namespace Server.Engines.Plants Plant = plant; FertileDirt = fertileDirt; - NextGrowth = DateTime.UtcNow + CheckDelay; + NextGrowth = Core.Now + CheckDelay; GrowthIndicator = PlantGrowthIndicator.None; m_Hits = MaxHits; m_LeftSeeds = 8; @@ -290,7 +290,7 @@ namespace Server.Engines.Plants public void Reset(bool potions) { - NextGrowth = DateTime.UtcNow + CheckDelay; + NextGrowth = Core.Now + CheckDelay; GrowthIndicator = PlantGrowthIndicator.None; Hits = MaxHits; @@ -387,7 +387,7 @@ namespace Server.Engines.Plants public static void GrowAll() { var plants = PlantItem.Plants; - var now = DateTime.UtcNow; + var now = Core.Now; for (var i = plants.Count - 1; i >= 0; --i) { @@ -417,13 +417,15 @@ namespace Server.Engines.Plants return; } - if (DateTime.UtcNow < NextGrowth) + var now = Core.Now; + + if (now < NextGrowth) { GrowthIndicator = PlantGrowthIndicator.Delay; return; } - NextGrowth = DateTime.UtcNow + CheckDelay; + NextGrowth = now + CheckDelay; if (!Plant.ValidGrowthLocation) { diff --git a/Projects/UOContent/Engines/Quests/Collector/Objectives.cs b/Projects/UOContent/Engines/Quests/Collector/Objectives.cs index 53a98726e..1fa41bfe9 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Objectives.cs @@ -70,9 +70,9 @@ namespace Server.Engines.Quests.Collector { if (m_Begin == DateTime.MaxValue) { - m_Begin = DateTime.UtcNow; + m_Begin = Core.Now; } - else if (DateTime.UtcNow - m_Begin > TimeSpan.FromSeconds(30.0)) + else if (Core.Now - m_Begin > TimeSpan.FromSeconds(30.0)) { Complete(); } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs b/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs index 2cef83a8b..ab2a7bd8a 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs @@ -24,7 +24,7 @@ namespace Server.Engines.Quests { if (restartDelay < TimeSpan.MaxValue) { - RestartTime = DateTime.UtcNow + restartDelay; + RestartTime = Core.Now + restartDelay; } else { diff --git a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs index 09b6f7792..d3c6e7d0e 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs @@ -473,7 +473,7 @@ namespace Server.Engines.Quests { var endTime = restartInfo.RestartTime; - if (DateTime.UtcNow < endTime) + if (Core.Now < endTime) { inRestartPeriod = true; return false; diff --git a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs index 8af09f20b..2fb58578b 100644 --- a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs @@ -30,7 +30,7 @@ namespace Server.Engines.Quests.Naturalist { if (m_StudyState != StudyState.Inactive) { - var time = DateTime.UtcNow - m_StudyBegin; + var time = Core.Now - m_StudyBegin; if (time > TimeSpan.FromSeconds(30.0)) { @@ -84,7 +84,7 @@ namespace Server.Engines.Quests.Naturalist if (nest != null) { m_CurrentNest = nest; - m_StudyBegin = DateTime.UtcNow; + m_StudyBegin = Core.Now; if (m_StudiedNests.Contains(nest)) { diff --git a/Projects/UOContent/Engines/Spawners/BaseSpawner.cs b/Projects/UOContent/Engines/Spawners/BaseSpawner.cs index bce623678..37801d92c 100644 --- a/Projects/UOContent/Engines/Spawners/BaseSpawner.cs +++ b/Projects/UOContent/Engines/Spawners/BaseSpawner.cs @@ -186,7 +186,7 @@ namespace Server.Engines.Spawners [CommandProperty(AccessLevel.Developer)] public TimeSpan NextSpawn { - get => m_Running && m_Timer?.Running == true ? End - DateTime.UtcNow : TimeSpan.FromSeconds(0); + get => m_Running && m_Timer?.Running == true ? End - Core.Now : TimeSpan.FromSeconds(0); set { Start(); @@ -748,7 +748,7 @@ namespace Server.Engines.Spawners return; } - End = DateTime.UtcNow + delay; + End = Core.Now + delay; if (m_Timer == null) { @@ -1005,7 +1005,7 @@ namespace Server.Engines.Spawners if (m_Running) { - ts = reader.ReadDeltaTime() - DateTime.UtcNow; + ts = reader.ReadDeltaTime() - Core.Now; } if (version < 7) diff --git a/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs b/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs index 8701cedc6..01059310c 100644 --- a/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs +++ b/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs @@ -93,14 +93,14 @@ namespace Server.Engines.Spawners return; } - End = DateTime.UtcNow + delay; + End = Core.Now + delay; } public override void Respawn() { RemoveSpawns(); - End = DateTime.UtcNow; + End = Core.Now; } public virtual bool ValidTrigger(Mobile m) @@ -120,7 +120,7 @@ namespace Server.Engines.Spawners return; } - if (IsEmpty && End <= DateTime.UtcNow && m.InRange(GetWorldLocation(), TriggerRange) && + if (IsEmpty && End <= Core.Now && m.InRange(GetWorldLocation(), TriggerRange) && m.Location != oldLocation && ValidTrigger(m)) { TextDefinition.SendMessageTo(m, SpawnMessage); diff --git a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs index 056cfd7cb..d07e5d05e 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs @@ -254,7 +254,7 @@ namespace Server.Mobiles public void Sculpt(Mobile by) { m_SculptedBy = by; - SculptedOn = DateTime.UtcNow; + SculptedOn = Core.Now; InvalidateProperties(); } @@ -516,7 +516,7 @@ namespace Server.Mobiles if (from.Account is Account acct && from.AccessLevel == AccessLevel.Player) { var time = TimeSpan.FromDays(RewardSystem.RewardInterval.TotalDays * 6) - - (DateTime.UtcNow - acct.Created); + (Core.Now - acct.Created); if (time > TimeSpan.Zero) { diff --git a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs index 85dd84ea1..869b1b3fc 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs @@ -83,16 +83,9 @@ namespace Server.Engines.VeteranRewards return false; } - var totalTime = DateTime.UtcNow - acct.Created; + ts = list.Age - (Core.Now - acct.Created); - ts = list.Age - totalTime; - - if (ts <= TimeSpan.Zero) - { - return true; - } - - return false; + return ts <= TimeSpan.Zero; } public static int GetRewardLevel(Mobile mob) @@ -107,7 +100,7 @@ namespace Server.Engines.VeteranRewards public static int GetRewardLevel(Account acct) { - var totalTime = DateTime.UtcNow - acct.Created; + var totalTime = Core.Now - acct.Created; return Math.Max((int)(totalTime.TotalDays / RewardInterval.TotalDays), 0); } @@ -124,7 +117,7 @@ namespace Server.Engines.VeteranRewards public static bool HasHalfLevel(Account acct) { - var totalTime = DateTime.UtcNow - acct.Created; + var totalTime = Core.Now - acct.Created; var level = totalTime.TotalDays / RewardInterval.TotalDays; diff --git a/Projects/UOContent/Engines/Virtues/Compassion.cs b/Projects/UOContent/Engines/Virtues/Compassion.cs index e7c81075b..e16089cf6 100644 --- a/Projects/UOContent/Engines/Virtues/Compassion.cs +++ b/Projects/UOContent/Engines/Virtues/Compassion.cs @@ -27,11 +27,11 @@ namespace Server try { - if (pm.LastCompassionLoss + LossDelay < DateTime.UtcNow) + if (pm.LastCompassionLoss + LossDelay < Core.Now) { VirtueHelper.Atrophy(from, VirtueName.Compassion, LossAmount); // OSI has no cliloc message for losing compassion. Weird. - pm.LastCompassionLoss = DateTime.UtcNow; + pm.LastCompassionLoss = Core.Now; } } catch diff --git a/Projects/UOContent/Engines/Virtues/Honor.cs b/Projects/UOContent/Engines/Virtues/Honor.cs index 69cf6c7a3..4518142ea 100644 --- a/Projects/UOContent/Engines/Virtues/Honor.cs +++ b/Projects/UOContent/Engines/Virtues/Honor.cs @@ -49,7 +49,7 @@ namespace Server return; } - var waitTime = DateTime.UtcNow - pm.LastHonorUse; + var waitTime = Core.Now - pm.LastHonorUse; if (waitTime < UseDelay) { var remainingTime = UseDelay - waitTime; @@ -93,7 +93,7 @@ namespace Server () => { pm.HonorActive = false; - pm.LastHonorUse = DateTime.UtcNow; + pm.LastHonorUse = Core.Now; pm.SendLocalizedMessage(1063236); // You no longer embrace your honor } ); @@ -225,13 +225,13 @@ namespace Server m_Timer = new InternalTimer(this); m_Timer.Start(); - source.m_hontime = DateTime.UtcNow + TimeSpan.FromMinutes(40); + source.m_hontime = Core.Now + TimeSpan.FromMinutes(40); Timer.DelayCall( TimeSpan.FromMinutes(40), () => { - if (source.m_hontime < DateTime.UtcNow && source.SentHonorContext != null) + if (source.m_hontime < Core.Now && source.SentHonorContext != null) { Cancel(); } diff --git a/Projects/UOContent/Engines/Virtues/Justice.cs b/Projects/UOContent/Engines/Virtues/Justice.cs index d127b6fa6..ab321802d 100644 --- a/Projects/UOContent/Engines/Virtues/Justice.cs +++ b/Projects/UOContent/Engines/Virtues/Justice.cs @@ -199,14 +199,14 @@ namespace Server try { - if (pm.LastJusticeLoss + LossDelay < DateTime.UtcNow) + if (pm.LastJusticeLoss + LossDelay < Core.Now) { if (VirtueHelper.Atrophy(from, VirtueName.Justice, LossAmount)) { from.SendLocalizedMessage(1049373); // You have lost some Justice. } - pm.LastJusticeLoss = DateTime.UtcNow; + pm.LastJusticeLoss = Core.Now; } } catch diff --git a/Projects/UOContent/Engines/Virtues/Sacrifice.cs b/Projects/UOContent/Engines/Virtues/Sacrifice.cs index 8a33e87f6..4f1255047 100644 --- a/Projects/UOContent/Engines/Virtues/Sacrifice.cs +++ b/Projects/UOContent/Engines/Virtues/Sacrifice.cs @@ -45,7 +45,7 @@ namespace Server try { - if (pm.LastSacrificeLoss + LossDelay < DateTime.UtcNow) + if (pm.LastSacrificeLoss + LossDelay < Core.Now) { if (VirtueHelper.Atrophy(from, VirtueName.Sacrifice, LossAmount)) { @@ -55,7 +55,7 @@ namespace Server var level = VirtueHelper.GetLevel(from, VirtueName.Sacrifice); pm.AvailableResurrects = (int)level; - pm.LastSacrificeLoss = DateTime.UtcNow; + pm.LastSacrificeLoss = Core.Now; } } catch @@ -136,7 +136,7 @@ namespace Server { from.SendLocalizedMessage(1052017); // You do not have enough fame to sacrifice. } - else if (DateTime.UtcNow < pm.LastSacrificeGain + GainDelay) + else if (Core.Now < pm.LastSacrificeGain + GainDelay) { from.SendLocalizedMessage(1052016); // You must wait approximately one day before sacrificing again. } @@ -166,7 +166,7 @@ namespace Server Timer.DelayCall(TimeSpan.FromSeconds(1.0), targ.Delete); - pm.LastSacrificeGain = DateTime.UtcNow; + pm.LastSacrificeGain = Core.Now; var gainedPath = false; diff --git a/Projects/UOContent/Engines/Virtues/Valor.cs b/Projects/UOContent/Engines/Virtues/Valor.cs index e14cc3329..beb3d9391 100644 --- a/Projects/UOContent/Engines/Virtues/Valor.cs +++ b/Projects/UOContent/Engines/Virtues/Valor.cs @@ -33,14 +33,14 @@ namespace Server try { - if (pm.LastValorLoss + LossDelay < DateTime.UtcNow) + if (pm.LastValorLoss + LossDelay < Core.Now) { if (VirtueHelper.Atrophy(from, VirtueName.Valor, LossAmount)) { from.SendLocalizedMessage(1054040); // You have lost some Valor. } - pm.LastValorLoss = DateTime.UtcNow; + pm.LastValorLoss = Core.Now; } } catch diff --git a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs index 7e66255be..5b4948056 100644 --- a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs +++ b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs @@ -112,7 +112,7 @@ namespace Server { if (virtue == VirtueName.Compassion) { - if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay) + if (pm.CompassionGains > 0 && Core.Now > pm.NextCompassionDay) { pm.NextCompassionDay = DateTime.MinValue; pm.CompassionGains = 0; @@ -142,7 +142,7 @@ namespace Server if (virtue == VirtueName.Compassion) { - pm.NextCompassionDay = DateTime.UtcNow + TimeSpan.FromDays(1.0); + pm.NextCompassionDay = Core.Now + TimeSpan.FromDays(1.0); ++pm.CompassionGains; if (pm.CompassionGains >= 5) diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 8e713a456..7e899b6f1 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -185,7 +185,7 @@ namespace Server.Gumps AddLabel(150, 270, LabelHue, Core.ScriptItems.ToString()); AddLabel(20, 290, LabelHue, "Uptime:"); - AddLabel(150, 290, LabelHue, FormatTimeSpan(DateTime.UtcNow - Clock.ServerStart)); + AddLabel(150, 290, LabelHue, FormatTimeSpan(Core.Now - Clock.ServerStart)); AddLabel(20, 310, LabelHue, "Memory:"); AddLabel(150, 310, LabelHue, FormatByteAmount(GC.GetTotalMemory(false))); @@ -902,17 +902,7 @@ namespace Server.Gumps } else { - var remaining = DateTime.UtcNow - banTime; - - if (remaining < TimeSpan.Zero) - { - remaining = TimeSpan.Zero; - } - else if (remaining > banDuration) - { - remaining = banDuration; - } - + var remaining = (Core.Now - banTime).Clamp(TimeSpan.Zero, banDuration); var remMinutes = remaining.TotalMinutes; var totMinutes = banDuration.TotalMinutes; diff --git a/Projects/UOContent/Gumps/BanDurationGump.cs b/Projects/UOContent/Gumps/BanDurationGump.cs index edec1f4c2..ef246edaa 100644 --- a/Projects/UOContent/Gumps/BanDurationGump.cs +++ b/Projects/UOContent/Gumps/BanDurationGump.cs @@ -229,7 +229,7 @@ namespace Server.Gumps { var a = m_List[i]; - a.SetBanTags(from, DateTime.UtcNow, duration); + a.SetBanTags(from, Core.Now, duration); if (comment != null) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs index 44acc68c6..edd1b4569 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs @@ -65,7 +65,7 @@ namespace Server.Gumps { m_Mobile.SendLocalizedMessage(1010405); // You cannot change guild types while in a Faction! } - else if (m_Guild.TypeLastChange.AddDays(7) > DateTime.UtcNow) + else if (m_Guild.TypeLastChange.AddDays(7) > Core.Now) { m_Mobile.SendLocalizedMessage(1011142); // You have already changed your guild type recently. // TODO: Clilocs 1011142-1011145 suggest a timer for pending changes diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index 41be14838..9e5dca714 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -70,9 +70,9 @@ namespace Server.Guilds var timeRemaining = TimeSpan.Zero; - if (activeWar.WarLength != TimeSpan.Zero && activeWar.WarBeginning + activeWar.WarLength > DateTime.UtcNow) + if (activeWar.WarLength != TimeSpan.Zero && activeWar.WarBeginning + activeWar.WarLength > Core.Now) { - timeRemaining = activeWar.WarBeginning + activeWar.WarLength - DateTime.UtcNow; + timeRemaining = activeWar.WarBeginning + activeWar.WarLength - Core.Now; } time = $"{timeRemaining.Hours:D2}:{DateTime.MinValue + timeRemaining:mm}"; @@ -234,7 +234,7 @@ namespace Server.Guilds { // Accept the war guild.PendingWars.Remove(war); - war.WarBeginning = DateTime.UtcNow; + war.WarBeginning = Core.Now; guild.AcceptedWars.Add(war); if (alliance?.IsMember(guild) == true) @@ -260,7 +260,7 @@ namespace Server.Guilds // Technically SHOULD say Your guild is now at war w/out any info, intentional diff. otherGuild.PendingWars.Remove(otherWar); - otherWar.WarBeginning = DateTime.UtcNow; + otherWar.WarBeginning = Core.Now; otherGuild.AcceptedWars.Add(otherWar); if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other)) diff --git a/Projects/UOContent/Gumps/HouseGumpAOS.cs b/Projects/UOContent/Gumps/HouseGumpAOS.cs index 8fcbca778..e1308d94b 100644 --- a/Projects/UOContent/Gumps/HouseGumpAOS.cs +++ b/Projects/UOContent/Gumps/HouseGumpAOS.cs @@ -1510,7 +1510,7 @@ namespace Server.Gumps ); // You cannot redeed a house with a guildstone inside. } else if (Core.ML && from.AccessLevel < AccessLevel.GameMaster && - DateTime.UtcNow <= m_House.BuiltOn.AddHours(1)) + Core.Now <= m_House.BuiltOn.AddHours(1)) { from.SendLocalizedMessage( 1080178 diff --git a/Projects/UOContent/Gumps/ReportMurderer.cs b/Projects/UOContent/Gumps/ReportMurderer.cs index 7ad6cd800..a17709e91 100644 --- a/Projects/UOContent/Gumps/ReportMurderer.cs +++ b/Projects/UOContent/Gumps/ReportMurderer.cs @@ -43,7 +43,7 @@ namespace Server.Gumps } } - if (ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && + if (ai.Attacker.Player && Core.Now - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker)) { toGive.Add(ai.Attacker); @@ -52,7 +52,7 @@ namespace Server.Gumps foreach (var ai in m.Aggressed) { - if (ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && + if (ai.Defender.Player && Core.Now - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender)) { toGive.Add(ai.Defender); diff --git a/Projects/UOContent/Gumps/VendorInventoryGump.cs b/Projects/UOContent/Gumps/VendorInventoryGump.cs index f6944a4c0..f68ad16ba 100644 --- a/Projects/UOContent/Gumps/VendorInventoryGump.cs +++ b/Projects/UOContent/Gumps/VendorInventoryGump.cs @@ -38,7 +38,7 @@ namespace Server.Gumps AddLabel(45, y, 0x481, $"{inventory.ShopName} ({inventory.VendorName})"); - var expire = inventory.ExpireTime - DateTime.UtcNow; + var expire = inventory.ExpireTime - Core.Now; var hours = (int)expire.TotalHours; AddLabel(320, y, 0x481, hours.ToString()); diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index 99a5b3173..fb4123331 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -13,9 +13,9 @@ namespace Server.Engines.Events public static void Initialize() { - var now = DateTime.UtcNow; + var now = Core.Now; - if (DateTime.UtcNow >= HolidaySettings.StartHalloween && DateTime.UtcNow <= HolidaySettings.FinishHalloween) + if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween) { EventSink.Speech += EventSink_Speech; } @@ -165,7 +165,7 @@ namespace Server.Engines.Events return; } - var now = DateTime.UtcNow; + var now = Core.Now; if (CheckMobile(begged)) { diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs b/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs index e02b744b0..99fc5be2b 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs @@ -23,7 +23,7 @@ namespace Server.Engines.Events public static void Initialize() { - var now = DateTime.UtcNow; + var now = Core.Now; if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween) { diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs b/Projects/UOContent/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs index 16ec75256..385312dab 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs @@ -48,7 +48,7 @@ namespace Server.Engines.Events m_QueueDelaySeconds = 120; m_QueueClearIntervalSeconds = 1800; - var today = DateTime.UtcNow; + var today = Core.Now; var tick = TimeSpan.FromSeconds(m_QueueDelaySeconds); var clear = TimeSpan.FromSeconds(m_QueueClearIntervalSeconds); @@ -80,7 +80,7 @@ namespace Server.Engines.Events m_DeathQueue.Clear(); - if (DateTime.UtcNow <= HolidaySettings.FinishHalloween) + if (Core.Now <= HolidaySettings.FinishHalloween) { m_ClearTimer.Stop(); } @@ -90,7 +90,7 @@ namespace Server.Engines.Events { PlayerMobile player = null; - if (DateTime.UtcNow <= HolidaySettings.FinishHalloween) + if (Core.Now <= HolidaySettings.FinishHalloween) { for (var index = 0; m_DeathQueue.Count > 0 && index < m_DeathQueue.Count; index++) { diff --git a/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs b/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs index 5855a78a5..0d63edd82 100644 --- a/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs +++ b/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs @@ -86,7 +86,7 @@ namespace Server.Items public bool IsSigned => m_Line1 != null || m_Line2 != null || m_Line3 != null; - public bool CanSign => !IsSigned || DateTime.UtcNow <= EditLimit; + public bool CanSign => !IsSigned || Core.Now <= EditLimit; public override void AddNameProperty(ObjectPropertyList list) { @@ -237,7 +237,7 @@ namespace Server.Items if (!m_Bear.IsSigned) { - m_Bear.EditLimit = DateTime.UtcNow + TimeSpan.FromMinutes(10); + m_Bear.EditLimit = Core.Now + TimeSpan.FromMinutes(10); } m_Bear.Line1 = Utility.FixHtml(line1); diff --git a/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs b/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs index d4f9c60de..178f0a550 100644 --- a/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs +++ b/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs @@ -57,7 +57,7 @@ namespace Server.Items public static bool CheckSeason(Mobile from) { - if (DateTime.UtcNow.Month == 2) + if (Core.Now.Month == 2) { return true; } diff --git a/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs b/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs index 3505c5c6c..6b7ed8d41 100644 --- a/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs +++ b/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs @@ -96,7 +96,7 @@ namespace Server.Items return; } - if (DateTime.UtcNow < LastUse + UseDelay) + if (Core.Now < LastUse + UseDelay) { return; } @@ -172,7 +172,7 @@ namespace Server.Items return; } - LastUse = DateTime.UtcNow; + LastUse = Core.Now; from.Direction = from.GetDirectionTo(GetWorldLocation()); bow.PlaySwingAnimation(from); diff --git a/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs b/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs index 45470a798..44fdbc2ac 100644 --- a/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs +++ b/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs @@ -90,14 +90,14 @@ namespace Server.Items if (m.Player && Utility.InRange(Location, m.Location, 3) && !Utility.InRange(Location, oldLocation, 3)) { - if (DateTime.UtcNow >= m_NextMessage) + if (Core.Now >= m_NextMessage) { if (Components.Count > 0) { Components[0].SendLocalizedMessageTo(m, 1010061); // An overwhelming sense of peace fills you. } - m_NextMessage = DateTime.UtcNow + TimeSpan.FromSeconds(25.0); + m_NextMessage = Core.Now + TimeSpan.FromSeconds(25.0); } } } diff --git a/Projects/UOContent/Items/Addons/SHTeleporter.cs b/Projects/UOContent/Items/Addons/SHTeleporter.cs index 4b9e9fa28..cbb1786c0 100644 --- a/Projects/UOContent/Items/Addons/SHTeleporter.cs +++ b/Projects/UOContent/Items/Addons/SHTeleporter.cs @@ -192,11 +192,11 @@ namespace Server.Items { World.Broadcast(0x35, true, "Solen hives teleporters are being generated, please wait."); - var startTime = DateTime.UtcNow; + var startTime = Core.Now; var count = new SHTeleporterCreator().CreateSHTeleporters(); - var endTime = DateTime.UtcNow; + var endTime = Core.Now; World.Broadcast( 0x35, diff --git a/Projects/UOContent/Items/Aquarium/Aquarium.cs b/Projects/UOContent/Items/Aquarium/Aquarium.cs index 84140fec9..4a90b68ad 100644 --- a/Projects/UOContent/Items/Aquarium/Aquarium.cs +++ b/Projects/UOContent/Items/Aquarium/Aquarium.cs @@ -535,7 +535,7 @@ namespace Server.Items } else { - writer.Write(DateTime.UtcNow + EvaluationInterval); + writer.Write(Core.Now + EvaluationInterval); } // version 0 @@ -569,12 +569,12 @@ namespace Server.Items { var next = reader.ReadDateTime(); - if (next < DateTime.UtcNow) + if (next < Core.Now) { - next = DateTime.UtcNow; + next = Core.Now; } - m_Timer = Timer.DelayCall(next - DateTime.UtcNow, EvaluationInterval, Evaluate); + m_Timer = Timer.DelayCall(next - Core.Now, EvaluationInterval, Evaluate); goto case 0; } diff --git a/Projects/UOContent/Items/Bulletin Boards/BulletinBoard.cs b/Projects/UOContent/Items/Bulletin Boards/BulletinBoard.cs index cfc0aec69..9eaa54a5a 100644 --- a/Projects/UOContent/Items/Bulletin Boards/BulletinBoard.cs +++ b/Projects/UOContent/Items/Bulletin Boards/BulletinBoard.cs @@ -24,13 +24,13 @@ namespace Server.Items } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool CheckCreateTime(DateTime time) => time + ThreadCreateTime < DateTime.UtcNow; + public static bool CheckCreateTime(DateTime time) => time + ThreadCreateTime < Core.Now; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool CheckDeletionTime(DateTime time) => time + ThreadDeletionTime < DateTime.UtcNow; + public static bool CheckDeletionTime(DateTime time) => time + ThreadDeletionTime < Core.Now; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool CheckReplyTime(DateTime time) => time + ThreadReplyTime < DateTime.UtcNow; + public static bool CheckReplyTime(DateTime time) => time + ThreadReplyTime < Core.Now; } [Flippable(0x1E5E, 0x1E5F)] @@ -180,7 +180,7 @@ namespace Server.Items { if (thread != null) { - thread.LastPostTime = DateTime.UtcNow; + thread.LastPostTime = Core.Now; } AddItem(new BulletinMessage(from, thread, subject, lines)); diff --git a/Projects/UOContent/Items/Bulletin Boards/BulletinMessage.cs b/Projects/UOContent/Items/Bulletin Boards/BulletinMessage.cs index a37a07dd8..ba44aaee4 100644 --- a/Projects/UOContent/Items/Bulletin Boards/BulletinMessage.cs +++ b/Projects/UOContent/Items/Bulletin Boards/BulletinMessage.cs @@ -12,7 +12,7 @@ namespace Server.Items Poster = poster; Subject = subject; - Time = DateTime.UtcNow; + Time = Core.Now; LastPostTime = Time; Thread = thread; PostedName = Poster.Name; diff --git a/Projects/UOContent/Items/Clothing/OuterTorso.cs b/Projects/UOContent/Items/Clothing/OuterTorso.cs index 8a9706ad8..95a021a79 100644 --- a/Projects/UOContent/Items/Clothing/OuterTorso.cs +++ b/Projects/UOContent/Items/Clothing/OuterTorso.cs @@ -113,7 +113,7 @@ namespace Server.Items { m_DecayTimer?.Stop(); - m_DecayTime = DateTime.UtcNow + delay; + m_DecayTime = Core.Now + delay; m_DecayTimer = new InternalTimer(this, delay); m_DecayTimer.Start(); @@ -171,7 +171,7 @@ namespace Server.Items if (reader.ReadBool()) { m_DecayTime = reader.ReadDeltaTime(); - BeginDecay(m_DecayTime - DateTime.UtcNow); + BeginDecay(m_DecayTime - Core.Now); } break; diff --git a/Projects/UOContent/Items/Containers/FillableContainers.cs b/Projects/UOContent/Items/Containers/FillableContainers.cs index 5b582a115..eb5d34982 100644 --- a/Projects/UOContent/Items/Containers/FillableContainers.cs +++ b/Projects/UOContent/Items/Containers/FillableContainers.cs @@ -129,7 +129,7 @@ namespace Server.Items var mins = Utility.RandomMinMax(MinRespawnMinutes, MaxRespawnMinutes); var delay = TimeSpan.FromMinutes(mins); - m_NextRespawnTime = DateTime.UtcNow + delay; + m_NextRespawnTime = Core.Now + delay; m_RespawnTimer = Timer.DelayCall(delay, Respawn); } } @@ -279,7 +279,7 @@ namespace Server.Items { m_NextRespawnTime = reader.ReadDeltaTime(); - var delay = m_NextRespawnTime - DateTime.UtcNow; + var delay = m_NextRespawnTime - Core.Now; m_RespawnTimer = Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, Respawn); } else diff --git a/Projects/UOContent/Items/Containers/MarkContainer.cs b/Projects/UOContent/Items/Containers/MarkContainer.cs index 8069d081b..153c388f6 100644 --- a/Projects/UOContent/Items/Containers/MarkContainer.cs +++ b/Projects/UOContent/Items/Containers/MarkContainer.cs @@ -212,7 +212,7 @@ namespace Server.Items if (!Locked && m_AutoLock) { - m_RelockTimer = new InternalTimer(this, reader.ReadDeltaTime() - DateTime.UtcNow); + m_RelockTimer = new InternalTimer(this, reader.ReadDeltaTime() - Core.Now); } TargetMap = reader.ReadMap(); @@ -229,7 +229,7 @@ namespace Server.Items public InternalTimer(MarkContainer container, TimeSpan delay) : base(delay) { Container = container; - RelockTime = DateTime.UtcNow + delay; + RelockTime = Core.Now + delay; Start(); } diff --git a/Projects/UOContent/Items/Containers/TreasureMapChest.cs b/Projects/UOContent/Items/Containers/TreasureMapChest.cs index ff8a668f7..ac84b2111 100644 --- a/Projects/UOContent/Items/Containers/TreasureMapChest.cs +++ b/Projects/UOContent/Items/Containers/TreasureMapChest.cs @@ -23,7 +23,7 @@ namespace Server.Items { Owner = owner; Level = level; - DeleteTime = DateTime.UtcNow + TimeSpan.FromHours(3.0); + DeleteTime = Core.Now + TimeSpan.FromHours(3.0); Temporary = temporary; Guardians = new List(); @@ -585,7 +585,7 @@ namespace Server.Items { private readonly Item m_Item; - public DeleteTimer(Item item, DateTime time) : base(time - DateTime.UtcNow) + public DeleteTimer(Item item, DateTime time) : base(time - Core.Now) { m_Item = item; Priority = TimerPriority.OneMinute; diff --git a/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs b/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs index 799099981..ad4143ca4 100644 --- a/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs +++ b/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs @@ -363,7 +363,7 @@ namespace Server.Items { private Item m_Item; - public StealableInstance(StealableEntry entry) : this(entry, null, DateTime.UtcNow) + public StealableInstance(StealableEntry entry) : this(entry, null, Core.Now) { } @@ -384,7 +384,7 @@ namespace Server.Items if (m_Item != null && value == null) { var delay = Utility.RandomMinMax(Entry.MinDelay, Entry.MaxDelay); - NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(delay); + NextRespawn = Core.Now + TimeSpan.FromMinutes(delay); } if (Instance != null) @@ -413,7 +413,7 @@ namespace Server.Items Item = null; } - if (Item == null && DateTime.UtcNow >= NextRespawn) + if (Item == null && Core.Now >= NextRespawn) { Item = Entry.CreateInstance(); } diff --git a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs index 62da60d24..28d35544e 100644 --- a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs +++ b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs @@ -51,7 +51,7 @@ namespace Server.Items return false; } - if (DateTime.UtcNow.Month != 12) + if (Core.Now.Month != 12) { from.SendLocalizedMessage( 1005700 diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs index 348d2d47e..ab2fa1a63 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs @@ -26,7 +26,7 @@ namespace Server.Engines.Mahjong WallBreakIndicator = new MahjongWallBreakIndicator(this, new Point2D(335, 335)); Dices = new MahjongDices(this); Players = new MahjongPlayers(this, MaxPlayers, BaseScore); - m_LastReset = DateTime.UtcNow; + m_LastReset = Core.Now; Level = SecureLevel.CoOwners; } @@ -199,12 +199,12 @@ namespace Server.Engines.Mahjong public void ResetGame(Mobile from) { - if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0)) + if (Core.Now - m_LastReset < TimeSpan.FromSeconds(5.0)) { return; } - m_LastReset = DateTime.UtcNow; + m_LastReset = Core.Now; if (from != null) { @@ -222,12 +222,12 @@ namespace Server.Engines.Mahjong public void ResetWalls(Mobile from) { - if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0)) + if (Core.Now - m_LastReset < TimeSpan.FromSeconds(5.0)) { return; } - m_LastReset = DateTime.UtcNow; + m_LastReset = Core.Now; BuildWalls(); @@ -320,7 +320,7 @@ namespace Server.Engines.Mahjong m_ShowScores = reader.ReadBool(); m_SpectatorVision = reader.ReadBool(); - m_LastReset = DateTime.UtcNow; + m_LastReset = Core.Now; break; } diff --git a/Projects/UOContent/Items/Lights/BaseLight.cs b/Projects/UOContent/Items/Lights/BaseLight.cs index a181b1551..56213748a 100644 --- a/Projects/UOContent/Items/Lights/BaseLight.cs +++ b/Projects/UOContent/Items/Lights/BaseLight.cs @@ -51,16 +51,7 @@ namespace Server.Items [CommandProperty(AccessLevel.GameMaster)] public TimeSpan Duration { - get - { - if (m_Duration != TimeSpan.Zero && m_Burning) - { - return m_End - DateTime.UtcNow; - } - - return m_Duration; - } - + get => m_Duration != TimeSpan.Zero && m_Burning ? m_End - Core.Now : m_Duration; set => m_Duration = value; } @@ -120,7 +111,7 @@ namespace Server.Items } else if (m_Duration != TimeSpan.Zero) { - m_Duration = m_End - DateTime.UtcNow; + m_Duration = m_End - Core.Now; } m_Timer?.Stop(); @@ -145,7 +136,7 @@ namespace Server.Items return; } - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; m_Timer = new InternalTimer(this, delay); m_Timer.Start(); @@ -214,7 +205,7 @@ namespace Server.Items if (m_Burning && m_Duration != TimeSpan.Zero) { - DoTimer(reader.ReadDeltaTime() - DateTime.UtcNow); + DoTimer(reader.ReadDeltaTime() - Core.Now); } break; diff --git a/Projects/UOContent/Items/Misc/AcidSlime.cs b/Projects/UOContent/Items/Misc/AcidSlime.cs index c40f5836f..a141827cb 100644 --- a/Projects/UOContent/Items/Misc/AcidSlime.cs +++ b/Projects/UOContent/Items/Misc/AcidSlime.cs @@ -26,7 +26,7 @@ namespace Server.Items Movable = false; m_MinDamage = minDamage; m_MaxDamage = maxDamage; - m_Created = DateTime.UtcNow; + m_Created = Core.Now; m_Duration = duration; m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick); } @@ -44,7 +44,7 @@ namespace Server.Items private void OnTick() { - var now = DateTime.UtcNow; + var now = Core.Now; var age = now - m_Created; if (age > m_Duration) diff --git a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs index 46bdf6f09..3c69a01bf 100644 --- a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs +++ b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs @@ -113,7 +113,7 @@ namespace Server.Items m_CorpseName = GetCorpseName(owner); - TimeOfDeath = DateTime.UtcNow; + TimeOfDeath = Core.Now; AccessLevel = owner.AccessLevel; Guild = owner.Guild as Guild; @@ -140,10 +140,10 @@ namespace Server.Items { var info = owner.Aggressors[i]; - if (DateTime.UtcNow - info.LastCombatTime < lastTime) + if (Core.Now - info.LastCombatTime < lastTime) { Killer = info.Attacker; - lastTime = DateTime.UtcNow - info.LastCombatTime; + lastTime = Core.Now - info.LastCombatTime; } if (!isBaseCreature && !info.CriminalAggression) @@ -156,10 +156,10 @@ namespace Server.Items { var info = owner.Aggressed[i]; - if (DateTime.UtcNow - info.LastCombatTime < lastTime) + if (Core.Now - info.LastCombatTime < lastTime) { Killer = info.Defender; - lastTime = DateTime.UtcNow - info.LastCombatTime; + lastTime = Core.Now - info.LastCombatTime; } if (!isBaseCreature) @@ -200,7 +200,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public virtual bool InstancedCorpse => Core.SE && DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime; + public virtual bool InstancedCorpse => Core.SE && Core.Now < TimeOfDeath + InstancedCorpseTime; public override bool IsDecoContainer => false; @@ -471,7 +471,7 @@ namespace Server.Items { m_DecayTimer?.Stop(); - m_DecayTime = DateTime.UtcNow + delay; + m_DecayTime = Core.Now + delay; m_DecayTimer = new InternalTimer(this, delay); m_DecayTimer.Start(); @@ -657,7 +657,7 @@ namespace Server.Items if (reader.ReadBool()) { - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + BeginDecay(reader.ReadDeltaTime() - Core.Now); } Looters = reader.ReadEntityList(); @@ -711,7 +711,7 @@ namespace Server.Items { if (reader.ReadBool()) { - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + BeginDecay(reader.ReadDeltaTime() - Core.Now); } goto case 6; @@ -757,7 +757,7 @@ namespace Server.Items { if (version < 10) { - TimeOfDeath = DateTime.UtcNow; + TimeOfDeath = Core.Now; } if (version < 7) diff --git a/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs b/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs index 33306fa2e..65204f802 100644 --- a/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs +++ b/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs @@ -27,7 +27,7 @@ namespace Server.Items { m_DecayTimer?.Stop(); - m_DecayTime = DateTime.UtcNow + delay; + m_DecayTime = Core.Now + delay; m_DecayTimer = new InternalTimer(this, delay); m_DecayTimer.Start(); @@ -85,7 +85,7 @@ namespace Server.Items { if (reader.ReadBool()) { - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + BeginDecay(reader.ReadDeltaTime() - Core.Now); } break; diff --git a/Projects/UOContent/Items/Misc/DeceitBrazier.cs b/Projects/UOContent/Items/Misc/DeceitBrazier.cs index 11e2557dd..0cc30f4c7 100644 --- a/Projects/UOContent/Items/Misc/DeceitBrazier.cs +++ b/Projects/UOContent/Items/Misc/DeceitBrazier.cs @@ -14,7 +14,7 @@ namespace Server.Items { Movable = false; Light = LightType.Circle225; - NextSpawn = DateTime.UtcNow; + NextSpawn = Core.Now; NextSpawnDelay = TimeSpan.FromMinutes(15.0); SpawnRange = 5; } @@ -87,7 +87,7 @@ namespace Server.Items NextSpawnDelay = reader.ReadTimeSpan(); } - NextSpawn = DateTime.UtcNow; + NextSpawn = Core.Now; } public virtual void HeedWarning() @@ -101,7 +101,7 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { - if (NextSpawn < DateTime.UtcNow) // means we haven't spawned anything if the next spawn is below + if (NextSpawn < Core.Now) // means we haven't spawned anything if the next spawn is below { if (Utility.InRange(m.Location, Location, 1) && !Utility.InRange(oldLocation, Location, 1) && m.Player && !(m.AccessLevel > AccessLevel.Player || m.Hidden)) @@ -171,7 +171,7 @@ namespace Server.Items { try { - if (NextSpawn < DateTime.UtcNow) + if (NextSpawn < Core.Now) { var map = Map; var bc = Creatures.RandomElement().CreateInstance(); @@ -182,7 +182,7 @@ namespace Server.Items Timer.DelayCall(TimeSpan.FromSeconds(1), SummonCreatureToWorld, bc, spawnLoc, map); - NextSpawn = DateTime.UtcNow + NextSpawnDelay; + NextSpawn = Core.Now + NextSpawnDelay; } else { diff --git a/Projects/UOContent/Items/Misc/Firebomb.cs b/Projects/UOContent/Items/Misc/Firebomb.cs index 62ce9d3b4..5d2a29093 100644 --- a/Projects/UOContent/Items/Misc/Firebomb.cs +++ b/Projects/UOContent/Items/Misc/Firebomb.cs @@ -225,7 +225,7 @@ namespace Server.Items { Movable = false; m_LitBy = litBy; - m_Expire = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_Expire = Core.Now + TimeSpan.FromSeconds(10); m_Burning = toDamage; m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnFirebombFieldTimerTick); } @@ -295,7 +295,7 @@ namespace Server.Items } } - if (DateTime.UtcNow >= m_Expire) + if (Core.Now >= m_Expire) { m_Timer.Stop(); Delete(); diff --git a/Projects/UOContent/Items/Misc/Guillotine.cs b/Projects/UOContent/Items/Misc/Guillotine.cs index c6339e733..c98a41e64 100644 --- a/Projects/UOContent/Items/Misc/Guillotine.cs +++ b/Projects/UOContent/Items/Misc/Guillotine.cs @@ -24,7 +24,7 @@ namespace Server.Items { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that } - else if (Visible && (ItemID == 4656 || ItemID == 4702) && DateTime.UtcNow >= m_NextUse) + else if (Visible && (ItemID == 4656 || ItemID == 4702) && Core.Now >= m_NextUse) { var p = GetWorldLocation(); @@ -42,7 +42,7 @@ namespace Server.Items Timer.DelayCall(TimeSpan.FromSeconds(5.00), BackUp); - m_NextUse = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + m_NextUse = Core.Now + TimeSpan.FromSeconds(10.0); } } diff --git a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs index 28da6ff66..f48fdb506 100644 --- a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs +++ b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs @@ -244,7 +244,7 @@ namespace Server.Items if (text.Length > 0) { - var message = new PlayerBBMessage(DateTime.UtcNow, from, text); + var message = new PlayerBBMessage(Core.Now, from, text); if (m_Greeting) { diff --git a/Projects/UOContent/Items/Misc/PoolOfAcid.cs b/Projects/UOContent/Items/Misc/PoolOfAcid.cs index d05f52abf..b343459e5 100644 --- a/Projects/UOContent/Items/Misc/PoolOfAcid.cs +++ b/Projects/UOContent/Items/Misc/PoolOfAcid.cs @@ -27,7 +27,7 @@ namespace Server.Items m_MinDamage = minDamage; m_MaxDamage = maxDamage; - m_Created = DateTime.UtcNow; + m_Created = Core.Now; m_Duration = duration; m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick); @@ -46,7 +46,7 @@ namespace Server.Items private void OnTick() { - var now = DateTime.UtcNow; + var now = Core.Now; var age = now - m_Created; if (age > m_Duration) diff --git a/Projects/UOContent/Items/Misc/PowerGenerator.cs b/Projects/UOContent/Items/Misc/PowerGenerator.cs index d2e60e62f..1438234bf 100644 --- a/Projects/UOContent/Items/Misc/PowerGenerator.cs +++ b/Projects/UOContent/Items/Misc/PowerGenerator.cs @@ -197,7 +197,7 @@ namespace Server.Items } if (m_User.Deleted || m_User.Map != Map || !m_User.InRange(this, 3) - || m_User.NetState == null || DateTime.UtcNow - m_LastUse >= m_UseTimeout) + || m_User.NetState == null || Core.Now - m_LastUse >= m_UseTimeout) { m_User.CloseGump(); } @@ -209,7 +209,7 @@ namespace Server.Items } m_User = from; - m_LastUse = DateTime.UtcNow; + m_LastUse = Core.Now; from.SendGump(new GameGump(this, from, 0, false)); } @@ -473,7 +473,7 @@ namespace Server.Items if (40.0 + Utility.RandomDouble() * 80.0 < lockpicking) { m_From.SendGump(new GameGump(m_Panel, m_From, m_Step, true)); - m_Panel.m_LastUse = DateTime.UtcNow; + m_Panel.m_LastUse = Core.Now; } else { @@ -520,7 +520,7 @@ namespace Server.Items { m_From.PlaySound(0x1F4); m_From.SendGump(new GameGump(m_Panel, m_From, m_Step + 1, false)); - m_Panel.m_LastUse = DateTime.UtcNow; + m_Panel.m_LastUse = Core.Now; } } else diff --git a/Projects/UOContent/Items/Misc/Teleporter.cs b/Projects/UOContent/Items/Misc/Teleporter.cs index d56398fb8..7336aa897 100644 --- a/Projects/UOContent/Items/Misc/Teleporter.cs +++ b/Projects/UOContent/Items/Misc/Teleporter.cs @@ -755,7 +755,7 @@ namespace Server.Items if (ShowTimeRemaining) { - m.SendMessage("Time remaining: {0}", FormatTime(info.Timer.Next - DateTime.UtcNow)); + m.SendMessage("Time remaining: {0}", FormatTime(info.Timer.Next - Core.Now)); } Timer.DelayCall(TimeSpan.FromSeconds(5), EndLock, m); @@ -932,7 +932,7 @@ namespace Server.Items var m = reader.ReadEntity(); var end = reader.ReadDateTime(); - StartTimer(m, end - DateTime.UtcNow); + StartTimer(m, end - Core.Now); } } } diff --git a/Projects/UOContent/Items/Misc/WarningItem.cs b/Projects/UOContent/Items/Misc/WarningItem.cs index b56794584..ebf899930 100644 --- a/Projects/UOContent/Items/Misc/WarningItem.cs +++ b/Projects/UOContent/Items/Misc/WarningItem.cs @@ -100,12 +100,12 @@ namespace Server.Items public virtual void Broadcast(Mobile triggerer) { - if (m_Broadcasting || DateTime.UtcNow < m_LastBroadcast + ResetDelay) + if (m_Broadcasting || Core.Now < m_LastBroadcast + ResetDelay) { return; } - m_LastBroadcast = DateTime.UtcNow; + m_LastBroadcast = Core.Now; m_Broadcasting = true; diff --git a/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs b/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs index 82a78f3a5..a9fb1ab6b 100644 --- a/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs +++ b/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs @@ -29,7 +29,7 @@ namespace Server.Items m_Entries = new List(); - Created = DateTime.UtcNow; + Created = Core.Now; m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick); } @@ -94,7 +94,7 @@ namespace Server.Items private void OnTick() { - var now = DateTime.UtcNow; + var now = Core.Now; var age = now - Created; if (age >= TimeSpan.FromSeconds(100.0)) @@ -191,7 +191,7 @@ namespace Server.Items { Player = player; Fire = fire; - Start = DateTime.UtcNow; + Start = Core.Now; m_Safe = false; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs index 80b1b9a4b..a0ac49105 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs @@ -113,9 +113,9 @@ namespace Server.Items public static int GetDelay(Mobile m) { - if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow) + if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) { - return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; + return (int)(timer.Next - Core.Now).TotalSeconds; } return 0; @@ -185,7 +185,7 @@ namespace Server.Items MoveToWorld(loc, map); From = from; - m_End = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_End = Core.Now + TimeSpan.FromSeconds(10); SetDamage(min, max); @@ -292,7 +292,7 @@ namespace Server.Items return; } - if (DateTime.UtcNow > m_End) + if (Core.Now > m_End) { m_Item.Delete(); Stop(); diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index c271dd761..a73fde919 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -104,7 +104,7 @@ namespace Server.Items continue; } - mon.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(5.0)); // TODO check + mon.Pacify(from, Core.Now + TimeSpan.FromSeconds(5.0)); // TODO check } } } @@ -131,9 +131,9 @@ namespace Server.Items public static int GetDelay(Mobile m) { - if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow) + if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) { - return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; + return (int)(timer.Next - Core.Now).TotalSeconds; } return 0; diff --git a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs index 5c50b4f38..97e16e150 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs @@ -342,7 +342,7 @@ namespace Server.Items return; } - if (DateTime.UtcNow < NextUse) + if (Core.Now < NextUse) { from.SendLocalizedMessage(502406); // This book needs time to recharge. return; @@ -359,7 +359,7 @@ namespace Server.Items { if (!Core.SA) { - NextUse = DateTime.UtcNow + UseDelay; + NextUse = Core.Now + UseDelay; } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 63e8c72c4..d8f690d4b 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -108,7 +108,7 @@ namespace Server.Items { if (value != m_ReplenishesCharges && value) { - m_LastReplenished = DateTime.UtcNow; + m_LastReplenished = Core.Now; } m_ReplenishesCharges = value; @@ -159,15 +159,15 @@ namespace Server.Items return; } - if (m_LastReplenished + ChargeReplenishRate < DateTime.UtcNow) + if (m_LastReplenished + ChargeReplenishRate < Core.Now) { - var timeDifference = DateTime.UtcNow - m_LastReplenished; + var timeDifference = Core.Now - m_LastReplenished; m_UsesRemaining = Math.Min( m_UsesRemaining + (int)(timeDifference.Ticks / ChargeReplenishRate.Ticks), InitMaxUses ); // How rude of TimeSpan to not allow timespan division. - m_LastReplenished = DateTime.UtcNow; + m_LastReplenished = Core.Now; if (invalidate) { diff --git a/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs b/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs index 22177f3eb..7903bb9b4 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs @@ -315,13 +315,7 @@ namespace Server.Items return; } - var ts = t.Next - DateTime.UtcNow; - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - t.Delay = ts; + t.Delay = Utility.Max(t.Next - Core.Now, TimeSpan.Zero); t.Stop(); } @@ -334,7 +328,7 @@ namespace Server.Items } public static TimeSpan TimeRemaining(Mobile m) => - Timers.TryGetValue(m, out var t) ? t.Next - DateTime.UtcNow : TimeSpan.Zero; + Timers.TryGetValue(m, out var t) ? t.Next - Core.Now : TimeSpan.Zero; private class InternalTimer : Timer { diff --git a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs index 9fa8f8b36..c3dce8530 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs @@ -39,7 +39,7 @@ namespace Server.Items var m = entry.Key; writer.Write(m); - writer.Write(entry.Value.Next - DateTime.UtcNow); + writer.Write(entry.Value.Next - Core.Now); writer.Write(m.NameMod); } } diff --git a/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs b/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs index eedfb03a3..4dde6b0f5 100644 --- a/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs +++ b/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs @@ -33,7 +33,7 @@ namespace Server.Items public static void Initialize() { - ServerStart = DateTime.UtcNow; + ServerStart = Core.Now; } public static MoonPhase GetMoonPhase(Map map, int x, int y) @@ -55,7 +55,7 @@ namespace Server.Items public static void GetTime(Map map, int x, int y, out int hours, out int minutes, out int totalMinutes) { - var timeSpan = DateTime.UtcNow - WorldStart; + var timeSpan = Core.Now - WorldStart; totalMinutes = (int)(timeSpan.TotalSeconds / SecondsPerUOMinute); diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs index 097f1ba70..bd451b669 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs @@ -155,7 +155,7 @@ namespace Server.Items var next = reader.ReadDateTime(); - var now = DateTime.UtcNow; + var now = Core.Now; if (next < now) { diff --git a/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs b/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs index b312c9c61..5b2a75a5d 100644 --- a/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs +++ b/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs @@ -86,7 +86,7 @@ namespace Server.Items m_SpawnTimer = new SpawnTimer(this, delay); m_SpawnTimer.Start(); - m_NextSpawnTime = DateTime.UtcNow + delay; + m_NextSpawnTime = Core.Now + delay; } private void StopSpawnTimer() @@ -134,7 +134,7 @@ namespace Server.Items if (m_Petals < 10) { - StartSpawnTimer(m_NextSpawnTime - DateTime.UtcNow); + StartSpawnTimer(m_NextSpawnTime - Core.Now); } } diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs index 49c51065d..92238b11a 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs @@ -204,7 +204,7 @@ namespace Server.Items var daysLeft = (int)Math.Ceiling( (deed.Stone.Started + deed.Stone.Duration + - HouseRaffleStone.ExpirationTime - DateTime.UtcNow).TotalDays + HouseRaffleStone.ExpirationTime - Core.Now).TotalDays ); return diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index 34be83a1b..61be90d6d 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -18,7 +18,7 @@ namespace Server.Items Address = From.NetState?.Address ?? IPAddress.None; - Date = DateTime.UtcNow; + Date = Core.Now; } public RaffleEntry(IGenericReader reader, int version) @@ -132,7 +132,7 @@ namespace Server.Items Entries.Clear(); m_Winner = null; Deed = null; - m_Started = DateTime.UtcNow; + m_Started = Core.Now; } m_State = value; @@ -213,7 +213,7 @@ namespace Server.Items return false; } - return m_Started + m_Duration + ExpirationTime <= DateTime.UtcNow; + return m_Started + m_Duration + ExpirationTime <= Core.Now; } } @@ -537,7 +537,7 @@ namespace Server.Items public void CheckEnd() { - if (m_State != HouseRaffleState.Active || m_Started + m_Duration > DateTime.UtcNow) + if (m_State != HouseRaffleState.Active || m_Started + m_Duration > Core.Now) { return; } diff --git a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs index 19f3e30a6..9f21565a7 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs @@ -238,7 +238,7 @@ namespace Server.Items "You cannot summon your pet to this location." ); } - else if (Core.ML && from is PlayerMobile mobile && DateTime.UtcNow < mobile.LastPetBallTime.AddSeconds(15.0)) + else if (Core.ML && from is PlayerMobile mobile && Core.Now < mobile.LastPetBallTime.AddSeconds(15.0)) { MessageHelper.SendLocalizedMessageTo( this, @@ -304,7 +304,7 @@ namespace Server.Items if (from is PlayerMobile playerMobile) { - playerMobile.LastPetBallTime = DateTime.UtcNow; + playerMobile.LastPetBallTime = Core.Now; } } diff --git a/Projects/UOContent/Items/Special/SoulStone.cs b/Projects/UOContent/Items/Special/SoulStone.cs index 3064645ad..ff30f15df 100644 --- a/Projects/UOContent/Items/Special/SoulStone.cs +++ b/Projects/UOContent/Items/Special/SoulStone.cs @@ -145,7 +145,7 @@ namespace Server.Items { var info = m.Aggressed[i]; - if (DateTime.UtcNow - info.LastCombatTime < time) + if (Core.Now - info.LastCombatTime < time) { return true; } @@ -231,7 +231,7 @@ namespace Server.Items return false; } - if ((from as PlayerMobile)?.AcceleratedStart > DateTime.UtcNow) + if ((from as PlayerMobile)?.AcceleratedStart > Core.Now) { // You may not use a soulstone while your character is under the effects of a Scroll of Alacrity. from.SendLocalizedMessage(1078115); @@ -743,7 +743,7 @@ namespace Server.Items return; } - if ((from as PlayerMobile)?.AcceleratedStart > DateTime.UtcNow) + if ((from as PlayerMobile)?.AcceleratedStart > Core.Now) { //
Unable to Absorb Selected Skill from Soulstone
diff --git a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs index d9320fc2c..8b656de51 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs @@ -61,7 +61,7 @@ namespace Server.Items } } - if (pm.AcceleratedStart > DateTime.UtcNow) + if (pm.AcceleratedStart > Core.Now) { from.SendLocalizedMessage(1077951); // You are already under the effect of an accelerated skillgain scroll. return false; @@ -96,7 +96,7 @@ namespace Server.Items Effects.PlaySound(from.Location, from.Map, 0x1E9); Effects.SendTargetParticles(from, 0x373A, 35, 45, 0x00, 0x00, 9502, (EffectLayer)255, 0x100); - pm.AcceleratedStart = DateTime.UtcNow + TimeSpan.FromMinutes(15); + pm.AcceleratedStart = Core.Now + TimeSpan.FromMinutes(15); Timer.DelayCall(TimeSpan.FromMinutes(15), Expire_Callback, from); pm.AcceleratedSkill = Skill; diff --git a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs index 35c803142..a0719165b 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs @@ -72,7 +72,7 @@ namespace Server.Items } } - if (pm.AcceleratedStart > DateTime.UtcNow) + if (pm.AcceleratedStart > Core.Now) { from.SendLocalizedMessage(1077951); // You are already under the effect of an accelerated skillgain scroll. return false; diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs index 67c8ab2d0..6d451fa81 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs @@ -60,9 +60,9 @@ namespace Server.Items { m.SendLocalizedMessage(1060197); // You are not dead, and thus cannot be resurrected! } - else if (m.AnkhNextUse > DateTime.UtcNow) + else if (m.AnkhNextUse > Core.Now) { - var delay = m.AnkhNextUse - DateTime.UtcNow; + var delay = m.AnkhNextUse - Core.Now; if (delay.TotalMinutes > 0) { @@ -167,7 +167,7 @@ namespace Server.Items if (from is PlayerMobile mobile) { - mobile.AnkhNextUse = DateTime.UtcNow + TimeSpan.FromHours(1); + mobile.AnkhNextUse = Core.Now + TimeSpan.FromHours(1); } base.OnResponse(state, info); diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs b/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs index f5c35ace1..759b2d8df 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs @@ -255,7 +255,7 @@ namespace Server.Items } else { - writer.Write(DateTime.UtcNow + TimeSpan.FromDays(1)); + writer.Write(Core.Now + TimeSpan.FromDays(1)); } } @@ -277,12 +277,12 @@ namespace Server.Items var next = reader.ReadDateTime(); - if (next < DateTime.UtcNow) + if (next < Core.Now) { - next = DateTime.UtcNow; + next = Core.Now; } - m_Timer = Timer.DelayCall(next - DateTime.UtcNow, TimeSpan.FromDays(1), GiveResources); + m_Timer = Timer.DelayCall(next - Core.Now, TimeSpan.FromDays(1), GiveResources); break; } } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs b/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs index 1777cbbd2..195f87c13 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs @@ -149,7 +149,7 @@ namespace Server.Items } else { - writer.Write(DateTime.UtcNow + TimeSpan.FromDays(1)); + writer.Write(Core.Now + TimeSpan.FromDays(1)); } } @@ -164,12 +164,12 @@ namespace Server.Items var next = reader.ReadDateTime(); - if (next < DateTime.UtcNow) + if (next < Core.Now) { - next = DateTime.UtcNow; + next = Core.Now; } - m_Timer = Timer.DelayCall(next - DateTime.UtcNow, TimeSpan.FromDays(1), GiveLogs); + m_Timer = Timer.DelayCall(next - Core.Now, TimeSpan.FromDays(1), GiveLogs); } } diff --git a/Projects/UOContent/Items/Talismans/TalismanSummons.cs b/Projects/UOContent/Items/Talismans/TalismanSummons.cs index 8c79873f1..4a3ff4601 100644 --- a/Projects/UOContent/Items/Talismans/TalismanSummons.cs +++ b/Projects/UOContent/Items/Talismans/TalismanSummons.cs @@ -385,7 +385,7 @@ namespace Server.Mobiles public override void OnThink() { /* - if (m_NextWave < DateTime.UtcNow) + if (m_NextWave < Core.Now) AreaHeatDamage(); */ } @@ -436,7 +436,7 @@ namespace Server.Mobiles } } - m_NextWave = DateTime.UtcNow + TimeSpan.FromSeconds( 3 ); + m_NextWave = Core.Now + TimeSpan.FromSeconds( 3 ); } */ } diff --git a/Projects/UOContent/Items/Traps/BaseTrap.cs b/Projects/UOContent/Items/Traps/BaseTrap.cs index 87a24dda7..5ee4e4fd8 100644 --- a/Projects/UOContent/Items/Traps/BaseTrap.cs +++ b/Projects/UOContent/Items/Traps/BaseTrap.cs @@ -51,16 +51,16 @@ namespace Server.Items return; } - if (CheckRange(m.Location, oldLocation, 0) && DateTime.UtcNow >= m_NextActiveTrigger) + if (CheckRange(m.Location, oldLocation, 0) && Core.Now >= m_NextActiveTrigger) { - m_NextActiveTrigger = m_NextPassiveTrigger = DateTime.UtcNow + ResetDelay; + m_NextActiveTrigger = m_NextPassiveTrigger = Core.Now + ResetDelay; OnTrigger(m); } else if (PassivelyTriggered && CheckRange(m.Location, oldLocation, PassiveTriggerRange) && - DateTime.UtcNow >= m_NextPassiveTrigger) + Core.Now >= m_NextPassiveTrigger) { - m_NextPassiveTrigger = DateTime.UtcNow + PassiveTriggerDelay; + m_NextPassiveTrigger = Core.Now + PassiveTriggerDelay; OnTrigger(m); } diff --git a/Projects/UOContent/Items/Weapons/BaseWeapon.cs b/Projects/UOContent/Items/Weapons/BaseWeapon.cs index 48eef5e94..a81e887ab 100644 --- a/Projects/UOContent/Items/Weapons/BaseWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseWeapon.cs @@ -730,7 +730,7 @@ namespace Server.Items if (canSwing) { - canSwing = !(attacker is PlayerMobile p) || p.PeacedUntil <= DateTime.UtcNow; + canSwing = !(attacker is PlayerMobile p) || p.PeacedUntil <= Core.Now; } } diff --git a/Projects/UOContent/Misc/AttackMessage.cs b/Projects/UOContent/Misc/AttackMessage.cs index bfb5652f7..c743a3ce2 100644 --- a/Projects/UOContent/Misc/AttackMessage.cs +++ b/Projects/UOContent/Misc/AttackMessage.cs @@ -51,7 +51,7 @@ namespace Server.Misc { var info = list[i]; - if (info.Attacker == m2 && DateTime.UtcNow < info.LastCombatTime + Delay) + if (info.Attacker == m2 && Core.Now < info.LastCombatTime + Delay) { return true; } @@ -63,7 +63,7 @@ namespace Server.Misc { var info = list[i]; - if (info.Attacker == m1 && DateTime.UtcNow < info.LastCombatTime + Delay) + if (info.Attacker == m1 && Core.Now < info.LastCombatTime + Delay) { return true; } diff --git a/Projects/UOContent/Misc/BuffIcons.cs b/Projects/UOContent/Misc/BuffIcons.cs index 8aec8d3cd..16423d25d 100644 --- a/Projects/UOContent/Misc/BuffIcons.cs +++ b/Projects/UOContent/Misc/BuffIcons.cs @@ -29,7 +29,7 @@ namespace Server : this(iconID, titleCliloc, secondaryCliloc) { TimeLength = length; - TimeStart = DateTime.UtcNow; + TimeStart = Core.TickCount; Timer = Timer.DelayCall(length, RemoveBuff, m, this); } @@ -101,7 +101,7 @@ namespace Server public TimeSpan TimeLength { get; } - public DateTime TimeStart { get; } + public long TimeStart { get; } public Timer Timer { get; } @@ -152,12 +152,12 @@ namespace Server TitleCliloc, SecondaryCliloc, Args, - TimeStart != DateTime.MinValue ? TimeStart + TimeLength - DateTime.UtcNow : TimeSpan.Zero + TimeStart == 0 ? 0 : Math.Max(TimeStart + (long)TimeLength.TotalMilliseconds - Core.TickCount, 0) ); public static void SendAddBuffPacket( NetState ns, Serial mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, - TimeSpan ts + long ticks ) { if (ns == null) @@ -178,7 +178,7 @@ namespace Server writer.Write((short)iconID); writer.Write((short)0x1); // command (0 = remove, 1 = add, 2 = data) writer.Write(0); - writer.Write((short)(ts <= TimeSpan.Zero ? 0 : ts.TotalSeconds)); + writer.Write((short)(ticks / 1000)); writer.Clear(3); writer.Write(titleCliloc); writer.Write(secondaryCliloc); diff --git a/Projects/UOContent/Misc/ClientVerification.cs b/Projects/UOContent/Misc/ClientVerification.cs index d31ef3136..ac0e830a2 100644 --- a/Projects/UOContent/Misc/ClientVerification.cs +++ b/Projects/UOContent/Misc/ClientVerification.cs @@ -86,7 +86,7 @@ namespace Server.Misc if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick || m_OldClientResponse == OldClientResponse.LenientKick && - DateTime.UtcNow - state.Mobile.CreationTime > m_AgeLeniency && + Core.Now - state.Mobile.CreationTime > m_AgeLeniency && state.Mobile is PlayerMobile mobile && mobile.GameTime > m_GameTimeLeniency)) { diff --git a/Projects/UOContent/Misc/Email.cs b/Projects/UOContent/Misc/Email.cs index 357beb986..242ace805 100644 --- a/Projects/UOContent/Misc/Email.cs +++ b/Projects/UOContent/Misc/Email.cs @@ -24,7 +24,7 @@ namespace Server.Misc } var sender = entry.Sender; - var time = DateTime.UtcNow; + var time = Core.Now; var message = new MimeMessage(); message.From.Add(EmailConfiguration.FromAddress); @@ -107,7 +107,7 @@ namespace Server.Misc return; } - var now = DateTime.UtcNow; + var now = Core.Now; var messageID = $"<{now:yyyyMMdd}.{now:HHmmssff}@{EmailConfiguration.EmailServer}>"; message.Headers.Add("Message-ID", messageID); message.From.Add(EmailConfiguration.FromAddress); diff --git a/Projects/UOContent/Misc/Guild.cs b/Projects/UOContent/Misc/Guild.cs index 7d1d2d2df..97ce0fedc 100644 --- a/Projects/UOContent/Misc/Guild.cs +++ b/Projects/UOContent/Misc/Guild.cs @@ -500,7 +500,7 @@ namespace Server.Guilds return WarStatus.Win; } - if (WarLength != TimeSpan.Zero && WarBeginning + WarLength < DateTime.UtcNow) + if (WarLength != TimeSpan.Zero && WarBeginning + WarLength < Core.Now) { if (Kills > w.Kills) { @@ -598,7 +598,7 @@ namespace Server.Guilds Candidates = new List(); Accepted = new List(); - LastFealty = DateTime.UtcNow; + LastFealty = Core.Now; m_Name = name; m_Abbreviation = abbreviation; @@ -766,7 +766,7 @@ namespace Server.Guilds if (m_Type != value) { m_Type = value; - TypeLastChange = DateTime.UtcNow; + TypeLastChange = Core.Now; InvalidateMemberProperties(); } @@ -1157,7 +1157,7 @@ namespace Server.Guilds public override void Serialize(IGenericWriter writer) { - if (LastFealty + TimeSpan.FromDays(1.0) < DateTime.UtcNow) + if (LastFealty + TimeSpan.FromDays(1.0) < Core.Now) { CalculateGuildmaster(); } @@ -1547,7 +1547,7 @@ namespace Server.Guilds m?.Deleted == false && m.Guild == this; public bool CanBeVotedFor(Mobile m) => - (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && + (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= Core.Now) && m?.Deleted == false && m.Guild == this; public void CalculateGuildmaster() @@ -1615,7 +1615,7 @@ namespace Server.Guilds } Leader = winner; - LastFealty = DateTime.UtcNow; + LastFealty = Core.Now; } private class GuildPropsTarget : Target diff --git a/Projects/UOContent/Misc/HardwareInfo.cs b/Projects/UOContent/Misc/HardwareInfo.cs index 3be146304..e3a651da7 100644 --- a/Projects/UOContent/Misc/HardwareInfo.cs +++ b/Projects/UOContent/Misc/HardwareInfo.cs @@ -172,7 +172,7 @@ namespace Server PartialInstalled = reader.ReadByte(), Language = reader.ReadLittleUniSafe(4), Unknown = reader.ReadAsciiSafe(64), - TimeReceived = DateTime.UtcNow + TimeReceived = Core.Now }; if (state.Account is Account acct) diff --git a/Projects/UOContent/Misc/Notoriety.cs b/Projects/UOContent/Misc/Notoriety.cs index 0a8234d33..96dce3691 100644 --- a/Projects/UOContent/Misc/Notoriety.cs +++ b/Projects/UOContent/Misc/Notoriety.cs @@ -342,7 +342,7 @@ namespace Server.Misc actual = Notoriety.Murderer; } - if (DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice) + if (Core.Now >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice) { return actual; } diff --git a/Projects/UOContent/Misc/Profile.cs b/Projects/UOContent/Misc/Profile.cs index 23ff42cb9..7fe9bb9ef 100644 --- a/Projects/UOContent/Misc/Profile.cs +++ b/Projects/UOContent/Misc/Profile.cs @@ -70,7 +70,7 @@ namespace Server.Misc return ""; } - var ts = DateTime.UtcNow - a.Created; + var ts = Core.Now - a.Created; if (Format(ts.TotalDays, "This account is {0} day{1} old.", out var v)) { diff --git a/Projects/UOContent/Misc/ShardPoller.cs b/Projects/UOContent/Misc/ShardPoller.cs index 767131d69..5644aa213 100644 --- a/Projects/UOContent/Misc/ShardPoller.cs +++ b/Projects/UOContent/Misc/ShardPoller.cs @@ -47,32 +47,10 @@ namespace Server.Misc public DateTime StartTime { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public TimeSpan TimeRemaining - { - get - { - if (StartTime == DateTime.MinValue || !m_Active) - { - return TimeSpan.Zero; - } - - try - { - var ts = StartTime + Duration - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - return TimeSpan.Zero; - } - - return ts; - } - catch - { - return TimeSpan.Zero; - } - } - } + public TimeSpan TimeRemaining => + StartTime == DateTime.MinValue || !m_Active + ? TimeSpan.Zero + : Utility.Max(StartTime + Duration - Core.Now, TimeSpan.Zero); [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public bool Active @@ -89,7 +67,7 @@ namespace Server.Misc if (m_Active) { - StartTime = DateTime.UtcNow; + StartTime = Core.Now; m_ActivePollers.Add(this); } else diff --git a/Projects/UOContent/Misc/SkillCheck.cs b/Projects/UOContent/Misc/SkillCheck.cs index e6c207baf..e17527c3a 100644 --- a/Projects/UOContent/Misc/SkillCheck.cs +++ b/Projects/UOContent/Misc/SkillCheck.cs @@ -293,7 +293,7 @@ namespace Server.Misc } if (from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && - pm.AcceleratedStart > DateTime.UtcNow) + pm.AcceleratedStart > Core.Now) { toGain *= Utility.RandomMinMax(2, 5); } @@ -433,51 +433,51 @@ namespace Server.Misc { if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastStrGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (creature.LastStrGain + m_PetStatGainDelay >= Core.Now) { return; } } - else if (from.LastStrGain + m_StatGainDelay >= DateTime.UtcNow) + else if (from.LastStrGain + m_StatGainDelay >= Core.Now) { return; } - from.LastStrGain = DateTime.UtcNow; + from.LastStrGain = Core.Now; break; } case Stat.Dex: { if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastDexGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (creature.LastDexGain + m_PetStatGainDelay >= Core.Now) { return; } } - else if (from.LastDexGain + m_StatGainDelay >= DateTime.UtcNow) + else if (from.LastDexGain + m_StatGainDelay >= Core.Now) { return; } - from.LastDexGain = DateTime.UtcNow; + from.LastDexGain = Core.Now; break; } case Stat.Int: { if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastIntGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (creature.LastIntGain + m_PetStatGainDelay >= Core.Now) { return; } } - else if (from.LastIntGain + m_StatGainDelay >= DateTime.UtcNow) + else if (from.LastIntGain + m_StatGainDelay >= Core.Now) { return; } - from.LastIntGain = DateTime.UtcNow; + from.LastIntGain = Core.Now; break; } } diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index 21c4105b3..7ca244892 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -1760,7 +1760,7 @@ namespace Server.Mobiles public virtual bool DoBardPacified() { - if (DateTime.UtcNow < m_Mobile.BardEndTime) + if (Core.Now < m_Mobile.BardEndTime) { m_Mobile.DebugSay("I am pacified, I wait"); m_Mobile.Combatant = null; @@ -1777,7 +1777,7 @@ namespace Server.Mobiles public virtual bool DoBardProvoked() { - if (DateTime.UtcNow >= m_Mobile.BardEndTime && + if (Core.Now >= m_Mobile.BardEndTime && (m_Mobile.BardMaster?.Deleted != false || m_Mobile.BardMaster.Map != m_Mobile.Map || m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) > m_Mobile.RangePerception)) @@ -1944,7 +1944,7 @@ namespace Server.Mobiles using (var op = new StreamWriter("nan_transform.txt", true)) { op.WriteLine( - $"NaN in TransformMoveDelay: {DateTime.UtcNow}, {GetType()}, {m_Mobile?.GetType()}, {m_Mobile.HitsMax}" + $"NaN in TransformMoveDelay: {Core.Now}, {GetType()}, {m_Mobile?.GetType()}, {m_Mobile.HitsMax}" ); } diff --git a/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs b/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs index c2a0efbfc..043012ed8 100644 --- a/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs +++ b/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs @@ -100,7 +100,7 @@ namespace Server.Mobiles from.SendLocalizedMessage(1071182); // The cow nimbly escapes your attempts to milk it. } - if (Milk == 0 && MilkedOn + TimeSpan.FromDays(1) > DateTime.UtcNow) + if (Milk == 0 && MilkedOn + TimeSpan.FromDays(1) > Core.Now) { from.SendLocalizedMessage(1080198); // This cow can not be milked now. Please wait for some time. } @@ -111,7 +111,7 @@ namespace Server.Mobiles Milk = 4; } - MilkedOn = DateTime.UtcNow; + MilkedOn = Core.Now; Milk--; return true; diff --git a/Projects/UOContent/Mobiles/Animals/Misc/Sheep.cs b/Projects/UOContent/Mobiles/Animals/Misc/Sheep.cs index af53f866b..04e21dd45 100644 --- a/Projects/UOContent/Mobiles/Animals/Misc/Sheep.cs +++ b/Projects/UOContent/Mobiles/Animals/Misc/Sheep.cs @@ -54,7 +54,7 @@ namespace Server.Mobiles set { m_NextWoolTime = value; - Body = DateTime.UtcNow >= m_NextWoolTime ? 0xCF : 0xDF; + Body = Core.Now >= m_NextWoolTime ? 0xCF : 0xDF; } } @@ -68,7 +68,7 @@ namespace Server.Mobiles public void Carve(Mobile from, Item item) { - if (DateTime.UtcNow < m_NextWoolTime) + if (Core.Now < m_NextWoolTime) { // This sheep is not yet ready to be shorn. PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500449, from.NetState); @@ -78,13 +78,13 @@ namespace Server.Mobiles from.SendLocalizedMessage(500452); // You place the gathered wool into your backpack. from.AddToBackpack(new Wool(Map == Map.Felucca ? 2 : 1)); - NextWoolTime = DateTime.UtcNow + TimeSpan.FromHours(3.0); // TODO: Proper time delay + NextWoolTime = Core.Now + TimeSpan.FromHours(3.0); // TODO: Proper time delay } public override void OnThink() { base.OnThink(); - Body = DateTime.UtcNow >= m_NextWoolTime ? 0xCF : 0xDF; + Body = Core.Now >= m_NextWoolTime ? 0xCF : 0xDF; } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs b/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs index 3f2a12ff2..53be78aa0 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs @@ -134,10 +134,10 @@ namespace Server.Mobiles var attacker = from ?? m_Rider.FindMostRecentDamager(true); - if (!(attacker == this || attacker == m_Rider || willKill || DateTime.UtcNow < NextMountAbility) + if (!(attacker == this || attacker == m_Rider || willKill || Core.Now < NextMountAbility) && DoMountAbility(amount, from)) { - NextMountAbility = DateTime.UtcNow + MountAbilityDelay; + NextMountAbility = Core.Now + MountAbilityDelay; } } diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index 11670dfa7..ebcd1ed2f 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -962,7 +962,7 @@ namespace Server.Mobiles { if (m_DeleteTimer?.Running == true) { - return m_DeleteTimer.Next - DateTime.UtcNow; + return m_DeleteTimer.Next - Core.Now; } return TimeSpan.Zero; @@ -1422,7 +1422,7 @@ namespace Server.Mobiles public void Unpacify() { - BardEndTime = DateTime.UtcNow; + BardEndTime = Core.Now; BardPacified = false; } @@ -1907,7 +1907,7 @@ namespace Server.Mobiles if (m_bSummoned) { SummonEnd = reader.ReadDeltaTime(); - new UnsummonTimer(m_ControlMaster, this, SummonEnd - DateTime.UtcNow).Start(); + new UnsummonTimer(m_ControlMaster, this, SummonEnd - Core.Now).Start(); } ControlSlots = reader.ReadInt(); @@ -2631,7 +2631,7 @@ namespace Server.Mobiles { // idling... - if (DateTime.UtcNow >= m_IdleReleaseTime) + if (Core.Now >= m_IdleReleaseTime) { m_IdleReleaseTime = DateTime.MinValue; return false; // idle is over @@ -2645,7 +2645,7 @@ namespace Server.Mobiles return false; // not idling, but don't want to enter idle state } - m_IdleReleaseTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(15, 25)); + m_IdleReleaseTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(15, 25)); if (Body.IsHuman) { @@ -3271,7 +3271,7 @@ namespace Server.Mobiles { if (OwnerAbandonTime == DateTime.MinValue) { - OwnerAbandonTime = DateTime.UtcNow; + OwnerAbandonTime = Core.Now; } } else @@ -3551,7 +3551,7 @@ namespace Server.Mobiles } new UnsummonTimer(caster, creature, duration).Start(); - creature.SummonEnd = DateTime.UtcNow + duration; + creature.SummonEnd = Core.Now + duration; creature.MoveToWorld(p, caster.Map); @@ -3730,7 +3730,7 @@ namespace Server.Mobiles BardMaster = master; BardTarget = target; Combatant = target; - BardEndTime = DateTime.UtcNow + TimeSpan.FromSeconds(30.0); + BardEndTime = Core.Now + TimeSpan.FromSeconds(30.0); if (target is BaseCreature t) { @@ -3744,7 +3744,7 @@ namespace Server.Mobiles t.BardMaster = master; t.BardTarget = this; t.Combatant = this; - t.BardEndTime = DateTime.UtcNow + TimeSpan.FromSeconds(30.0); + t.BardEndTime = Core.Now + TimeSpan.FromSeconds(30.0); } } else @@ -3859,7 +3859,7 @@ namespace Server.Mobiles { if (OwnerAbandonTime == DateTime.MinValue) { - OwnerAbandonTime = DateTime.UtcNow; + OwnerAbandonTime = Core.Now; } } else @@ -3933,7 +3933,7 @@ namespace Server.Mobiles private void CheckShout(PlayerMobile pm, Point3D oldLocation) { - if (m_MLNextShout > DateTime.UtcNow || pm.Hidden || !pm.Alive) + if (m_MLNextShout > Core.Now || pm.Hidden || !pm.Alive) { return; } @@ -3960,7 +3960,7 @@ namespace Server.Mobiles } Shout(pm); - m_MLNextShout = DateTime.UtcNow + ShoutDelay; + m_MLNextShout = Core.Now + ShoutDelay; } public virtual void Shout(PlayerMobile pm) @@ -4187,7 +4187,7 @@ namespace Server.Mobiles return false; } - if (DateTime.UtcNow >= EndFleeTime) + if (Core.Now >= EndFleeTime) { StopFlee(); return false; @@ -4198,7 +4198,7 @@ namespace Server.Mobiles public virtual void BeginFlee(TimeSpan maxDuration) { - EndFleeTime = DateTime.UtcNow + maxDuration; + EndFleeTime = Core.Now + maxDuration; } public virtual bool IsPetFriend(Mobile m) => Friends?.Contains(m) == true; @@ -4398,9 +4398,9 @@ namespace Server.Mobiles { if (BondingBegin == DateTime.MinValue) { - BondingBegin = DateTime.UtcNow; + BondingBegin = Core.Now; } - else if (BondingBegin + BondingDelay <= DateTime.UtcNow) + else if (BondingBegin + BondingDelay <= Core.Now) { IsBonded = true; BondingBegin = DateTime.MinValue; @@ -5617,7 +5617,7 @@ namespace Server.Mobiles public LoyaltyTimer() : base(InternalDelay, InternalDelay) { - m_NextHourlyCheck = DateTime.UtcNow + TimeSpan.FromHours(1.0); + m_NextHourlyCheck = Core.Now + TimeSpan.FromHours(1.0); Priority = TimerPriority.FiveSeconds; } @@ -5628,12 +5628,12 @@ namespace Server.Mobiles protected override void OnTick() { - if (DateTime.UtcNow < m_NextHourlyCheck) + if (Core.Now < m_NextHourlyCheck) { return; } - m_NextHourlyCheck = DateTime.UtcNow + TimeSpan.FromHours(1.0); + m_NextHourlyCheck = Core.Now + TimeSpan.FromHours(1.0); var toRelease = new List(); @@ -5662,9 +5662,9 @@ namespace Server.Mobiles { if (c.OwnerAbandonTime == DateTime.MinValue) { - c.OwnerAbandonTime = DateTime.UtcNow; + c.OwnerAbandonTime = Core.Now; } - else if (c.OwnerAbandonTime + c.BondingAbandonDelay <= DateTime.UtcNow) + else if (c.OwnerAbandonTime + c.BondingAbandonDelay <= Core.Now) { toRemove.Add(c); } diff --git a/Projects/UOContent/Mobiles/ChampionTitleInfo.cs b/Projects/UOContent/Mobiles/ChampionTitleInfo.cs index 6678ad3a3..357c4c0d9 100644 --- a/Projects/UOContent/Mobiles/ChampionTitleInfo.cs +++ b/Projects/UOContent/Mobiles/ChampionTitleInfo.cs @@ -190,7 +190,7 @@ namespace Server.Mobiles if (before != m_Values[index].Value) { - m_Values[index].LastDecay = DateTime.UtcNow; + m_Values[index].LastDecay = Core.Now; } } @@ -225,7 +225,7 @@ namespace Server.Mobiles for (var i = 0; i < t.m_Values.Length; i++) { - if (t.GetLastDecay(i) + LossDelay < DateTime.UtcNow) + if (t.GetLastDecay(i) + LossDelay < Core.Now) { t.Atrophy(i, LossAmount); } diff --git a/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs b/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs index ee3cfdb21..af3a2465d 100644 --- a/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs +++ b/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs @@ -47,12 +47,12 @@ namespace Server.Mobiles { base.OnThink(); - if (DateTime.UtcNow < m_NextRestore) + if (Core.Now < m_NextRestore) { return; } - m_NextRestore = DateTime.UtcNow + TimeSpan.FromSeconds(2.0); + m_NextRestore = Core.Now + TimeSpan.FromSeconds(2.0); var caster = ControlMaster ?? SummonMaster; diff --git a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs index c795fb515..e1be900ac 100644 --- a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs +++ b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs @@ -62,12 +62,12 @@ namespace Server.Mobiles { base.OnThink(); - if (DateTime.UtcNow < m_NextPickup) + if (Core.Now < m_NextPickup) { return; } - m_NextPickup = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10)); + m_NextPickup = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10)); var pack = Backpack; diff --git a/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs b/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs index 5bfebe689..3f4f5514f 100644 --- a/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs +++ b/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs @@ -48,12 +48,12 @@ namespace Server.Mobiles { base.OnThink(); - if (DateTime.UtcNow < m_NextFlare) + if (Core.Now < m_NextFlare) { return; } - m_NextFlare = DateTime.UtcNow + TimeSpan.FromSeconds(5.0 + 25.0 * Utility.RandomDouble()); + m_NextFlare = Core.Now + TimeSpan.FromSeconds(5.0 + 25.0 * Utility.RandomDouble()); FixedEffect(0x37C4, 1, 12, 1109, 6); PlaySound(0x1D3); diff --git a/Projects/UOContent/Mobiles/Healers/BaseHealer.cs b/Projects/UOContent/Mobiles/Healers/BaseHealer.cs index 4a3afd9bc..d669d5cc5 100644 --- a/Projects/UOContent/Mobiles/Healers/BaseHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/BaseHealer.cs @@ -113,11 +113,11 @@ namespace Server.Mobiles public override void OnMovement(Mobile m, Point3D oldLocation) { - if (!m.Frozen && DateTime.UtcNow >= m_NextResurrect && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m)) + if (!m.Frozen && Core.Now >= m_NextResurrect && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m)) { if (!m.Alive) { - m_NextResurrect = DateTime.UtcNow + ResurrectDelay; + m_NextResurrect = Core.Now + ResurrectDelay; if (m.Map?.CanFit(m.Location, 16, false, false) != true) { diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs b/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs index 93c7f7f44..5ce83b7e4 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs @@ -24,7 +24,7 @@ namespace Server.Mobiles var scalar = caster.Skills.SpiritSpeak.Value * 0.01; m_Target = target; - m_ExpireTime = DateTime.UtcNow + duration; + m_ExpireTime = Core.Now + duration; SetStr(200); SetDex(150); @@ -87,7 +87,7 @@ namespace Server.Mobiles public override void OnThink() { - if (!m_Target.Alive || DateTime.UtcNow > m_ExpireTime) + if (!m_Target.Alive || Core.Now > m_ExpireTime) { Kill(); return; diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs index 02a47d00a..fba6f279a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs @@ -51,7 +51,7 @@ namespace Server.Mobiles PackItem(new BlackthornWelcomeBook()); } - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); } public Betrayer(Serial serial) @@ -148,13 +148,13 @@ namespace Server.Mobiles { var combatant = Combatant; - if (DateTime.UtcNow < m_NextAbilityTime || combatant?.Deleted != false || combatant.Map != Map || + if (Core.Now < m_NextAbilityTime || combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 3) || !CanBeHarmful(combatant) || !InLOS(combatant)) { return; } - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); if (Utility.RandomBool()) { diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs index 5ac65dffa..adf0ccf89 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs @@ -18,7 +18,7 @@ namespace Server.Mobiles Hue = 0x41CE; m_Target = target; - m_ExpireTime = DateTime.UtcNow + TimeSpan.FromMinutes(10.0); + m_ExpireTime = Core.Now + TimeSpan.FromMinutes(10.0); SetStr(401, 500); SetDex(296, 315); @@ -114,7 +114,7 @@ namespace Server.Mobiles public override void OnThink() { - if (!m_Target.Alive || DateTime.UtcNow > m_ExpireTime) + if (!m_Target.Alive || Core.Now > m_ExpireTime) { Delete(); return; diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs index 9a6f8be54..6c6e4a342 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs @@ -108,7 +108,7 @@ namespace Server.Mobiles return; } - if (DateTime.UtcNow >= m_NextBomb) + if (Core.Now >= m_NextBomb) { ThrowBomb(combatant); @@ -116,11 +116,11 @@ namespace Server.Mobiles if (Utility.RandomDouble() <= 0.75 && m_Thrown % 2 == 1) // 75% chance to quickly throw another bomb { - m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(3.0); + m_NextBomb = Core.Now + TimeSpan.FromSeconds(3.0); } else { - m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(5.0 + 10.0 * Utility.RandomDouble()); // 5-15 seconds + m_NextBomb = Core.Now + TimeSpan.FromSeconds(5.0 + 10.0 * Utility.RandomDouble()); // 5-15 seconds } } } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs index dbf31f060..8f5405bf5 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs @@ -71,7 +71,7 @@ namespace Server.Mobiles PackItem(Seed.RandomPeculiarSeed(4)); } - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } public JukaMage(Serial serial) : base(serial) @@ -101,7 +101,7 @@ namespace Server.Mobiles public override void OnThink() { - if (DateTime.UtcNow >= m_NextAbilityTime) + if (Core.Now >= m_NextAbilityTime) { JukaLord toBuff = null; @@ -119,7 +119,7 @@ namespace Server.Mobiles { if (CanBeBeneficial(toBuff) && toBuff.BeginAction()) { - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60)); toBuff.Say(true, "Give me the power to destroy my enemies!"); Say(true, "Fight well my lord!"); @@ -169,7 +169,7 @@ namespace Server.Mobiles } else { - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs index b0c9beddb..24cbc389d 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs @@ -81,7 +81,7 @@ namespace Server.Mobiles AddItem(new Crossbow()); PackItem(pack); - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } public MeerCaptain(Serial serial) : base(serial) @@ -116,9 +116,9 @@ namespace Server.Mobiles PlaySound(0x1E9); } - if (DateTime.UtcNow >= m_NextAbilityTime) + if (Core.Now >= m_NextAbilityTime) { - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(10, 15)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(10, 15)); var eable = GetMobilesInRange(8); diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs index 7adefd005..ddf4808d0 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles VirtualArmor = 34; - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } public MeerEternal(Serial serial) : base(serial) @@ -159,13 +159,13 @@ namespace Server.Mobiles public override void OnThink() { - if (DateTime.UtcNow >= m_NextAbilityTime) + if (Core.Now >= m_NextAbilityTime) { var combatant = Combatant; if (combatant != null && combatant.Map == Map && combatant.InRange(this, 12)) { - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(10, 15)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(10, 15)); var ability = Utility.Random(4); diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs index 2bdd5cbd6..c3dfab7d3 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs @@ -44,7 +44,7 @@ namespace Server.Mobiles VirtualArmor = 16; - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } public MeerMage(Serial serial) : base(serial) @@ -76,14 +76,14 @@ namespace Server.Mobiles public override void OnThink() { - if (DateTime.UtcNow >= m_NextAbilityTime) + if (Core.Now >= m_NextAbilityTime) { var combatant = Combatant; if (combatant != null && combatant.Map == Map && combatant.InRange(this, 12) && IsEnemy(combatant) && !UnderEffect(combatant)) { - m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)); + m_NextAbilityTime = Core.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)); if (combatant is BaseCreature bc) { diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs index eeba762e7..d3a1589ae 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs @@ -94,7 +94,7 @@ namespace Server.Mobiles public void AreaPeace() { - if (Combatant == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + if (Combatant == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() > 0.1) { return; } @@ -105,24 +105,24 @@ namespace Server.Mobiles { if (m is PlayerMobile pm && IsValidTarget(pm)) { - pm.PeacedUntil = DateTime.UtcNow + duration; + pm.PeacedUntil = Core.Now + duration; m.SendLocalizedMessage(1072065); // You gaze upon the dryad's beauty, and forget to continue battling! m.FixedParticles(0x376A, 1, 20, 0x7F5, EffectLayer.Waist); m.Combatant = null; } } - m_NextPeace = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_NextPeace = Core.Now + TimeSpan.FromSeconds(10); PlaySound(0x1D3); } public bool IsValidTarget(PlayerMobile m) => - m?.PeacedUntil < DateTime.UtcNow && !m.Hidden && m.AccessLevel == AccessLevel.Player && + m?.PeacedUntil < Core.Now && !m.Hidden && m.AccessLevel == AccessLevel.Player && CanBeHarmful(m); public void AreaUndress() { - if (Combatant == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) + if (Combatant == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() > 0.005) { return; } @@ -144,7 +144,7 @@ namespace Server.Mobiles } } - m_NextUndress = DateTime.UtcNow + TimeSpan.FromMinutes(1); + m_NextUndress = Core.Now + TimeSpan.FromMinutes(1); } public void UndressItem(Mobile m, Layer layer) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs index 30dbf68b7..38ff955e2 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs @@ -90,14 +90,14 @@ namespace Server.Mobiles public void Peace(Mobile target) { - if (target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + if (target == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() > 0.1) { return; } - if (target is PlayerMobile p && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful(p)) + if (target is PlayerMobile p && p.PeacedUntil < Core.Now && !p.Hidden && CanBeHarmful(p)) { - p.PeacedUntil = DateTime.UtcNow + TimeSpan.FromMinutes(1); + p.PeacedUntil = Core.Now + TimeSpan.FromMinutes(1); p.SendLocalizedMessage(500616); // You hear lovely music, and forget to continue battling! p.FixedParticles(0x376A, 1, 32, 0x15BD, EffectLayer.Waist); p.Combatant = null; @@ -105,13 +105,13 @@ namespace Server.Mobiles PlaySound(0x58D); } - m_NextPeace = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_NextPeace = Core.Now + TimeSpan.FromSeconds(10); } public void Suppress(Mobile target) { if (target == null || m_Suppressed.ContainsKey(target) || Deleted || !Alive || - m_NextSuppress > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + m_NextSuppress > Core.Now || Utility.RandomDouble() > 0.1) { return; } @@ -137,7 +137,7 @@ namespace Server.Mobiles PlaySound(0x58C); } - m_NextSuppress = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_NextSuppress = Core.Now + TimeSpan.FromSeconds(10); } public static void SuppressRemove(Mobile target) @@ -160,7 +160,7 @@ namespace Server.Mobiles public void Undress(Mobile target) { - if (target == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) + if (target == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() > 0.005) { return; } @@ -178,7 +178,7 @@ namespace Server.Mobiles ); // The satyr's music makes your blood race. Your clothing is too confining. } - m_NextUndress = DateTime.UtcNow + TimeSpan.FromMinutes(1); + m_NextUndress = Core.Now + TimeSpan.FromMinutes(1); } public void UndressItem(Mobile m, Layer layer) @@ -193,7 +193,7 @@ namespace Server.Mobiles public void Provoke(Mobile target) { - if (target == null || Deleted || !Alive || m_NextProvoke > DateTime.UtcNow || Utility.RandomDouble() > 0.05) + if (target == null || Deleted || !Alive || m_NextProvoke > Core.Now || Utility.RandomDouble() > 0.05) { return; } @@ -220,7 +220,7 @@ namespace Server.Mobiles } } - m_NextProvoke = DateTime.UtcNow + TimeSpan.FromSeconds(10); + m_NextProvoke = Core.Now + TimeSpan.FromSeconds(10); } private class AnimateTimer : Timer diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs index 9ac704405..c57b62524 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs @@ -98,7 +98,7 @@ namespace Server.Mobiles if (value != null) { Morph(value); - m_LastMorph = DateTime.UtcNow; + m_LastMorph = Core.Now; } m_MorphedInto = value; @@ -128,10 +128,10 @@ namespace Server.Mobiles if (Combatant != null) { - if (m_NextFireRing <= DateTime.UtcNow && Utility.RandomDouble() < 0.02) + if (m_NextFireRing <= Core.Now && Utility.RandomDouble() < 0.02) { FireRing(); - m_NextFireRing = DateTime.UtcNow + TimeSpan.FromMinutes(2); + m_NextFireRing = Core.Now + TimeSpan.FromMinutes(2); } if (Combatant.Player && m_MorphedInto != Combatant && Utility.RandomDouble() < 0.05) @@ -145,7 +145,7 @@ namespace Server.Mobiles { var idle = base.CheckIdle(); - if (idle && m_MorphedInto != null && DateTime.UtcNow - m_LastMorph > TimeSpan.FromSeconds(30)) + if (idle && m_MorphedInto != null && Core.Now - m_LastMorph > TimeSpan.FromSeconds(30)) { MorphedInto = null; } diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs index 70d16037c..1a1317ea0 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs @@ -68,10 +68,10 @@ namespace Server.Mobiles { if (!from.Alive && from is PlayerMobile) { - if (!from.Frozen && DateTime.UtcNow >= m_NextResurrect && InRange(from, 4) && !InRange(oldLocation, 4) && + if (!from.Frozen && Core.Now >= m_NextResurrect && InRange(from, 4) && !InRange(oldLocation, 4) && InLOS(from)) { - m_NextResurrect = DateTime.UtcNow + ResurrectDelay; + m_NextResurrect = Core.Now + ResurrectDelay; if (!from.Criminal && from.Kills < 5 && from.Karma > 0) { if (from.Map?.CanFit(from.Location, 16, false, false) == true) diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs index b2254aed4..e1ca92246 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles public PlagueSpawn(Mobile owner = null) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Owner = owner; - ExpireTime = DateTime.UtcNow + TimeSpan.FromMinutes(1.0); + ExpireTime = Core.Now + TimeSpan.FromMinutes(1.0); Hue = Utility.Random(0x11, 15); @@ -102,7 +102,7 @@ namespace Server.Mobiles public override void OnThink() { - if (Owner != null && (DateTime.UtcNow >= ExpireTime || Owner.Deleted || Map != Owner.Map || !InRange(Owner, 16))) + if (Owner != null && (Core.Now >= ExpireTime || Owner.Deleted || Map != Owner.Map || !InRange(Owner, 16))) { PlaySound(GetIdleSound()); Delete(); diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs index 21d72b10e..c3e320356 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs @@ -63,10 +63,10 @@ namespace Server.Mobiles return; } - if (DateTime.UtcNow >= m_NextAttack) + if (Core.Now >= m_NextAttack) { SandAttack(combatant); - m_NextAttack = DateTime.UtcNow + TimeSpan.FromSeconds(10.0 + 10.0 * Utility.RandomDouble()); + m_NextAttack = Core.Now + TimeSpan.FromSeconds(10.0 + 10.0 * Utility.RandomDouble()); } } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index f803b67bd..5f10144d7 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -289,39 +289,19 @@ namespace Server.Mobiles [CommandProperty(AccessLevel.GameMaster)] public TimeSpan SavagePaintExpiration { - get - { - var ts = m_SavagePaintExpiration - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - return ts; - } - set => m_SavagePaintExpiration = DateTime.UtcNow + value; + get => Utility.Max(m_SavagePaintExpiration - Core.Now, TimeSpan.Zero); + set => m_SavagePaintExpiration = Core.Now + value; } [CommandProperty(AccessLevel.GameMaster)] public TimeSpan NextSmithBulkOrder { - get - { - var ts = m_NextSmithBulkOrder - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - return ts; - } + get => Utility.Max(m_NextSmithBulkOrder - Core.Now, TimeSpan.Zero); set { try { - m_NextSmithBulkOrder = DateTime.UtcNow + value; + m_NextSmithBulkOrder = Core.Now + value; } catch { @@ -333,22 +313,12 @@ namespace Server.Mobiles [CommandProperty(AccessLevel.GameMaster)] public TimeSpan NextTailorBulkOrder { - get - { - var ts = m_NextTailorBulkOrder - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } - - return ts; - } + get => Utility.Max(m_NextTailorBulkOrder - Core.Now, TimeSpan.Zero); set { try { - m_NextTailorBulkOrder = DateTime.UtcNow + value; + m_NextTailorBulkOrder = Core.Now + value; } catch { @@ -381,7 +351,7 @@ namespace Server.Mobiles { if (NetState != null) { - return m_GameTime + (DateTime.UtcNow - SessionStart); + return m_GameTime + (Core.Now - SessionStart); } return m_GameTime; @@ -1140,7 +1110,7 @@ namespace Server.Mobiles } } - if (m_MountBlock?.m_Timer.Running != true || m_MountBlock.m_Timer.Next < DateTime.UtcNow + duration) + if (m_MountBlock?.m_Timer.Running != true || m_MountBlock.m_Timer.Next < Core.Now + duration) { m_MountBlock = new MountBlock(duration, type, this); } @@ -1568,12 +1538,12 @@ namespace Server.Mobiles { if (m is PlayerMobile pm) { - pm.SessionStart = DateTime.UtcNow; + pm.SessionStart = Core.Now; pm.Quest?.StartTimer(); pm.BedrollLogout = false; - pm.LastOnline = DateTime.UtcNow; + pm.LastOnline = Core.Now; } DisguiseTimers.StartTimer(m); @@ -1615,13 +1585,13 @@ namespace Server.Mobiles if (from is PlayerMobile pm) { - pm.m_GameTime += DateTime.UtcNow - pm.SessionStart; + pm.m_GameTime += Core.Now - pm.SessionStart; pm.Quest?.StopTimer(); pm.SpeechLog = null; pm.ClearQuestArrow(); - pm.LastOnline = DateTime.UtcNow; + pm.LastOnline = Core.Now; } DisguiseTimers.StopTimer(from); @@ -2661,7 +2631,7 @@ namespace Server.Mobiles } } - if (Kills >= 5 && DateTime.UtcNow >= m_NextJustAward) + if (Kills >= 5 && Core.Now >= m_NextJustAward) { var m = FindMostRecentDamager(false); @@ -2694,7 +2664,7 @@ namespace Server.Mobiles m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist); m.PlaySound(0x1F7); - m_NextJustAward = DateTime.UtcNow + TimeSpan.FromMinutes(pointsToGain / 3.0); + m_NextJustAward = Core.Now + TimeSpan.FromMinutes(pointsToGain / 3.0); } } } @@ -2949,7 +2919,7 @@ namespace Server.Mobiles if (tbl.TryGetValue(obj, out var count)) { - if (count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow) + if (count.TimeStamp + SkillCheck.AntiMacroExpire <= Core.Now) { count.Count = 1; return true; @@ -3292,7 +3262,7 @@ namespace Server.Mobiles foreach (var (k, v) in t) { - if (v.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow) + if (v.TimeStamp + SkillCheck.AntiMacroExpire <= Core.Now) { toRemove.Add(k); } @@ -4132,7 +4102,7 @@ namespace Server.Mobiles for (var i = 0; i < m_StuckMenuUses.Length; ++i) { - if (DateTime.UtcNow - m_StuckMenuUses[i] > TimeSpan.FromDays(1.0)) + if (Core.Now - m_StuckMenuUses[i] > TimeSpan.FromDays(1.0)) { return true; } @@ -4150,9 +4120,9 @@ namespace Server.Mobiles for (var i = 0; i < m_StuckMenuUses.Length; ++i) { - if (DateTime.UtcNow - m_StuckMenuUses[i] > TimeSpan.FromDays(1.0)) + if (Core.Now - m_StuckMenuUses[i] > TimeSpan.FromDays(1.0)) { - m_StuckMenuUses[i] = DateTime.UtcNow; + m_StuckMenuUses[i] = Core.Now; return; } } @@ -4428,9 +4398,9 @@ namespace Server.Mobiles return false; } - if (DateTime.UtcNow - m_LastYoungMessage > TimeSpan.FromMinutes(1.0)) + if (Core.Now - m_LastYoungMessage > TimeSpan.FromMinutes(1.0)) { - m_LastYoungMessage = DateTime.UtcNow; + m_LastYoungMessage = Core.Now; // A monster looks at you menacingly but does not attack. // You would be under attack now if not for your status as a new citizen of Britannia. SendLocalizedMessage(1019067); @@ -4441,9 +4411,9 @@ namespace Server.Mobiles public bool CheckYoungHealTime() { - if (DateTime.UtcNow - m_LastYoungHeal > TimeSpan.FromMinutes(5.0)) + if (Core.Now - m_LastYoungHeal > TimeSpan.FromMinutes(5.0)) { - m_LastYoungHeal = DateTime.UtcNow; + m_LastYoungHeal = Core.Now; return true; } @@ -4658,7 +4628,7 @@ namespace Server.Mobiles set { m_Count = value; - TimeStamp = DateTime.UtcNow; + TimeStamp = Core.Now; } } } diff --git a/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs b/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs index 97f2d53e7..6c3e06a11 100644 --- a/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs +++ b/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs @@ -284,10 +284,10 @@ namespace Server.Mobiles return false; } - if (m is PlayerMobile mobile && mobile.LastEscortTime + EscortDelay >= DateTime.UtcNow) + if (m is PlayerMobile mobile && mobile.LastEscortTime + EscortDelay >= Core.Now) { var minutes = - (int)Math.Ceiling((mobile.LastEscortTime + EscortDelay - DateTime.UtcNow).TotalMinutes); + (int)Math.Ceiling((mobile.LastEscortTime + EscortDelay - Core.Now).TotalMinutes); Say("You must rest {0} minute{1} before we set out on this journey.", minutes, minutes == 1 ? "" : "s"); return false; @@ -295,11 +295,11 @@ namespace Server.Mobiles if (SetControlMaster(m)) { - m_LastSeenEscorter = DateTime.UtcNow; + m_LastSeenEscorter = Core.Now; if (m is PlayerMobile playerMobile) { - playerMobile.LastEscortTime = DateTime.UtcNow; + playerMobile.LastEscortTime = Core.Now; } Say( @@ -420,7 +420,7 @@ namespace Server.Mobiles { StopFollow(); - var lastSeenDelay = DateTime.UtcNow - m_LastSeenEscorter; + var lastSeenDelay = Core.Now - m_LastSeenEscorter; if (lastSeenDelay >= AbandonDelay) { @@ -443,7 +443,7 @@ namespace Server.Mobiles StartFollow(master); } - m_LastSeenEscorter = DateTime.UtcNow; + m_LastSeenEscorter = Core.Now; return master; } @@ -451,9 +451,9 @@ namespace Server.Mobiles { m_DeleteTimer?.Stop(); - m_DeleteTime = DateTime.UtcNow + DeleteTime; + m_DeleteTime = Core.Now + DeleteTime; - m_DeleteTimer = new DeleteTimer(this, m_DeleteTime - DateTime.UtcNow); + m_DeleteTimer = new DeleteTimer(this, m_DeleteTime - Core.Now); m_DeleteTimer.Start(); } @@ -509,7 +509,7 @@ namespace Server.Mobiles if (escorter is PlayerMobile pm) { - if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay) + if (pm.CompassionGains > 0 && Core.Now > pm.NextCompassionDay) { pm.NextCompassionDay = DateTime.MinValue; pm.CompassionGains = 0; @@ -533,7 +533,7 @@ namespace Server.Mobiles } pm.NextCompassionDay = - DateTime.UtcNow + TimeSpan.FromDays(1.0); // in one day CompassionGains gets reset to 0 + Core.Now + TimeSpan.FromDays(1.0); // in one day CompassionGains gets reset to 0 ++pm.CompassionGains; if (pm.CompassionGains >= 5) @@ -604,7 +604,7 @@ namespace Server.Mobiles if (reader.ReadBool()) { m_DeleteTime = reader.ReadDeltaTime(); - m_DeleteTimer = new DeleteTimer(this, m_DeleteTime - DateTime.UtcNow); + m_DeleteTimer = new DeleteTimer(this, m_DeleteTime - Core.Now); m_DeleteTimer.Start(); } diff --git a/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs b/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs index 9d5ab2522..09399e9fd 100644 --- a/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs +++ b/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs @@ -102,23 +102,14 @@ namespace Server.Mobiles { Lines = lines; - if (duration < TimeSpan.Zero) - { - duration = TimeSpan.Zero; - } - else if (duration > TimeSpan.FromDays(365.0)) - { - duration = TimeSpan.FromDays(365.0); - } - - ExpireTime = DateTime.UtcNow + duration; + ExpireTime = Core.Now + duration.Clamp(TimeSpan.Zero, TimeSpan.FromDays(365)); } public string[] Lines { get; } public DateTime ExpireTime { get; } - public bool Expired => DateTime.UtcNow >= ExpireTime; + public bool Expired => Core.Now >= ExpireTime; } public class TownCrierDurationPrompt : Prompt @@ -242,12 +233,7 @@ namespace Server.Mobiles { var tce = entries[i]; - var toExpire = tce.ExpireTime - DateTime.UtcNow; - - if (toExpire < TimeSpan.Zero) - { - toExpire = TimeSpan.Zero; - } + var toExpire = Utility.Max(tce.ExpireTime - Core.Now, TimeSpan.Zero); var sb = new StringBuilder(); @@ -301,12 +287,7 @@ namespace Server.Mobiles if (index < entries?.Count) { var tce = entries[index]; - var ts = tce.ExpireTime - DateTime.UtcNow; - - if (ts < TimeSpan.Zero) - { - ts = TimeSpan.Zero; - } + var ts = Utility.Max(tce.ExpireTime - Core.Now, TimeSpan.Zero); m_From.SendMessage("Editing entry #{0}.", index + 1); m_From.SendMessage("Enter the first line to shout:"); diff --git a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs index 072401ba0..98886e967 100644 --- a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs @@ -45,7 +45,7 @@ namespace Server.Mobiles pack = new Backpack { Layer = Layer.ShopResale, Movable = false, Visible = false }; AddItem(pack); - LastRestock = DateTime.UtcNow; + LastRestock = Core.Now; } public BaseVendor(Serial serial) @@ -97,7 +97,7 @@ namespace Server.Mobiles public virtual void Restock() { - LastRestock = DateTime.UtcNow; + LastRestock = Core.Now; var buyInfo = GetBuyInfo(); @@ -565,7 +565,7 @@ namespace Server.Mobiles protected void LoadSBInfo() { - LastRestock = DateTime.UtcNow; + LastRestock = Core.Now; for (var i = 0; i < m_ArmorBuyInfo.Count; ++i) { @@ -840,7 +840,7 @@ namespace Server.Mobiles return; } - if (DateTime.UtcNow - LastRestock > RestockDelay) + if (Core.Now - LastRestock > RestockDelay) { Restock(); } @@ -900,7 +900,7 @@ namespace Server.Mobiles var item = playerItems[i]; - if (item.LastMoved + InventoryDecayTime <= DateTime.UtcNow) + if (item.LastMoved + InventoryDecayTime <= Core.Now) { item.Delete(); } @@ -1064,7 +1064,7 @@ namespace Server.Mobiles var pm = from as PlayerMobile; - if (Core.ML && pm?.NextBODTurnInTime > DateTime.UtcNow) + if (Core.ML && pm?.NextBODTurnInTime > Core.Now) { SayTo(from, 1079976); // You'll have to wait a few seconds while I inspect the last order. return false; @@ -1118,7 +1118,7 @@ namespace Server.Mobiles if (Core.ML && pm != null) { - pm.NextBODTurnInTime = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + pm.NextBODTurnInTime = Core.Now + TimeSpan.FromSeconds(10.0); } dropped.Delete(); diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs index 10873c8b8..73056c170 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs @@ -94,7 +94,7 @@ namespace Server.Mobiles { SayTo(pm, 501046); // Thou must resign from thy other guild first. } - else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow) + else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > Core.Now) { SayTo(pm, 501048); // You are too young to join my guild... } @@ -111,7 +111,7 @@ namespace Server.Mobiles { SayTo(pm, 501052); // Thou dost not belong to my guild! } - else if (pm.NpcGuildJoinTime + QuitAge > DateTime.UtcNow || + else if (pm.NpcGuildJoinTime + QuitAge > Core.Now || pm.NpcGuildGameTime + QuitGameAge > pm.GameTime) { SayTo(pm, 501053); // You just joined my guild! You must wait a week to resign. @@ -141,7 +141,7 @@ namespace Server.Mobiles { SayTo(pm, 501046); // Thou must resign from thy other guild first. } - else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow) + else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > Core.Now) { SayTo(pm, 501048); // You are too young to join my guild... } @@ -150,7 +150,7 @@ namespace Server.Mobiles SayWelcomeTo(pm); pm.NpcGuild = NpcGuild; - pm.NpcGuildJoinTime = DateTime.UtcNow; + pm.NpcGuildJoinTime = Core.Now; pm.NpcGuildGameTime = pm.GameTime; dropped.Delete(); diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs b/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs index 630dd95c4..493f1a225 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs @@ -34,13 +34,13 @@ namespace Server.Mobiles public override void OnMovement(Mobile m, Point3D oldLocation) { - if (DateTime.UtcNow > m_NextCheckPack && InRange(m, 4) && !InRange(oldLocation, 4) && m.Player) + if (Core.Now > m_NextCheckPack && InRange(m, 4) && !InRange(oldLocation, 4) && m.Player) { var pack = m.Backpack; if (pack != null) { - m_NextCheckPack = DateTime.UtcNow + TimeSpan.FromSeconds(2.0); + m_NextCheckPack = Core.Now + TimeSpan.FromSeconds(2.0); if (pack.FindItemByType(false) != null) { diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Scribe.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Scribe.cs index a6b0d2326..05a0a310a 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Scribe.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Scribe.cs @@ -47,14 +47,14 @@ namespace Server.Mobiles { base.OnSpeech(e); - if (!e.Handled && m_NextShush <= DateTime.UtcNow && InLOS(e.Mobile)) + if (!e.Handled && m_NextShush <= Core.Now && InLOS(e.Mobile)) { Direction = GetDirectionTo(e.Mobile); PlaySound(Female ? 0x32F : 0x441); PublicOverheadMessage(MessageType.Regular, 0x3B2, 1073990); // Shhhh! - m_NextShush = DateTime.UtcNow + ShushDelay; + m_NextShush = Core.Now + ShushDelay; e.Handled = true; } } diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs index 04ed341e0..16fa11acf 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs @@ -306,7 +306,7 @@ namespace Server.Mobiles m_PayTimer = new PayTimer(this, delay); m_PayTimer.Start(); - NextPayTime = DateTime.UtcNow + delay; + NextPayTime = Core.Now + delay; } public PlayerVendor(Serial serial) : base(serial) @@ -454,7 +454,7 @@ namespace Server.Mobiles var description = reader.ReadString(); - var created = version < 1 ? DateTime.UtcNow : reader.ReadDateTime(); + var created = version < 1 ? Core.Now : reader.ReadDateTime(); if (item != null) { @@ -480,7 +480,7 @@ namespace Server.Mobiles Timer.DelayCall(FixDresswear); } - NextPayTime = DateTime.UtcNow + PayTimer.GetInterval(); + NextPayTime = Core.Now + PayTimer.GetInterval(); if (newVendorSystemActivated) { @@ -494,7 +494,7 @@ namespace Server.Mobiles InitStats(100, 100, 25); } - var delay = NextPayTime - DateTime.UtcNow; + var delay = NextPayTime - Core.Now; m_PayTimer = new PayTimer(this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero); m_PayTimer.Start(); @@ -752,7 +752,7 @@ namespace Server.Mobiles } private VendorItem SetVendorItem(Item item, int price, string description) => - SetVendorItem(item, price, description, DateTime.UtcNow); + SetVendorItem(item, price, description, Core.Now); private VendorItem SetVendorItem(Item item, int price, string description, DateTime created) { @@ -1064,7 +1064,7 @@ namespace Server.Mobiles { vendor.SayTo(from, 503202); // This item is not for sale. } - else if (vi.Created + TimeSpan.FromMinutes(1.0) > DateTime.UtcNow) + else if (vi.Created + TimeSpan.FromMinutes(1.0) > Core.Now) { from.SendMessage("You cannot buy this item right now. Please wait one minute and try again."); } @@ -1368,7 +1368,7 @@ namespace Server.Mobiles protected override void OnTick() { - m_Vendor.NextPayTime = DateTime.UtcNow + Interval; + m_Vendor.NextPayTime = Core.Now + Interval; int pay; int totalGold; diff --git a/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs b/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs index 3d248891b..08c3f6244 100644 --- a/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs @@ -61,7 +61,7 @@ namespace Server.Mobiles RentalGold = rentalGold; - RentalExpireTime = DateTime.UtcNow + duration.Duration; + RentalExpireTime = Core.Now + duration.Duration; m_RentalExpireTimer = new RentalExpireTimer(this, duration.Duration); m_RentalExpireTimer.Start(); } @@ -103,7 +103,7 @@ namespace Server.Mobiles public void ComputeRentalExpireDelay(out int days, out int hours) { - var delay = RentalExpireTime - DateTime.UtcNow; + var delay = RentalExpireTime - Core.Now; if (delay <= TimeSpan.Zero) { @@ -213,7 +213,7 @@ namespace Server.Mobiles RentalExpireTime = reader.ReadDeltaTime(); - var delay = RentalExpireTime - DateTime.UtcNow; + var delay = RentalExpireTime - Core.Now; m_RentalExpireTimer = new RentalExpireTimer(this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero); m_RentalExpireTimer.Start(); } @@ -380,7 +380,7 @@ namespace Server.Mobiles m_Vendor.RentalPrice = renewalPrice; - m_Vendor.RentalExpireTime = DateTime.UtcNow + m_Vendor.RentalDuration.Duration; + m_Vendor.RentalExpireTime = Core.Now + m_Vendor.RentalDuration.Duration; } else { diff --git a/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs b/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs index d1ca56fa9..528f8bf31 100644 --- a/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs +++ b/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs @@ -19,7 +19,7 @@ namespace Server.Mobiles Items = new List(); - ExpireTime = DateTime.UtcNow + GracePeriod; + ExpireTime = Core.Now + GracePeriod; m_ExpireTimer = new ExpireTimer(this, GracePeriod); m_ExpireTimer.Start(); } @@ -45,7 +45,7 @@ namespace Server.Mobiles } else { - var delay = ExpireTime - DateTime.UtcNow; + var delay = ExpireTime - Core.Now; m_ExpireTimer = new ExpireTimer(this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero); m_ExpireTimer.Start(); } diff --git a/Projects/UOContent/Multis/Boats/BaseBoat.cs b/Projects/UOContent/Multis/Boats/BaseBoat.cs index e339342b3..9421dba90 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoat.cs @@ -75,7 +75,7 @@ namespace Server.Multis public BaseBoat() : base(0x0) { - m_DecayTime = DateTime.UtcNow + BoatDecayDelay; + m_DecayTime = Core.Now + BoatDecayDelay; TillerMan = new TillerMan(this); Hold = new Hold(this); @@ -168,29 +168,29 @@ namespace Server.Multis { get { - var start = TimeOfDecay - BoatDecayDelay; + var start = Core.Now - TimeOfDecay - BoatDecayDelay; - if (DateTime.UtcNow - start < TimeSpan.FromHours(1.0)) + if (start < TimeSpan.FromHours(1.0)) { return 1043010; // This structure is like new. } - if (DateTime.UtcNow - start < TimeSpan.FromDays(2.0)) + if (start < TimeSpan.FromDays(2.0)) { return 1043011; // This structure is slightly worn. } - if (DateTime.UtcNow - start < TimeSpan.FromDays(3.0)) + if (start < TimeSpan.FromDays(3.0)) { return 1043012; // This structure is somewhat worn. } - if (DateTime.UtcNow - start < TimeSpan.FromDays(4.0)) + if (start < TimeSpan.FromDays(4.0)) { return 1043013; // This structure is fairly worn. } - if (DateTime.UtcNow - start < TimeSpan.FromDays(5.0)) + if (start < TimeSpan.FromDays(5.0)) { return 1043014; // This structure is greatly worn. } @@ -527,7 +527,7 @@ namespace Server.Multis public void Refresh() { - m_DecayTime = DateTime.UtcNow + BoatDecayDelay; + m_DecayTime = Core.Now + BoatDecayDelay; TillerMan?.InvalidateProperties(); } @@ -539,7 +539,7 @@ namespace Server.Multis return true; } - if (!IsMoving && DateTime.UtcNow >= m_DecayTime) + if (!IsMoving && Core.Now >= m_DecayTime) { new DecayTimer(this).Start(); diff --git a/Projects/UOContent/Multis/Camps/BaseCamp.cs b/Projects/UOContent/Multis/Camps/BaseCamp.cs index c0adb37e0..66dc066e6 100644 --- a/Projects/UOContent/Multis/Camps/BaseCamp.cs +++ b/Projects/UOContent/Multis/Camps/BaseCamp.cs @@ -66,7 +66,7 @@ namespace Server.Multis if (setDecayTime) { - m_DecayTime = DateTime.UtcNow + DecayDelay; + m_DecayTime = Core.Now + DecayDelay; } m_DecayTimer = Timer.DelayCall(DecayDelay, Delete); diff --git a/Projects/UOContent/Multis/Houses/BaseHouse.cs b/Projects/UOContent/Multis/Houses/BaseHouse.cs index b4996ddd8..ad5469b99 100644 --- a/Projects/UOContent/Multis/Houses/BaseHouse.cs +++ b/Projects/UOContent/Multis/Houses/BaseHouse.cs @@ -43,9 +43,9 @@ namespace Server.Multis { AllHouses.Add(this); - LastRefreshed = DateTime.UtcNow; + LastRefreshed = Core.Now; - BuiltOn = DateTime.UtcNow; + BuiltOn = Core.Now; LastTraded = DateTime.MinValue; Doors = new List(); @@ -203,14 +203,14 @@ namespace Server.Multis ResetDynamicDecay(); } - LastRefreshed = DateTime.UtcNow; + LastRefreshed = Core.Now; result = DecayLevel.Ageless; } else if (DynamicDecay.Enabled) { var stage = m_CurrentStage; - if (stage == DecayLevel.Ageless || DynamicDecay.Decays(stage) && NextDecayStage <= DateTime.UtcNow) + if (stage == DecayLevel.Ageless || DynamicDecay.Decays(stage) && NextDecayStage <= Core.Now) { SetDynamicDecay(++stage); } @@ -531,7 +531,7 @@ namespace Server.Multis public DecayLevel GetOldDecayLevel() { - var timeAfterRefresh = DateTime.UtcNow - LastRefreshed; + var timeAfterRefresh = Core.Now - LastRefreshed; var percent = (int)(timeAfterRefresh.Ticks * 1000 / DecayPeriod.Ticks); if (percent >= 1000) // 100.0% @@ -576,7 +576,7 @@ namespace Server.Multis var oldLevel = DecayLevel; - LastRefreshed = DateTime.UtcNow; + LastRefreshed = Core.Now; if (DynamicDecay.Enabled) { @@ -2416,7 +2416,7 @@ namespace Server.Multis var info = m.Aggressed[i]; if (info.Defender.Player && info.Defender.Alive && - DateTime.UtcNow - info.LastCombatTime < HouseRegion.CombatHeatDelay && + Core.Now - info.LastCombatTime < HouseRegion.CombatHeatDelay && (!(m.Guild is Guild attackerGuild) || !(info.Defender.Guild is Guild defenderGuild) || defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild))) { @@ -2935,7 +2935,7 @@ namespace Server.Multis var child = children[j]; if (child.Decays && !child.IsLockedDown && !child.IsSecure && - child.LastMoved + child.DecayTime <= DateTime.UtcNow) + child.LastMoved + child.DecayTime <= Core.Now) { Timer.DelayCall(child.Delete); } @@ -3176,7 +3176,7 @@ namespace Server.Multis if (version < 11) { - LastRefreshed = DateTime.UtcNow + TimeSpan.FromHours(24 * Utility.RandomDouble()); + LastRefreshed = Core.Now + TimeSpan.FromHours(24 * Utility.RandomDouble()); } if (DynamicDecay.Enabled && !loadedDynamicDecay) @@ -3633,7 +3633,7 @@ namespace Server.Multis if (DynamicDecay.Decays(level)) { - NextDecayStage = DateTime.UtcNow + DynamicDecay.GetRandomDuration(level); + NextDecayStage = Core.Now + DynamicDecay.GetRandomDuration(level); } else { @@ -3764,7 +3764,7 @@ namespace Server.Multis m_House.Friends.Clear(); m_House.CoOwners.Clear(); m_House.ChangeLocks(to); - m_House.LastTraded = DateTime.UtcNow; + m_House.LastTraded = Core.Now; } } diff --git a/Projects/UOContent/Multis/Houses/HouseSign.cs b/Projects/UOContent/Multis/Houses/HouseSign.cs index 66c084d1e..257c81e98 100644 --- a/Projects/UOContent/Multis/Houses/HouseSign.cs +++ b/Projects/UOContent/Multis/Houses/HouseSign.cs @@ -146,7 +146,7 @@ namespace Server.Multis if (canClaim && !BaseHouse.HasAccountHouse(from)) { Owner.Owner = from; - Owner.LastTraded = DateTime.UtcNow; + Owner.LastTraded = Core.Now; } } diff --git a/Projects/UOContent/Regions/HouseRegion.cs b/Projects/UOContent/Regions/HouseRegion.cs index 6055f5888..0e170b7e4 100644 --- a/Projects/UOContent/Regions/HouseRegion.cs +++ b/Projects/UOContent/Regions/HouseRegion.cs @@ -211,7 +211,7 @@ namespace Server.Regions public override TimeSpan GetLogoutDelay(Mobile m) => House.IsFriend(m) && House.IsInside(m) - ? m.Aggressed.Any(info => info.Defender.Player && DateTime.UtcNow - info.LastCombatTime < CombatHeatDelay) ? + ? m.Aggressed.Any(info => info.Defender.Player && Core.Now - info.LastCombatTime < CombatHeatDelay) ? base.GetLogoutDelay(m) : TimeSpan.Zero : base.GetLogoutDelay(m); @@ -242,7 +242,7 @@ namespace Server.Regions { from.SendLocalizedMessage(500295); // you are too far away to do that. } - else if (DateTime.UtcNow <= House.BuiltOn.AddHours(1)) + else if (Core.Now <= House.BuiltOn.AddHours(1)) { from.SendLocalizedMessage(1080178); // You must wait one hour between each house demolition. } diff --git a/Projects/UOContent/Skills/AnimalTaming.cs b/Projects/UOContent/Skills/AnimalTaming.cs index afef32f41..5f3be9ef7 100644 --- a/Projects/UOContent/Skills/AnimalTaming.cs +++ b/Projects/UOContent/Skills/AnimalTaming.cs @@ -268,7 +268,7 @@ namespace Server.SkillHandlers } else { - creature.BardEndTime = DateTime.UtcNow; + creature.BardEndTime = Core.Now; } creature.BardPacified = false; @@ -324,7 +324,7 @@ namespace Server.SkillHandlers m_Creature = creature; m_MaxCount = count; m_Paralyzed = creature.Paralyzed; - m_StartTime = DateTime.UtcNow; + m_StartTime = Core.Now; Priority = TimerPriority.TwoFiftyMS; } diff --git a/Projects/UOContent/Skills/Discordance.cs b/Projects/UOContent/Skills/Discordance.cs index 560f3d9aa..e666a0356 100644 --- a/Projects/UOContent/Skills/Discordance.cs +++ b/Projects/UOContent/Skills/Discordance.cs @@ -66,7 +66,7 @@ namespace Server.SkillHandlers } } - if (ends && info.m_Ending && info.m_EndTime < DateTime.UtcNow) + if (ends && info.m_Ending && info.m_EndTime < Core.Now) { info.m_Timer?.Stop(); @@ -78,12 +78,12 @@ namespace Server.SkillHandlers if (ends && !info.m_Ending) { info.m_Ending = true; - info.m_EndTime = DateTime.UtcNow + TimeSpan.FromSeconds(15); + info.m_EndTime = Core.Now + TimeSpan.FromSeconds(15); } else if (!ends) { info.m_Ending = false; - info.m_EndTime = DateTime.UtcNow; + info.m_EndTime = Core.Now; } targ.FixedEffect(0x376A, 1, 32); @@ -104,7 +104,7 @@ namespace Server.SkillHandlers { m_From = from; m_Creature = creature; - m_EndTime = DateTime.UtcNow; + m_EndTime = Core.Now; m_Ending = false; m_Effect = effect; m_Mods = mods; diff --git a/Projects/UOContent/Skills/Inscribe.cs b/Projects/UOContent/Skills/Inscribe.cs index 87733dbbd..452e51a8c 100644 --- a/Projects/UOContent/Skills/Inscribe.cs +++ b/Projects/UOContent/Skills/Inscribe.cs @@ -20,7 +20,7 @@ namespace Server.SkillHandlers Target target = new InternalTargetSrc(); m.Target = target; m.SendLocalizedMessage(1046295); // Target the book you wish to copy. - target.BeginTimeout(m, TimeSpan.FromMinutes(1.0)); + target.BeginTimeout(m, 60000); // 1 minute return TimeSpan.FromSeconds(1.0); } @@ -93,7 +93,7 @@ namespace Server.SkillHandlers Target target = new InternalTargetDst(book); from.Target = target; from.SendLocalizedMessage(501612); // Select a book to copy this to. - target.BeginTimeout(from, TimeSpan.FromMinutes(1.0)); + target.BeginTimeout(from, 60000); // 1 minute SetUser(book, from); } } diff --git a/Projects/UOContent/Skills/Peacemaking.cs b/Projects/UOContent/Skills/Peacemaking.cs index 94812633f..1101c7b21 100644 --- a/Projects/UOContent/Skills/Peacemaking.cs +++ b/Projects/UOContent/Skills/Peacemaking.cs @@ -126,7 +126,7 @@ namespace Server.SkillHandlers if (bc?.BardPacified == false) { - bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0)); + bc.Pacify(from, Core.Now + TimeSpan.FromSeconds(1.0)); } } @@ -210,7 +210,7 @@ namespace Server.SkillHandlers seconds = 10; } - bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds)); + bc.Pacify(from, Core.Now + TimeSpan.FromSeconds(seconds)); } else { diff --git a/Projects/UOContent/Skills/Stealing.cs b/Projects/UOContent/Skills/Stealing.cs index 99bce568e..7a65b98cd 100644 --- a/Projects/UOContent/Skills/Stealing.cs +++ b/Projects/UOContent/Skills/Stealing.cs @@ -185,7 +185,7 @@ namespace Server.SkillHandlers { if (sig.IsBeingCorrupted) { - sig.GraceStart = DateTime.UtcNow; // begin grace period + sig.GraceStart = Core.Now; // begin grace period } m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!! (woah, calm down now) @@ -193,7 +193,7 @@ namespace Server.SkillHandlers if (sig.LastMonolith?.Sigil != null) { sig.LastMonolith.Sigil = null; - sig.LastStolen = DateTime.UtcNow; + sig.LastStolen = Core.Now; } return sig; @@ -429,7 +429,7 @@ namespace Server.SkillHandlers Thief = thief; Victim = victim; - Expires = DateTime.UtcNow + StealTime; + Expires = Core.Now + StealTime; } public Item Stolen { get; } @@ -440,7 +440,7 @@ namespace Server.SkillHandlers public DateTime Expires { get; private set; } - public bool IsExpired => DateTime.UtcNow >= Expires; + public bool IsExpired => Core.Now >= Expires; public static void Add(Item item, Mobile thief, Mobile victim) { @@ -489,7 +489,7 @@ namespace Server.SkillHandlers si.Victim.SendLocalizedMessage(1010463); // the item that was stolen from you falls to the ground. } - si.Expires = DateTime.UtcNow; // such a hack + si.Expires = Core.Now; // such a hack } } } diff --git a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs index c82384ba7..92a9e938f 100644 --- a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs +++ b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs @@ -31,7 +31,7 @@ namespace Server.Misc return; } - var now = DateTime.UtcNow; + var now = Core.Now; for (var i = 0; i < m_Givers.Count; ++i) { diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index e4459ad1b..261dea6f1 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -483,7 +483,7 @@ namespace Server.Spells { Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell. } - else if (Caster is PlayerMobile mobile && mobile.PeacedUntil > DateTime.UtcNow) + else if (Caster is PlayerMobile mobile && mobile.PeacedUntil > Core.Now) { mobile.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed. } @@ -691,7 +691,7 @@ namespace Server.Spells var fcDelay = TimeSpan.FromSeconds(-(CastDelayFastScalar * fc * CastDelaySecondsPerTick)); - return (CastDelayBase + fcDelay).Max(CastDelayMinimum); + return Utility.Max(CastDelayBase + fcDelay, CastDelayMinimum); } public virtual int ComputeKarmaAward() => 0; @@ -723,7 +723,7 @@ namespace Server.Spells Caster.SendLocalizedMessage(502646); // You cannot cast a spell while frozen. DoFizzle(); } - else if (Caster is PlayerMobile mobile && mobile.PeacedUntil > DateTime.UtcNow) + else if (Caster is PlayerMobile mobile && mobile.PeacedUntil > Core.Now) { mobile.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed. DoFizzle(); @@ -924,7 +924,7 @@ namespace Server.Spells if (m_Spell.Caster.Player && m_Spell.Caster.Target != originalTarget) { - m_Spell.Caster.Target?.BeginTimeout(m_Spell.Caster, TimeSpan.FromSeconds(30.0)); + m_Spell.Caster.Target?.BeginTimeout(m_Spell.Caster, 30000); // 30 seconds } m_Spell.m_CastTimer = null; diff --git a/Projects/UOContent/Spells/Base/SpellHelper.cs b/Projects/UOContent/Spells/Base/SpellHelper.cs index d78d0e819..884ba9113 100644 --- a/Projects/UOContent/Spells/Base/SpellHelper.cs +++ b/Projects/UOContent/Spells/Base/SpellHelper.cs @@ -216,7 +216,7 @@ namespace Server.Spells { var info = m.Aggressed[i]; - if (info.Defender.Player && DateTime.UtcNow - info.LastCombatTime < CombatHeatDelay) + if (info.Defender.Player && Core.Now - info.LastCombatTime < CombatHeatDelay) { return true; } @@ -228,7 +228,7 @@ namespace Server.Spells { var info = m.Aggressors[i]; - if (info.Attacker.Player && DateTime.UtcNow - info.LastCombatTime < CombatHeatDelay) + if (info.Attacker.Player && Core.Now - info.LastCombatTime < CombatHeatDelay) { return true; } diff --git a/Projects/UOContent/Spells/Fifth/PoisonField.cs b/Projects/UOContent/Spells/Fifth/PoisonField.cs index 349be5cdb..edcf30ee8 100644 --- a/Projects/UOContent/Spells/Fifth/PoisonField.cs +++ b/Projects/UOContent/Spells/Fifth/PoisonField.cs @@ -103,7 +103,7 @@ namespace Server.Spells.Fifth m_Caster = caster; - m_End = DateTime.UtcNow + duration; + m_End = Core.Now + duration; m_Timer = new InternalTimer(this, TimeSpan.FromSeconds(Math.Abs(val) * 0.2), caster.InLOS(this), canFit); m_Timer.Start(); @@ -267,7 +267,7 @@ namespace Server.Spells.Fifth ); } } - else if (DateTime.UtcNow > m_Item.m_End) + else if (Core.Now > m_Item.m_End) { m_Item.Delete(); Stop(); diff --git a/Projects/UOContent/Spells/Fourth/FireField.cs b/Projects/UOContent/Spells/Fourth/FireField.cs index 4acb576a5..ff8c3c754 100644 --- a/Projects/UOContent/Spells/Fourth/FireField.cs +++ b/Projects/UOContent/Spells/Fourth/FireField.cs @@ -118,7 +118,7 @@ namespace Server.Spells.Fourth m_Damage = damage; - m_End = DateTime.UtcNow + duration; + m_End = Core.Now + duration; m_Timer = new InternalTimer(this, TimeSpan.FromSeconds(Math.Abs(val) * 0.2), caster.InLOS(this), canFit); m_Timer.Start(); @@ -263,7 +263,7 @@ namespace Server.Spells.Fourth ); } } - else if (DateTime.UtcNow > m_Item.m_End) + else if (Core.Now > m_Item.m_End) { m_Item.Delete(); Stop(); diff --git a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs index 41011b085..c1f6fb684 100644 --- a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs @@ -124,7 +124,7 @@ namespace Server.Spells.Necromancy { m_Caster = caster; m_Target = target; - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; Priority = TimerPriority.TwoFiftyMS; } @@ -132,7 +132,7 @@ namespace Server.Spells.Necromancy protected override void OnTick() { if (m_Caster.Deleted || m_Target.Deleted || !m_Caster.Alive || !m_Target.Alive || - DateTime.UtcNow >= m_End) + Core.Now >= m_End) { DoExpire(); } diff --git a/Projects/UOContent/Spells/Necromancy/MindRot.cs b/Projects/UOContent/Spells/Necromancy/MindRot.cs index 9e2585965..f394b087e 100644 --- a/Projects/UOContent/Spells/Necromancy/MindRot.cs +++ b/Projects/UOContent/Spells/Necromancy/MindRot.cs @@ -119,13 +119,13 @@ namespace Server.Spells.Necromancy ) { m_Target = target; - m_End = DateTime.UtcNow + delay; + m_End = Core.Now + delay; Priority = TimerPriority.TwoFiftyMS; } protected override void OnTick() { - if (m_Target.Deleted || !m_Target.Alive || DateTime.UtcNow >= m_End) + if (m_Target.Deleted || !m_Target.Alive || Core.Now >= m_End) { MindRotSpell.ClearMindRotScalar(m_Target); Stop(); diff --git a/Projects/UOContent/Spells/Necromancy/PainSpike.cs b/Projects/UOContent/Spells/Necromancy/PainSpike.cs index 76763e9d0..7687e9d1f 100644 --- a/Projects/UOContent/Spells/Necromancy/PainSpike.cs +++ b/Projects/UOContent/Spells/Necromancy/PainSpike.cs @@ -65,7 +65,7 @@ namespace Server.Spells.Necromancy { damage = Utility.RandomMinMax(3, 7); timer.Delay += TimeSpan.FromSeconds(2.0); - buffTime = timer.Next - DateTime.UtcNow; + buffTime = timer.Next - Core.Now; } BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.PainSpike, 1075667, buffTime, m, Convert.ToString((int)damage))); diff --git a/Projects/UOContent/Spells/Necromancy/Strangle.cs b/Projects/UOContent/Spells/Necromancy/Strangle.cs index cbf61e6b6..78a471d4f 100644 --- a/Projects/UOContent/Spells/Necromancy/Strangle.cs +++ b/Projects/UOContent/Spells/Necromancy/Strangle.cs @@ -153,7 +153,7 @@ namespace Server.Spells.Necromancy m_MaxBaseDamage = spiritLevel + 1; m_HitDelay = 5; - m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay); + m_NextHit = Core.Now + TimeSpan.FromSeconds(m_HitDelay); m_Count = (int)spiritLevel; @@ -173,7 +173,7 @@ namespace Server.Spells.Necromancy Stop(); } - if (!m_Target.Alive || DateTime.UtcNow < m_NextHit) + if (!m_Target.Alive || Core.Now < m_NextHit) { return; } @@ -209,7 +209,7 @@ namespace Server.Spells.Necromancy } else { - m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay); + m_NextHit = Core.Now + TimeSpan.FromSeconds(m_HitDelay); var damage = m_MinBaseDamage + Utility.RandomDouble() * (m_MaxBaseDamage - m_MinBaseDamage); diff --git a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs index 1fdac00c5..d01b7b60e 100644 --- a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs +++ b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs @@ -171,7 +171,7 @@ namespace Server.Mobiles var duration = TimeSpan.FromSeconds(30 + caster.Skills.Ninjitsu.Fixed / 40); new UnsummonTimer(caster, this, duration).Start(); - SummonEnd = DateTime.UtcNow + duration; + SummonEnd = Core.Now + duration; MirrorImage.AddClone(m_Caster); } diff --git a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs index 0ece06125..16a7999bf 100644 --- a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs +++ b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs @@ -131,7 +131,7 @@ namespace Server.Spells.Sixth m_Timer = new InternalTimer(this, duration); m_Timer.Start(); - m_End = DateTime.UtcNow + duration; + m_End = Core.Now + duration; } public InternalItem(Serial serial) : base(serial) @@ -170,7 +170,7 @@ namespace Server.Spells.Sixth m_Caster = reader.ReadEntity(); m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); + m_Timer = new InternalTimer(this, m_End - Core.Now); m_Timer.Start(); break; diff --git a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs index 86a2e1a8f..b55588a0e 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs @@ -171,7 +171,7 @@ namespace Server.Spells.Spellweaving { to.SendLocalizedMessage(1072828); // Your arcane focus is renewed. focus.LifeSpan = duration; - focus.CreationTime = DateTime.UtcNow; + focus.CreationTime = Core.Now; focus.StrengthBonus = strengthBonus; focus.InvalidateProperties(); focus.SendTimeRemainingMessage(to); diff --git a/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs b/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs index 182313d4f..8a4facc6d 100644 --- a/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs +++ b/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs @@ -10,7 +10,7 @@ namespace Server.Items public TransientItem(int itemID, TimeSpan lifeSpan) : base(itemID) { - CreationTime = DateTime.UtcNow; + CreationTime = Core.Now; LifeSpan = lifeSpan; m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), CheckExpiry); @@ -67,7 +67,7 @@ namespace Server.Items public virtual void CheckExpiry() { - if (CreationTime + LifeSpan < DateTime.UtcNow) + if (CreationTime + LifeSpan < Core.Now) { Expire(RootParent as Mobile); } @@ -81,7 +81,7 @@ namespace Server.Items { base.GetProperties(list); - var remaining = CreationTime + LifeSpan - DateTime.UtcNow; + var remaining = CreationTime + LifeSpan - Core.Now; list.Add(1072517, ((int)remaining.TotalSeconds).ToString()); // Lifespan: ~1_val~ seconds } diff --git a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs index 6a04be55a..5cd55fe36 100644 --- a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs +++ b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs @@ -40,7 +40,7 @@ namespace Server.Spells from.SendLocalizedMessage(501943); // Target cannot be seen. Try again. from.Target = new SpellTargetPoint3D(m_Spell); - from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow); + from.Target.BeginTimeout(from, TimeoutTime - Core.TickCount); m_Spell = null; // Needed? } diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index 39e24611e..a2c9a01d6 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -122,7 +122,7 @@ namespace Server.Spells.Third m_Timer = new InternalTimer(this, TimeSpan.FromSeconds(10.0)); m_Timer.Start(); - m_End = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + m_End = Core.Now + TimeSpan.FromSeconds(10.0); } public InternalItem(Serial serial) : base(serial) @@ -152,7 +152,7 @@ namespace Server.Spells.Third { m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); + m_Timer = new InternalTimer(this, m_End - Core.Now); m_Timer.Start(); break; @@ -164,7 +164,7 @@ namespace Server.Spells.Third m_Timer = new InternalTimer(this, duration); m_Timer.Start(); - m_End = DateTime.UtcNow + duration; + m_End = Core.Now + duration; break; }