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

@ -31,7 +31,7 @@ namespace Server
Console.WriteLine( "Client: {0}: Past IP limit threshold", ip );
using ( StreamWriter op = new StreamWriter( "ipLimits.log", true ) )
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", ip, DateTime.Now );
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", ip, DateTime.UtcNow );
e.AllowConnection = false;
return;

View file

@ -177,7 +177,7 @@ namespace Server.Accounting
if ( GetBanTags( out banTime, out banDuration ) )
{
if ( banDuration != TimeSpan.MaxValue && DateTime.Now >= ( banTime + banDuration ) )
if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= ( banTime + banDuration ) )
{
SetUnspecifiedBan( null ); // clear
Banned = false;
@ -235,7 +235,7 @@ namespace Server.Accounting
if( this.AccessLevel != AccessLevel.Player )
return false;
TimeSpan inactiveLength = DateTime.Now - m_LastLogin;
TimeSpan inactiveLength = DateTime.UtcNow - m_LastLogin;
return (inactiveLength > ((this.Count == 0) ? EmptyInactiveDuration : InactiveDuration));
}
@ -254,7 +254,7 @@ namespace Server.Accounting
PlayerMobile m = m_Mobiles[i] as PlayerMobile;
if ( m != null && m.NetState != null )
return m_TotalGameTime + ( DateTime.Now - m.SessionStart );
return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart );
}
return m_TotalGameTime;
@ -528,7 +528,7 @@ namespace Server.Accounting
if ( m == null )
return;
acc.m_TotalGameTime += DateTime.Now - m.SessionStart;
acc.m_TotalGameTime += DateTime.UtcNow - m.SessionStart;
}
private static void EventSink_Login( LoginEventArgs e )
@ -607,7 +607,7 @@ namespace Server.Accounting
m_AccessLevel = AccessLevel.Player;
m_Created = m_LastLogin = DateTime.Now;
m_Created = m_LastLogin = DateTime.UtcNow;
m_TotalGameTime = TimeSpan.Zero;
m_Mobiles = new Mobile[7];
@ -674,8 +674,8 @@ namespace Server.Accounting
m_AccessLevel = (AccessLevel)Enum.Parse( typeof( AccessLevel ), Utility.GetText( node["accessLevel"], "Player" ), true );
#endif
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.Now );
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.Now );
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
m_Mobiles = LoadMobiles( node );
m_Comments = LoadComments( node );

View file

@ -30,7 +30,7 @@ namespace Server.Accounting
if ( accessLog == null )
return true;
return ( DateTime.Now >= (accessLog.LastAccessTime + ComputeThrottle( accessLog.Counts )) );
return ( DateTime.UtcNow >= (accessLog.LastAccessTime + ComputeThrottle( accessLog.Counts )) );
}
private static List<InvalidAccountAccessLog> m_List = new List<InvalidAccountAccessLog>();
@ -73,7 +73,7 @@ namespace Server.Accounting
using ( StreamWriter op = new StreamWriter( "throttle.log", true ) ) {
op.WriteLine(
"{0}\t{1}\t{2}",
DateTime.Now,
DateTime.UtcNow,
ns,
accessLog.Counts
);
@ -125,7 +125,7 @@ namespace Server.Accounting
public bool HasExpired
{
get{ return ( DateTime.Now >= ( m_LastAccessTime + TimeSpan.FromHours( 1.0 ) ) ); }
get{ return ( DateTime.UtcNow >= ( m_LastAccessTime + TimeSpan.FromHours( 1.0 ) ) ); }
}
public int Counts
@ -136,7 +136,7 @@ namespace Server.Accounting
public void RefreshAccessTime()
{
m_LastAccessTime = DateTime.Now;
m_LastAccessTime = DateTime.UtcNow;
}
public InvalidAccountAccessLog( IPAddress address )

View file

@ -23,7 +23,7 @@ namespace Server.Accounting
public string Content
{
get{ return m_Content; }
set{ m_Content = value; m_LastModified = DateTime.Now; }
set{ m_Content = value; m_LastModified = DateTime.UtcNow; }
}
/// <summary>
@ -43,7 +43,7 @@ namespace Server.Accounting
{
m_AddedBy = addedBy;
m_Content = content;
m_LastModified = DateTime.Now;
m_LastModified = DateTime.UtcNow;
}
/// <summary>
@ -53,7 +53,7 @@ namespace Server.Accounting
public AccountComment( XmlElement node )
{
m_AddedBy = Utility.GetAttribute( node, "addedBy", "empty" );
m_LastModified = Utility.GetXMLDateTime( Utility.GetAttribute( node, "lastModified" ), DateTime.Now );
m_LastModified = Utility.GetXMLDateTime( Utility.GetAttribute( node, "lastModified" ), DateTime.UtcNow );
m_Content = Utility.GetText( node, "" );
}

View file

@ -197,7 +197,7 @@ namespace Server.Misc
state.Send( new DeleteResult( DeleteResultType.CharBeingPlayed ) );
state.Send( new CharacterListUpdate( acct ) );
}
else if ( RestrictDeletion && DateTime.Now < (m.CreationTime + DeleteDelay) )
else if ( RestrictDeletion && DateTime.UtcNow < (m.CreationTime + DeleteDelay) )
{
state.Send( new DeleteResult( DeleteResultType.CharTooYoung ) );
state.Send( new CharacterListUpdate( acct ) );
@ -306,7 +306,7 @@ namespace Server.Misc
Console.WriteLine( "Login: {0}: Past IP limit threshold", e.State );
using ( StreamWriter op = new StreamWriter( "ipLimits.log", true ) )
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now );
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow );
return;
}
@ -370,7 +370,7 @@ namespace Server.Misc
Console.WriteLine( "Login: {0}: Past IP limit threshold", e.State );
using ( StreamWriter op = new StreamWriter( "ipLimits.log", true ) )
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now );
op.WriteLine( "{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow );
return;
}