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

@ -32,7 +32,7 @@ namespace Server.RemoteAdmin
string outStr;
if ( m_NewLine )
{
outStr = String.Format( "[{0}]: {1}", DateTime.Now.ToString( DateFormat ), str );
outStr = String.Format( "[{0}]: {1}", DateTime.UtcNow.ToString( DateFormat ), str );
m_NewLine = false;
}
else
@ -51,7 +51,7 @@ namespace Server.RemoteAdmin
if ( m_NewLine )
{
string outStr;
outStr = String.Format( "[{0}]: {1}", DateTime.Now.ToString( DateFormat ), ch );
outStr = String.Format( "[{0}]: {1}", DateTime.UtcNow.ToString( DateFormat ), ch );
m_ConsoleData.Append( outStr );
SendToAll( outStr );
@ -71,7 +71,7 @@ namespace Server.RemoteAdmin
{
string outStr;
if ( m_NewLine )
outStr = String.Format( "[{0}]: {1}{2}", DateTime.Now.ToString( DateFormat ), line, Console.Out.NewLine );
outStr = String.Format( "[{0}]: {1}{2}", DateTime.UtcNow.ToString( DateFormat ), line, Console.Out.NewLine );
else
outStr = String.Format( "{0}{1}", line, Console.Out.NewLine );
@ -127,7 +127,7 @@ namespace Server.RemoteAdmin
}
else if ( cmd == 0xFF )
{
string statStr = String.Format( ", Name={0}, Age={1}, Clients={2}, Items={3}, Chars={4}, Mem={5}K, Ver={6}", Server.Misc.ServerList.ServerName, (int)(DateTime.Now - Server.Items.Clock.ServerStart).TotalHours, NetState.Instances.Count, World.Items.Count, World.Mobiles.Count, (int)(System.GC.GetTotalMemory( false ) / 1024), ProtocolVersion );
string statStr = String.Format( ", Name={0}, Age={1}, Clients={2}, Items={3}, Chars={4}, Mem={5}K, Ver={6}", Server.Misc.ServerList.ServerName, (int)(DateTime.UtcNow - Server.Items.Clock.ServerStart).TotalHours, NetState.Instances.Count, World.Items.Count, World.Mobiles.Count, (int)(System.GC.GetTotalMemory( false ) / 1024), ProtocolVersion );
state.Send( new UOGInfo( statStr ) );
state.Dispose();
}
@ -189,7 +189,7 @@ namespace Server.RemoteAdmin
Console.WriteLine( "ADMIN: Access granted to '{0}' from {1}", user, state );
state.Account = a;
a.LogAccess( state );
a.LastLogin = DateTime.Now;
a.LastLogin = DateTime.UtcNow;
state.Send( new Login( LoginResponse.OK ) );
TightTrimConsoleData();

View file

@ -83,7 +83,7 @@ namespace Server.RemoteAdmin
m_Stream.Write( (int) World.Items.Count );
m_Stream.Write( (int) Core.ScriptItems );
m_Stream.Write( (uint)(DateTime.Now - Clock.ServerStart).TotalSeconds );
m_Stream.Write( (uint)(DateTime.UtcNow - Clock.ServerStart).TotalSeconds );
m_Stream.Write( (uint) GC.GetTotalMemory( false ) ); // TODO: uint not sufficient for TotalMemory (long). Fix protocol.
m_Stream.WriteAsciiNull( netVer );
m_Stream.WriteAsciiNull( os );
@ -132,7 +132,7 @@ namespace Server.RemoteAdmin
m_Stream.Write( (int)NetState.Instances.Count - 1 ); // Clients
m_Stream.Write( (int)World.Items.Count ); // Items
m_Stream.Write( (int)World.Mobiles.Count ); // Mobiles
m_Stream.Write( (uint)(DateTime.Now - Clock.ServerStart).TotalSeconds ); // Age (seconds)
m_Stream.Write( (uint)(DateTime.UtcNow - Clock.ServerStart).TotalSeconds ); // Age (seconds)
long memory = GC.GetTotalMemory( false );
m_Stream.Write( (uint)(memory >> 32) ); // Memory high bytes

View file

@ -34,12 +34,12 @@ namespace Server.RemoteAdmin
try
{
m_Output = new StreamWriter( Path.Combine( directory, String.Format( LogSubDirectory + "{0}.log", DateTime.Now.ToString( "yyyyMMdd" ) ) ), true );
m_Output = new StreamWriter( Path.Combine( directory, String.Format( LogSubDirectory + "{0}.log", DateTime.UtcNow.ToString( "yyyyMMdd" ) ) ), true );
m_Output.AutoFlush = true;
m_Output.WriteLine( "##############################" );
m_Output.WriteLine( "Log started on {0}", DateTime.Now );
m_Output.WriteLine( "Log started on {0}", DateTime.UtcNow );
m_Output.WriteLine();
}
catch
@ -81,7 +81,7 @@ namespace Server.RemoteAdmin
string accesslevel = acct == null ? "NoAccount" : acct.AccessLevel.ToString();
string statestr = state == null ? "NULLSTATE" : state.ToString();
m_Output.WriteLine( "{0}: {1}: {2}: {3}", DateTime.Now, statestr, name, text );
m_Output.WriteLine( "{0}: {1}: {2}: {3}", DateTime.UtcNow, statestr, name, text );
string path = Core.BaseDirectory;
@ -91,7 +91,7 @@ namespace Server.RemoteAdmin
path = Path.Combine( path, String.Format( "{0}.log", name ) );
using ( StreamWriter sw = new StreamWriter( path, true ) )
sw.WriteLine( "{0}: {1}: {2}", DateTime.Now, statestr, text );
sw.WriteLine( "{0}: {1}: {2}", DateTime.UtcNow, statestr, text );
}
catch
{