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

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