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
This commit is contained in:
Kamron Batman 2021-03-13 01:32:04 -08:00 committed by GitHub
parent 5de6edbeb8
commit 6c4308bce6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
208 changed files with 660 additions and 793 deletions

View file

@ -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

View file

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

View file

@ -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)
{

View file

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

View file

@ -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<DamageEntry> 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<DamageEntry>();
NextSkillTime = Core.TickCount;
CreationTime = DateTime.UtcNow;
CreationTime = Core.Now;
}
public virtual void Delta(MobileDelta flag)

View file

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

View file

@ -33,7 +33,7 @@ namespace Server.Network
public AuthIDPersistence(ClientVersion v)
{
Age = DateTime.UtcNow;
Age = Core.Now;
Version = v;
}
}

View file

@ -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) =>

View file

@ -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

View file

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

View file

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

View file

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

View file

@ -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>(T val, T min) where T : IComparable<T> => val.CompareTo(min) < 0 ? val : min;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Max<T>(T val, T max) where T : IComparable<T> => 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");
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,7 @@ namespace Server.Accounting
{
AddedBy = addedBy;
m_Content = content;
LastModified = DateTime.UtcNow;
LastModified = Core.Now;
}
/// <summary>
@ -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;
}
}

View file

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

View file

@ -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
{

View file

@ -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

View file

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

View file

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

View file

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

View file

@ -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()
{

View file

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

View file

@ -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)
{

View file

@ -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];

View file

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

View file

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

View file

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

View file

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

View file

@ -19,7 +19,7 @@ namespace Server.Items
{
Title = title;
m_Rank = rank;
Date = DateTime.UtcNow;
Date = Core.Now;
LootType = LootType.Blessed;

View file

@ -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()
{

View file

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

View file

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

View file

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

View file

@ -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()

View file

@ -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<FactionItem> 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<PlayerState>(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;
}
}

View file

@ -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)
{

View file

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

View file

@ -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

View file

@ -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.

View file

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

View file

@ -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)
{

View file

@ -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
{

View file

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

View file

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

View file

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

View file

@ -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<Spell>(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;

View file

@ -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
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests
return false;
}
if (nextAvailable > DateTime.UtcNow)
if (nextAvailable > Core.Now)
{
if (message)
{

View file

@ -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

View file

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

View file

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

View file

@ -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)
{

View file

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

View file

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

View file

@ -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)
{

View file

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

View file

@ -24,7 +24,7 @@ namespace Server.Engines.Quests
{
if (restartDelay < TimeSpan.MaxValue)
{
RestartTime = DateTime.UtcNow + restartDelay;
RestartTime = Core.Now + restartDelay;
}
else
{

View file

@ -473,7 +473,7 @@ namespace Server.Engines.Quests
{
var endTime = restartInfo.RestartTime;
if (DateTime.UtcNow < endTime)
if (Core.Now < endTime)
{
inRestartPeriod = true;
return false;

View file

@ -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))
{

View file

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

View file

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

View file

@ -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)
{

View file

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

View file

@ -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

View file

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

View file

@ -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

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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)
{

View file

@ -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

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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))
{

View file

@ -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)
{

View file

@ -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++)
{

View file

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

View file

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

View file

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

View file

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

View file

@ -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,

View file

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

View file

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

View file

@ -12,7 +12,7 @@ namespace Server.Items
Poster = poster;
Subject = subject;
Time = DateTime.UtcNow;
Time = Core.Now;
LastPostTime = Time;
Thread = thread;
PostedName = Poster.Name;

View file

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

View file

@ -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

Some files were not shown because too many files have changed in this diff Show more