Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -3,78 +3,82 @@ using Server.Commands;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class AutoRestart : Timer
|
||||
{
|
||||
public static bool Enabled; // is the script enabled?
|
||||
public class AutoRestart : Timer
|
||||
{
|
||||
public static bool Enabled; // is the script enabled?
|
||||
|
||||
private static TimeSpan RestartTime = TimeSpan.FromHours( 2.0 ); // time of day at which to restart
|
||||
private static TimeSpan RestartDelay = TimeSpan.Zero; // how long the server should remain active before restart (period of 'server wars')
|
||||
private static TimeSpan RestartTime = TimeSpan.FromHours(2.0); // time of day at which to restart
|
||||
|
||||
private static TimeSpan WarningDelay = TimeSpan.FromMinutes( 1.0 ); // at what interval should the shutdown message be displayed?
|
||||
private static TimeSpan
|
||||
RestartDelay =
|
||||
TimeSpan.Zero; // how long the server should remain active before restart (period of 'server wars')
|
||||
|
||||
private static DateTime m_RestartTime;
|
||||
private static TimeSpan
|
||||
WarningDelay = TimeSpan.FromMinutes(1.0); // at what interval should the shutdown message be displayed?
|
||||
|
||||
public static bool Restarting { get; private set; }
|
||||
private static DateTime m_RestartTime;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "Restart", AccessLevel.Administrator, Restart_OnCommand );
|
||||
new AutoRestart().Start();
|
||||
}
|
||||
public AutoRestart() : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
|
||||
public static void Restart_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if ( Restarting )
|
||||
{
|
||||
e.Mobile.SendMessage( "The server is already restarting." );
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage( "You have initiated server shutdown." );
|
||||
Enabled = true;
|
||||
m_RestartTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
m_RestartTime = DateTime.UtcNow.Date + RestartTime;
|
||||
|
||||
public AutoRestart() : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
if (m_RestartTime < DateTime.UtcNow)
|
||||
m_RestartTime += TimeSpan.FromDays(1.0);
|
||||
}
|
||||
|
||||
m_RestartTime = DateTime.UtcNow.Date + RestartTime;
|
||||
public static bool Restarting{ get; private set; }
|
||||
|
||||
if ( m_RestartTime < DateTime.UtcNow )
|
||||
m_RestartTime += TimeSpan.FromDays( 1.0 );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Restart", AccessLevel.Administrator, Restart_OnCommand);
|
||||
new AutoRestart().Start();
|
||||
}
|
||||
|
||||
private void Warning_Callback()
|
||||
{
|
||||
World.Broadcast( 0x22, true, "The server is going down shortly." );
|
||||
}
|
||||
public static void Restart_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (Restarting)
|
||||
{
|
||||
e.Mobile.SendMessage("The server is already restarting.");
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage("You have initiated server shutdown.");
|
||||
Enabled = true;
|
||||
m_RestartTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
private void Restart_Callback()
|
||||
{
|
||||
Core.Kill( true );
|
||||
}
|
||||
private void Warning_Callback()
|
||||
{
|
||||
World.Broadcast(0x22, true, "The server is going down shortly.");
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( Restarting || !Enabled )
|
||||
return;
|
||||
private void Restart_Callback()
|
||||
{
|
||||
Core.Kill(true);
|
||||
}
|
||||
|
||||
if ( DateTime.UtcNow < m_RestartTime )
|
||||
return;
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Restarting || !Enabled)
|
||||
return;
|
||||
|
||||
if ( WarningDelay > TimeSpan.Zero )
|
||||
{
|
||||
Warning_Callback();
|
||||
DelayCall( WarningDelay, WarningDelay, Warning_Callback );
|
||||
}
|
||||
if (DateTime.UtcNow < m_RestartTime)
|
||||
return;
|
||||
|
||||
AutoSave.Save();
|
||||
if (WarningDelay > TimeSpan.Zero)
|
||||
{
|
||||
Warning_Callback();
|
||||
DelayCall(WarningDelay, WarningDelay, Warning_Callback);
|
||||
}
|
||||
|
||||
Restarting = true;
|
||||
AutoSave.Save();
|
||||
|
||||
DelayCall( RestartDelay, Restart_Callback );
|
||||
}
|
||||
}
|
||||
Restarting = true;
|
||||
|
||||
DelayCall(RestartDelay, Restart_Callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue