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

@ -251,7 +251,7 @@ namespace Server.Gumps
AddLabel( 150, 270, LabelHue, Core.ScriptItems.ToString() );
AddLabel( 20, 290, LabelHue, "Uptime:" );
AddLabel( 150, 290, LabelHue, FormatTimeSpan( DateTime.Now - Clock.ServerStart ) );
AddLabel( 150, 290, LabelHue, FormatTimeSpan( DateTime.UtcNow - Clock.ServerStart ) );
AddLabel( 20, 310, LabelHue, "Memory:" );
AddLabel( 150, 310, LabelHue, FormatByteAmount( GC.GetTotalMemory( false ) ) );
@ -907,7 +907,7 @@ namespace Server.Gumps
}
else
{
TimeSpan remaining = (DateTime.Now - banTime);
TimeSpan remaining = (DateTime.UtcNow - banTime);
if ( remaining < TimeSpan.Zero )
remaining = TimeSpan.Zero;

View file

@ -239,7 +239,7 @@ namespace Server.Gumps
{
Account a = (Account)m_List[i];
a.SetBanTags( from, DateTime.Now, duration );
a.SetBanTags( from, DateTime.UtcNow, duration );
if ( comment != null )
a.Comments.Add( new AccountComment( from.RawName, String.Format( "Duration: {0}, Comment: {1}", (( duration == TimeSpan.MaxValue )? "Infinite" : duration.ToString()), comment ) ) );

View file

@ -66,7 +66,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.Now )
else if ( m_Guild.TypeLastChange.AddDays( 7 ) > DateTime.UtcNow )
{
m_Mobile.SendLocalizedMessage( 1011142 ); // You have already changed your guild type recently.
// TODO: Clilocs 1011142-1011145 suggest a timer for pending changes

View file

@ -83,8 +83,8 @@ namespace Server.Guilds
TimeSpan timeRemaining = TimeSpan.Zero;
if( activeWar.WarLength != TimeSpan.Zero && (activeWar.WarBeginning + activeWar.WarLength) > DateTime.Now )
timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.Now;
if( activeWar.WarLength != TimeSpan.Zero && (activeWar.WarBeginning + activeWar.WarLength) > DateTime.UtcNow )
timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.UtcNow;
//time = String.Format( "{0:D2}:{1:D2}", timeRemaining.Hours.ToString(), timeRemaining.Subtract( TimeSpan.FromHours( timeRemaining.Hours ) ).Minutes ); //Is there a formatter for htis? it's 2AM and I'm tired and can't find it
time = String.Format( "{0:D2}:{1:mm}", timeRemaining.Hours, DateTime.MinValue + timeRemaining );
@ -234,7 +234,7 @@ namespace Server.Guilds
{
//Accept the war
guild.PendingWars.Remove( war );
war.WarBeginning = DateTime.Now;
war.WarBeginning = DateTime.UtcNow;
guild.AcceptedWars.Add( war );
if( alliance != null && alliance.IsMember( guild ) )
@ -250,7 +250,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.Now;
otherWar.WarBeginning = DateTime.UtcNow;
otherGuild.AcceptedWars.Add( otherWar );
if( otherAlliance != null && m_Other.Alliance.IsMember( m_Other ) )

View file

@ -1232,7 +1232,7 @@ namespace Server.Gumps
{
from.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
}
else if ( Core.ML && from.AccessLevel < AccessLevel.GameMaster && DateTime.Now <= m_House.BuiltOn.AddHours ( 1 ) )
else if ( Core.ML && from.AccessLevel < AccessLevel.GameMaster && DateTime.UtcNow <= m_House.BuiltOn.AddHours ( 1 ) )
{
from.SendLocalizedMessage( 1080178 ); // You must wait one hour between each house demolition.
}

View file

@ -36,13 +36,13 @@ namespace Server.Gumps
}
}
if ( ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
if ( ai.Attacker.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
toGive.Add( ai.Attacker );
}
foreach ( AggressorInfo ai in m.Aggressed )
{
if ( ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
if ( ai.Defender.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
toGive.Add( ai.Defender );
}

View file

@ -36,7 +36,7 @@ namespace Server.Gumps
AddLabel( 45, y, 0x481, String.Format( "{0} ({1})", inventory.ShopName, inventory.VendorName ) );
TimeSpan expire = inventory.ExpireTime - DateTime.Now;
TimeSpan expire = inventory.ExpireTime - DateTime.UtcNow;
int hours = (int) expire.TotalHours;
AddLabel( 320, y, 0x481, hours.ToString() );