public static void Save( bool message ) {
if ( m_Saving || AsyncWriter.ThreadCount > 0 )
return;
NetState.FlushAll();
NetState.Pause();
m_Saving = true;
if ( message )
Broadcast( 0x35, true, "The world is saving, please wait." );
SaveStrategy strategy = SaveStrategy.Acquire();
Console.WriteLine( "Core: Using {0} save strategy", strategy.Name.ToLowerInvariant() );
Console.Write( "World: Saving..." );
Stopwatch watch = Stopwatch.StartNew();
if ( !Directory.Exists( "Saves/Mobiles/" ) )
Directory.CreateDirectory( "Saves/Mobiles/" );
if ( !Directory.Exists( "Saves/Items/" ) )
Directory.CreateDirectory( "Saves/Items/" );
if ( !Directory.Exists( "Saves/Guilds/" ) )
Directory.CreateDirectory( "Saves/Guilds/" );
/*using ( SaveMetrics metrics = new SaveMetrics() ) {*/
strategy.Save( null );
/*}*/
try {
EventSink.InvokeWorldSave( new WorldSaveEventArgs( message ) );
} catch ( Exception e ) {
throw new Exception( "World Save event threw an exception. Save failed!", e );
}
watch.Stop();
m_Saving = false;
ProcessSafetyQueues();
strategy.ProcessDecay();
Console.WriteLine( "done in {0:F2} seconds.", watch.Elapsed.TotalSeconds );
if ( message )
Broadcast( 0x35, true, "World save complete. The entire process took {0:F1} seconds.", watch.Elapsed.TotalSeconds );
NetState.Resume();
}