Implement Core.TickCount

Convert movement, actions (lift/use), combat, and spells to use Core.TickCount and avoid DateTime caveats (performance, system time dependency, etc)
Refactor DateTime.Now to DateTime.UtcNow
Add LOS check for Iron Maiden addon
This commit is contained in:
Mark Sturgill 2013-10-06 03:21:18 -07:00
parent f99eefb288
commit d2c670f5c3
241 changed files with 842 additions and 831 deletions

View file

@ -109,7 +109,7 @@ namespace Server
if ( m_Queued )
DumpAccess();
return ( m_Attacker.Deleted || m_Defender.Deleted || DateTime.Now >= (m_LastCombatTime + m_ExpireDelay) );
return ( m_Attacker.Deleted || m_Defender.Deleted || DateTime.UtcNow >= (m_LastCombatTime + m_ExpireDelay) );
}
}
@ -205,7 +205,7 @@ namespace Server
if ( m_Queued )
DumpAccess();
m_LastCombatTime = DateTime.Now;
m_LastCombatTime = DateTime.UtcNow;
m_Reported = false;
}
}

View file

@ -47,7 +47,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.3.*")]
[assembly: AssemblyVersion("2.4.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the

View file

@ -1520,7 +1520,7 @@ namespace Server
public void SetLastMoved()
{
m_LastMovedTime = DateTime.Now;
m_LastMovedTime = DateTime.UtcNow;
}
public DateTime LastMoved
@ -2073,7 +2073,7 @@ namespace Server
/* begin last moved time optimization */
long ticks = m_LastMovedTime.Ticks;
long now = DateTime.Now.Ticks;
long now = DateTime.UtcNow.Ticks;
TimeSpan d;
@ -2322,8 +2322,8 @@ namespace Server
{
int minutes = reader.ReadEncodedInt();
try{ LastMoved = DateTime.Now - TimeSpan.FromMinutes( minutes ); }
catch{ LastMoved = DateTime.Now; }
try{ LastMoved = DateTime.UtcNow - TimeSpan.FromMinutes( minutes ); }
catch{ LastMoved = DateTime.UtcNow; }
}
if ( GetSaveFlag( flags, SaveFlag.Direction ) )

View file

@ -84,9 +84,9 @@ namespace Server
m_Profiling = value;
if( m_ProfileStart > DateTime.MinValue )
m_ProfileTime += DateTime.Now - m_ProfileStart;
m_ProfileTime += DateTime.UtcNow - m_ProfileStart;
m_ProfileStart = (m_Profiling ? DateTime.Now : DateTime.MinValue);
m_ProfileStart = (m_Profiling ? DateTime.UtcNow : DateTime.MinValue);
}
}
@ -95,7 +95,7 @@ namespace Server
get
{
if( m_ProfileStart > DateTime.MinValue )
return m_ProfileTime + (DateTime.Now - m_ProfileStart);
return m_ProfileTime + (DateTime.UtcNow - m_ProfileStart);
return m_ProfileTime;
}
@ -112,6 +112,14 @@ namespace Server
public static Thread Thread { get { return m_Thread; } }
public static MultiTextWriter MultiConsoleOut { get { return m_MultiConOut; } }
public static int TickCount {
get {
if (Stopwatch.IsHighResolution) // TODO: GetTimestamp is unreliable with certain system configurations.
return (int)((double)Stopwatch.GetTimestamp() / Stopwatch.Frequency * 1000);
return Environment.TickCount;
}
}
#if Framework_4_0
public static readonly bool Is64Bit = Environment.Is64BitProcess;
#else
@ -704,7 +712,7 @@ namespace Server
m_FileName = file;
using( StreamWriter writer = new StreamWriter( new FileStream( m_FileName, append ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.Read ) ) )
{
writer.WriteLine( ">>>Logging started on {0}.", DateTime.Now.ToString( "f" ) ); //f = Tuesday, April 10, 2001 3:51 PM
writer.WriteLine( ">>>Logging started on {0}.", DateTime.UtcNow.ToString( "f" ) ); //f = Tuesday, April 10, 2001 3:51 PM
}
m_NewLine = true;
}
@ -715,7 +723,7 @@ namespace Server
{
if( m_NewLine )
{
writer.Write( DateTime.Now.ToString( DateFormat ) );
writer.Write( DateTime.UtcNow.ToString( DateFormat ) );
m_NewLine = false;
}
writer.Write( ch );
@ -728,7 +736,7 @@ namespace Server
{
if( m_NewLine )
{
writer.Write( DateTime.Now.ToString( DateFormat ) );
writer.Write( DateTime.UtcNow.ToString( DateFormat ) );
m_NewLine = false;
}
writer.Write( str );
@ -740,7 +748,7 @@ namespace Server
using( StreamWriter writer = new StreamWriter( new FileStream( m_FileName, FileMode.Append, FileAccess.Write, FileShare.Read ) ) )
{
if( m_NewLine )
writer.Write( DateTime.Now.ToString( DateFormat ) );
writer.Write( DateTime.UtcNow.ToString( DateFormat ) );
writer.WriteLine( line );
m_NewLine = true;
}

View file

@ -55,7 +55,7 @@ namespace Server
private DateTime m_Expire;
public TimedSkillMod( SkillName skill, bool relative, double value, TimeSpan delay )
: this( skill, relative, value, DateTime.Now + delay )
: this( skill, relative, value, DateTime.UtcNow + delay )
{
}
@ -67,7 +67,7 @@ namespace Server
public override bool CheckCondition()
{
return (DateTime.Now < m_Expire);
return (DateTime.UtcNow < m_Expire);
}
}
@ -326,7 +326,7 @@ namespace Server
if( m_Duration == TimeSpan.Zero )
return false;
return (DateTime.Now - m_Added) >= m_Duration;
return (DateTime.UtcNow - m_Added) >= m_Duration;
}
public StatMod( StatType type, string name, int offset, TimeSpan duration )
@ -335,7 +335,7 @@ namespace Server
m_Name = name;
m_Offset = offset;
m_Duration = duration;
m_Added = DateTime.Now;
m_Added = DateTime.UtcNow;
}
}
@ -351,7 +351,7 @@ namespace Server
public Mobile Damager { get { return m_Damager; } }
public int DamageGiven { get { return m_DamageGiven; } set { m_DamageGiven = value; } }
public DateTime LastDamage { get { return m_LastDamage; } set { m_LastDamage = value; } }
public bool HasExpired { get { return (DateTime.Now > (m_LastDamage + m_ExpireDelay)); } }
public bool HasExpired { get { return (DateTime.UtcNow > (m_LastDamage + m_ExpireDelay)); } }
public List<DamageEntry> Responsible { get { return m_Responsible; } set { m_Responsible = value; } }
private static TimeSpan m_ExpireDelay = TimeSpan.FromMinutes( 2.0 );
@ -660,11 +660,11 @@ namespace Server
private class MovementRecord
{
public DateTime m_End;
public int m_End;
private static Queue<MovementRecord> m_InstancePool = new Queue<MovementRecord>();
public static MovementRecord NewInstance( DateTime end )
public static MovementRecord NewInstance( int end )
{
MovementRecord r;
@ -682,14 +682,14 @@ namespace Server
return r;
}
private MovementRecord( DateTime end )
private MovementRecord( int end )
{
m_End = end;
}
public bool Expired()
{
bool v = (DateTime.Now >= m_End);
bool v = (Core.TickCount - m_End >= 0);
if( v )
m_InstancePool.Enqueue( this );
@ -744,7 +744,7 @@ namespace Server
private int m_TithingPoints;
private bool m_DisplayGuildTitle;
private Mobile m_GuildFealty;
private DateTime m_NextSpellTime;
private int m_NextSpellTime;
private DateTime[] m_StuckMenuUses;
private Timer m_ExpireCombatant;
private Timer m_ExpireCriminal;
@ -752,9 +752,9 @@ namespace Server
private Timer m_LogoutTimer;
private Timer m_CombatTimer;
private Timer m_ManaTimer, m_HitsTimer, m_StamTimer;
private DateTime m_NextSkillTime;
private DateTime m_NextActionTime;
private DateTime m_NextActionMessage;
private int m_NextSkillTime;
private int m_NextActionTime;
private int m_NextActionMessage;
private bool m_Paralyzed;
private ParalyzedTimer m_ParaTimer;
private bool m_Frozen;
@ -1366,7 +1366,7 @@ namespace Server
if( m_Warmode == value )
return;
DateTime now = DateTime.Now, next = m_NextWarmodeChange;
DateTime now = DateTime.UtcNow, next = m_NextWarmodeChange;
if( now > next || m_WarmodeChanges == 0 )
{
@ -1482,7 +1482,7 @@ namespace Server
}
}
public DateTime NextCombatTime
public int NextCombatTime
{
get
{
@ -1586,7 +1586,7 @@ namespace Server
}
}
private DateTime m_LastMoveTime;
private int m_LastMoveTime;
/// <summary>
/// Gets or sets the number of steps this player may take when hidden before being revealed.
@ -1664,7 +1664,7 @@ namespace Server
}
}
public DateTime LastMoveTime
public int LastMoveTime
{
get
{
@ -1845,7 +1845,7 @@ namespace Server
return String.Format( "0x{0:X} \"{1}\"", m_Serial.Value, Name );
}
public DateTime NextActionTime
public int NextActionTime
{
get
{
@ -1857,7 +1857,7 @@ namespace Server
}
}
public DateTime NextActionMessage
public int NextActionMessage
{
get
{
@ -1869,9 +1869,9 @@ namespace Server
}
}
private static TimeSpan m_ActionMessageDelay = TimeSpan.FromSeconds( 0.125 );
private static int m_ActionMessageDelay = 125;
public static TimeSpan ActionMessageDelay
public static int ActionMessageDelay
{
get { return m_ActionMessageDelay; }
set { m_ActionMessageDelay = value; }
@ -1879,20 +1879,20 @@ namespace Server
public virtual void SendSkillMessage()
{
if( DateTime.Now < m_NextActionMessage )
if (m_NextActionMessage - Core.TickCount >= 0)
return;
m_NextActionMessage = DateTime.Now + m_ActionMessageDelay;
m_NextActionMessage = Core.TickCount + m_ActionMessageDelay;
SendLocalizedMessage( 500118 ); // You must wait a few moments to use another skill.
}
public virtual void SendActionMessage()
{
if( DateTime.Now < m_NextActionMessage )
if (m_NextActionMessage - Core.TickCount >= 0)
return;
m_NextActionMessage = DateTime.Now + m_ActionMessageDelay;
m_NextActionMessage = Core.TickCount + m_ActionMessageDelay;
SendLocalizedMessage( 500119 ); // You must wait to perform another action.
}
@ -2067,7 +2067,7 @@ namespace Server
protected override void OnTick()
{
if( DateTime.Now > m_Mobile.m_NextCombatTime )
if (Core.TickCount - m_Mobile.m_NextCombatTime >= 0)
{
Mobile combatant = m_Mobile.Combatant;
@ -2087,7 +2087,7 @@ namespace Server
{
weapon.OnBeforeSwing( m_Mobile, combatant ); //OnBeforeSwing for checking in regards to being hidden and whatnot
m_Mobile.RevealingAction();
m_Mobile.m_NextCombatTime = DateTime.Now + weapon.OnSwing( m_Mobile, combatant );
m_Mobile.m_NextCombatTime = Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds;
}
}
}
@ -2157,9 +2157,9 @@ namespace Server
#endregion
private DateTime m_NextCombatTime;
private int m_NextCombatTime;
public DateTime NextSkillTime
public int NextSkillTime
{
get
{
@ -3068,17 +3068,17 @@ namespace Server
}
}
private static TimeSpan m_WalkFoot = TimeSpan.FromSeconds( 0.4 );
private static TimeSpan m_RunFoot = TimeSpan.FromSeconds( 0.2 );
private static TimeSpan m_WalkMount = TimeSpan.FromSeconds( 0.2 );
private static TimeSpan m_RunMount = TimeSpan.FromSeconds( 0.1 );
private static int m_WalkFoot = 400;
private static int m_RunFoot = 200;
private static int m_WalkMount = 200;
private static int m_RunMount = 100;
public static TimeSpan WalkFoot { get { return m_WalkFoot; } set { m_WalkFoot = value; } }
public static TimeSpan RunFoot { get { return m_RunFoot; } set { m_RunFoot = value; } }
public static TimeSpan WalkMount { get { return m_WalkMount; } set { m_WalkMount = value; } }
public static TimeSpan RunMount { get { return m_RunMount; } set { m_RunMount = value; } }
public static int WalkFoot { get { return m_WalkFoot; } set { m_WalkFoot = value; } }
public static int RunFoot { get { return m_RunFoot; } set { m_RunFoot = value; } }
public static int WalkMount { get { return m_WalkMount; } set { m_WalkMount = value; } }
public static int RunMount { get { return m_RunMount; } set { m_RunMount = value; } }
private DateTime m_EndQueue;
private int m_EndQueue;
private static ArrayList m_MoveList = new ArrayList();
@ -3097,7 +3097,7 @@ namespace Server
if( m_MoveRecords != null && m_MoveRecords.Count > 0 )
m_MoveRecords.Clear();
m_EndQueue = DateTime.Now;
m_EndQueue = Core.TickCount;
}
public virtual bool CheckMovement( Direction d, out int newZ )
@ -3277,21 +3277,21 @@ namespace Server
return false;
}
TimeSpan delay = ComputeMovementSpeed( d );
int delay = ComputeMovementSpeed( d );
DateTime end;
int end;
if( m_MoveRecords.Count > 0 )
end = m_EndQueue + delay;
else
end = DateTime.Now + delay;
end = Core.TickCount + delay;
m_MoveRecords.Enqueue( MovementRecord.NewInstance( end ) );
m_EndQueue = end;
}
m_LastMoveTime = DateTime.Now;
m_LastMoveTime = Core.TickCount;
}
else
{
@ -3391,19 +3391,19 @@ namespace Server
{
}
public TimeSpan ComputeMovementSpeed()
public int ComputeMovementSpeed()
{
return ComputeMovementSpeed( this.Direction, false );
}
public TimeSpan ComputeMovementSpeed( Direction dir )
public int ComputeMovementSpeed( Direction dir )
{
return ComputeMovementSpeed( dir, true );
}
public virtual TimeSpan ComputeMovementSpeed( Direction dir, bool checkTurning )
public virtual int ComputeMovementSpeed( Direction dir, bool checkTurning )
{
TimeSpan delay;
int delay;
if( Mounted )
delay = (dir & Direction.Running) != 0 ? m_RunMount : m_WalkMount;
@ -3531,7 +3531,7 @@ namespace Server
{
for( int i = 0; i < m_StuckMenuUses.Length; ++i )
{
if( (DateTime.Now - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) )
if( (DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) )
{
return true;
}
@ -4287,9 +4287,9 @@ namespace Server
m.OnDoubleClick( this );
}
private static TimeSpan m_ActionDelay = TimeSpan.FromSeconds( 0.5 );
private static int m_ActionDelay = 500;
public static TimeSpan ActionDelay
public static int ActionDelay
{
get { return m_ActionDelay; }
set { m_ActionDelay = value; }
@ -4306,7 +4306,7 @@ namespace Server
Mobile from = this;
NetState state = m_NetState;
if( from.AccessLevel >= AccessLevel.GameMaster || DateTime.Now >= from.NextActionTime )
if (from.AccessLevel >= AccessLevel.GameMaster || Core.TickCount - from.NextActionTime >= 0)
{
if( from.CheckAlive() )
{
@ -4428,7 +4428,7 @@ namespace Server
if( liftSound != -1 )
from.Send( new PlaySound( liftSound, from ) );
from.NextActionTime = DateTime.Now + m_ActionDelay;
from.NextActionTime = Core.TickCount + m_ActionDelay;
if( fixMap != null && shouldFix )
fixMap.FixColumn( fixLoc.m_X, fixLoc.m_Y );
@ -5144,7 +5144,7 @@ namespace Server
de = new DamageEntry( from );
de.DamageGiven += amount;
de.LastDamage = DateTime.Now;
de.LastDamage = DateTime.UtcNow;
m_DamageEntries.Remove( de );
m_DamageEntries.Add( de );
@ -5175,7 +5175,7 @@ namespace Server
list.Add( resp = new DamageEntry( master ) );
resp.DamageGiven += amount;
resp.LastDamage = DateTime.Now;
resp.LastDamage = DateTime.UtcNow;
}
return de;
@ -5419,9 +5419,9 @@ namespace Server
for( int i = 0; i < m_StuckMenuUses.Length; ++i )
{
if( (DateTime.Now - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) )
if( (DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) )
{
m_StuckMenuUses[i] = DateTime.Now;
m_StuckMenuUses[i] = DateTime.UtcNow;
return;
}
}
@ -9888,7 +9888,7 @@ namespace Server
m_Serial = serial;
m_Aggressors = new List<AggressorInfo>();
m_Aggressed = new List<AggressorInfo>();
m_NextSkillTime = DateTime.MinValue;
m_NextSkillTime = Core.TickCount;
m_DamageEntries = new List<DamageEntry>();
Type ourType = this.GetType();
@ -9936,8 +9936,8 @@ namespace Server
m_Stabled = new List<Mobile>();
m_DamageEntries = new List<DamageEntry>();
m_NextSkillTime = DateTime.MinValue;
m_CreationTime = DateTime.Now;
m_NextSkillTime = Core.TickCount;
m_CreationTime = DateTime.UtcNow;
}
private static Queue<Mobile> m_DeltaQueue = new Queue<Mobile>();
@ -11335,7 +11335,7 @@ namespace Server
}
}
public DateTime NextSpellTime
public int NextSpellTime
{
get
{

View file

@ -83,7 +83,7 @@ namespace Server.Network {
public TimeSpan ConnectedFor {
get {
return ( DateTime.Now - m_ConnectedOn );
return ( DateTime.UtcNow - m_ConnectedOn );
}
}
@ -567,7 +567,7 @@ namespace Server.Network {
m_SendQueue = new SendQueue();
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 0.5 );
m_NextCheckActivity = Core.TickCount + 30000;
m_Instances.Add( this );
@ -580,7 +580,7 @@ namespace Server.Network {
m_ToString = "(error)";
}
m_ConnectedOn = DateTime.Now;
m_ConnectedOn = DateTime.UtcNow;
if ( m_CreatedCallback != null )
{
@ -647,7 +647,7 @@ namespace Server.Network {
Console.WriteLine( "Client: {0}: null buffer send, disconnecting...", this );
using ( StreamWriter op = new StreamWriter( "null_send.log", true ) )
{
op.WriteLine( "{0} Client: {1}: null buffer send, disconnecting...", DateTime.Now, this );
op.WriteLine( "{0} Client: {1}: null buffer send, disconnecting...", DateTime.UtcNow, this );
op.WriteLine( new System.Diagnostics.StackTrace() );
}
Dispose();
@ -711,7 +711,7 @@ namespace Server.Network {
return;
}
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
m_NextCheckActivity = Core.TickCount + 90000;
byte[] buffer = m_RecvBuffer;
@ -777,7 +777,7 @@ namespace Server.Network {
return;
}
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
m_NextCheckActivity = Core.TickCount + 90000;
}
public static void Pause() {
@ -867,7 +867,7 @@ namespace Server.Network {
int byteCount = s.EndReceive( asyncResult );
if ( byteCount > 0 ) {
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
m_NextCheckActivity = Core.TickCount + 90000;
byte[] buffer = m_RecvBuffer;
@ -910,7 +910,7 @@ namespace Server.Network {
return;
}
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
m_NextCheckActivity = Core.TickCount + 90000;
if ( m_CoalesceSleep >= 0 ) {
Thread.Sleep( m_CoalesceSleep );
@ -1023,13 +1023,13 @@ namespace Server.Network {
}
}
private DateTime m_NextCheckActivity;
private int m_NextCheckActivity;
public bool CheckAlive() {
if ( m_Socket == null )
return false;
if ( DateTime.Now < m_NextCheckActivity ) {
if (m_NextCheckActivity - Core.TickCount >= 0) {
return true;
}
@ -1045,7 +1045,7 @@ namespace Server.Network {
try {
using ( StreamWriter op = new StreamWriter( "network-errors.log", true ) ) {
op.WriteLine( "# {0}", DateTime.Now );
op.WriteLine("# {0}", DateTime.UtcNow);
op.WriteLine( ex );

View file

@ -1408,7 +1408,7 @@ namespace Server.Network
{
Mobile from = state.Mobile;
if ( from.AccessLevel >= AccessLevel.Counselor || DateTime.Now >= from.NextActionTime )
if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0)
{
int value = pvSrc.ReadInt32();
@ -1436,7 +1436,7 @@ namespace Server.Network
}
}
from.NextActionTime = DateTime.Now + Mobile.ActionDelay;
from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
}
else
{
@ -1627,7 +1627,7 @@ namespace Server.Network
if (from == null)
return;
if (from.AccessLevel >= AccessLevel.Counselor || DateTime.Now >= from.NextActionTime)
if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0)
{
Item bandage = World.FindItem(pvSrc.ReadInt32());
@ -1641,7 +1641,7 @@ namespace Server.Network
EventSink.InvokeBandageTargetRequest(new BandageTargetRequestEventArgs(from, bandage, target));
from.NextActionTime = DateTime.Now + Mobile.ActionDelay;
from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
}
else
{
@ -2412,7 +2412,6 @@ namespace Server.Network
}
}
private static bool m_ClientVerification = true;
public static bool ClientVerification
@ -2426,7 +2425,7 @@ namespace Server.Network
public ClientVersion Version;
public AuthIDPersistence( ClientVersion v ) {
Age = DateTime.Now;
Age = DateTime.UtcNow;
Version = v;
}
}

View file

@ -76,7 +76,7 @@ namespace Server.Network
{
using ( StreamWriter op = new StreamWriter( "neterr.log" ) )
{
op.WriteLine( "{0}\tInstance pool contains writer", DateTime.Now );
op.WriteLine("{0}\tInstance pool contains writer", DateTime.UtcNow);
}
}
catch

View file

@ -2731,7 +2731,7 @@ namespace Server.Network
{
public CurrentTime() : base( 0x5B, 4 )
{
DateTime now = DateTime.Now;
DateTime now = DateTime.UtcNow;
m_Stream.Write( (byte) now.Hour );
m_Stream.Write( (byte) now.Minute );
@ -4590,7 +4590,7 @@ namespace Server.Network
Console.WriteLine( "Warning: Compression buffer overflowed on packet 0x{0:X2} ('{1}') (length={2})", m_PacketID, GetType().Name, length );
using ( StreamWriter op = new StreamWriter( "compression_overflow.log", true ) )
{
op.WriteLine( "{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", DateTime.Now, m_PacketID, GetType().Name, length );
op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", DateTime.UtcNow, m_PacketID, GetType().Name, length);
op.WriteLine( new System.Diagnostics.StackTrace() );
}
}

View file

@ -134,7 +134,7 @@ namespace Server
writer.QueueForIndex(item, size);
if (item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.Now > (item.LastMoved + item.DecayTime))
if (item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.UtcNow > (item.LastMoved + item.DecayTime))
{
_decayBag.Add(item);
}

View file

@ -198,7 +198,8 @@ namespace Server {
metrics.OnItemSaved( length );
}
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.Now > ( item.LastMoved + item.DecayTime ) ) {
if (item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.UtcNow > (item.LastMoved + item.DecayTime))
{
_decayQueue.Enqueue( item );
}
}

View file

@ -134,7 +134,8 @@ namespace Server {
idx.Write( ( int ) items.Count );
foreach ( Item item in items.Values ) {
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && ( item.LastMoved + item.DecayTime ) <= DateTime.Now ) {
if (item.Decays && item.Parent == null && item.Map != Map.Internal && (item.LastMoved + item.DecayTime) <= DateTime.UtcNow)
{
_decayQueue.Enqueue( item );
}

View file

@ -379,7 +379,7 @@ namespace Server
public override void WriteDeltaTime( DateTime value )
{
long ticks = value.Ticks;
long now = DateTime.Now.Ticks;
long now = DateTime.UtcNow.Ticks;
TimeSpan d;
@ -980,7 +980,7 @@ namespace Server
public override DateTime ReadDeltaTime()
{
long ticks = m_File.ReadInt64();
long now = DateTime.Now.Ticks;
long now = DateTime.UtcNow.Ticks;
if( ticks > 0 && (ticks+now) < 0 )
return DateTime.MaxValue;
@ -1549,7 +1549,7 @@ namespace Server
public override void WriteDeltaTime( DateTime value )
{
long ticks = value.Ticks;
long now = DateTime.Now.Ticks;
long now = DateTime.UtcNow.Ticks;
TimeSpan d;

View file

@ -942,11 +942,11 @@ namespace Server
if ( info.Callback != null )
{
if ( from.NextSkillTime <= DateTime.Now && from.Spell == null )
if (Core.TickCount - from.NextSkillTime >= 0 && from.Spell == null)
{
from.DisruptiveAction();
from.NextSkillTime = DateTime.Now + info.Callback( from );
from.NextSkillTime = Core.TickCount + (int)(info.Callback(from)).TotalMilliseconds;
return true;
}

View file

@ -73,7 +73,7 @@ namespace Server.Targeting
public void BeginTimeout( Mobile from, TimeSpan delay )
{
m_TimeoutTime = DateTime.Now + delay;
m_TimeoutTime = DateTime.UtcNow + delay;
if ( m_TimeoutTimer != null )
m_TimeoutTimer.Stop();

View file

@ -461,10 +461,10 @@ namespace Server
}
catch ( EndOfStreamException )
{
if ( DateTime.Now >= m_NextStaticWarning )
if ( DateTime.UtcNow >= m_NextStaticWarning )
{
Console.WriteLine( "Warning: Static EOS for {0} ({1}, {2})", m_Owner, x, y );
m_NextStaticWarning = DateTime.Now + TimeSpan.FromMinutes( 1.0 );
m_NextStaticWarning = DateTime.UtcNow + TimeSpan.FromMinutes( 1.0 );
}
return m_EmptyStaticBlock;
@ -506,10 +506,10 @@ namespace Server
}
catch
{
if ( DateTime.Now >= m_NextLandWarning )
if ( DateTime.UtcNow >= m_NextLandWarning )
{
Console.WriteLine( "Warning: Land EOS for {0} ({1}, {2})", m_Owner, x, y );
m_NextLandWarning = DateTime.Now + TimeSpan.FromMinutes( 1.0 );
m_NextLandWarning = DateTime.UtcNow + TimeSpan.FromMinutes( 1.0 );
}
return m_InvalidLandBlock;

View file

@ -283,7 +283,7 @@ namespace Server
if ( tce.m_IsAdd )
{
timer.m_Next = DateTime.Now + timer.m_Delay;
timer.m_Next = DateTime.UtcNow + timer.m_Delay;
timer.m_Index = 0;
}
@ -318,7 +318,7 @@ namespace Server
for ( i = 0; i < m_Timers.Length; i++)
{
now = DateTime.Now;
now = DateTime.UtcNow;
if ( now < m_NextPriorities[i] )
break;

View file

@ -1089,7 +1089,7 @@ namespace Server {
try {
using ( StreamWriter op = new StreamWriter( "world-save-errors.log", true ) ) {
op.WriteLine( "{0}\t{1}", DateTime.Now, message );
op.WriteLine( "{0}\t{1}", DateTime.UtcNow, message );
op.WriteLine( new StackTrace( 2 ).ToString() );
op.WriteLine();
}