Example #1
0
			public void Save()
			{
				string str = "Saving game...";
				allConnectedAccounts.BroadCastMessage( str );
				DateTime now = DateTime.Now;
				//allAccounts.Serialize( new GenericWriter( "accounts.bin" ) );
				GenericWriter gw = null;
				if ( File.Exists( World.Path + "accounts.4.xml" ) )
					File.Copy( World.Path + "accounts.4.xml", World.Path + "accounts.5.xml", true );
				if ( File.Exists( World.Path + "accounts.3.xml" ) )
					File.Copy( World.Path + "accounts.3.xml", World.Path + "accounts.4.xml", true );
				if ( File.Exists( World.Path + "accounts.2.xml" ) )
					File.Copy( World.Path + "accounts.2.xml", World.Path + "accounts.3.xml", true );
				if ( File.Exists( World.Path + "accounts.xml" ) )
					File.Copy( World.Path + "accounts.xml", World.Path + "accounts.2.xml", true );
				allAccounts.Save( World.Path + "accounts.xml" );
				if ( allGameObjects.Dirty )
				{
					allGameObjects.Serialize( gw = new GenericWriter( World.Path + "objects.bin" ) );
				}
				if ( trajets.Dirty )
				{
					if ( File.Exists( "coord.bin" ) )
						File.Copy( World.Path + "coord.bin", World.Path + "coord" + DateTime.Now.Ticks.ToString() + ".bin", true );
					trajets.Serialize( gw = new GenericWriter( World.Path + "coord.bin" ) );
				}
				if ( allSpawners.Dirty )
				{
					allSpawners.Serialize( gw = new GenericWriter( World.Path + "spawnpoints.bin" ) );
				}

				if ( File.Exists( World.Path + "savegame.4.bin" ) )
					File.Copy( World.Path + "savegame.4.bin", World.Path + "savegame.5.bin", true );
				if ( File.Exists( World.Path + "savegame.3.bin" ) )
					File.Copy( World.Path + "savegame.3.bin", World.Path + "savegame.4.bin", true );
				if ( File.Exists( World.Path + "savegame.2.bin" ) )
					File.Copy( World.Path + "savegame.2.bin", World.Path + "savegame.3.bin", true );
				if ( File.Exists( World.Path + "savegame.bin" ) )
					File.Copy( World.Path + "savegame.bin", World.Path + "savegame.2.bin", true );				

				gw = new GenericWriter( World.Path + "savegame.bin" );	
				allMobiles.Serialize( gw );
				foreach( Account acc in allAccounts )
					foreach( Character ch in acc.characteres )
					{
						gw.Write( (int)1 );
						ch.Serialize( gw );
					}
				gw.Write( (int)0 );
				gw.Close();

	
				if ( onSave != null )
					onSave();

				//GC.Collect();
				/*Process p = Process.GetCurrentProcess();
				Console.WriteLine("{0}",p.MinWorkingSet,p.MaxWorkingSet );*/
				TimeSpan ts = DateTime.Now.Subtract( now );
				str = "Game saved in " + ts.TotalSeconds.ToString() + " sec";
				allConnectedAccounts.BroadCastMessage( str );
			}
Example #2
0
 public virtual void Serialize( GenericWriter gw )
 {
     gw.Write( (int)0 );
     gw.Write( (int)List.Count );
     foreach( Trajet t in this )
         t.Serialize( gw );
     gw.Close();
     Dirty = false;
 }
Example #3
0
 public void Serialize( GenericWriter gw )
 {
     gw.Write( (int)0 );
     gw.Write( (int)this.Count );
     foreach( Account a in this )
     {
         a.Serialize( gw );
     }
     gw.Close();
 }
Example #4
0
 public virtual void Serialize( GenericWriter gw )
 {
     gw.Write( (int)0 );
     foreach( GameObject m in this )
     {
         if ( m.SpawnerLink == null )
         {
             gw.Write( 1 );
             m.Serialize( gw );
         }
     }
     gw.Write( 0 );
     gw.Close();
     dirty = false;
 }
Example #5
0
 public virtual void Serialize( GenericWriter gw )
 {
     gw.Write( (int)0 );
     foreach( BaseSpawner m in this )
     {
         gw.Write( 1 );
         if ( m is MobileSpawner )
             gw.Write( 0 );
         else
             gw.Write( 1 );
         m.Serialize( gw );
     }
     gw.Write( 0 );
     gw.Write( (int)World.regSpawners.Count );
     //Console.WriteLine("{0} spawn path", World.regSpawners.Count );
     IDictionaryEnumerator regcountEnumerator = World.regSpawners.GetEnumerator();
     while ( regcountEnumerator.MoveNext() )
     {
         if ( regcountEnumerator.Value == null )
             continue;
         gw.Write( (int)regcountEnumerator.Key );
         gw.Write( (int)( regcountEnumerator.Value as ArrayList ).Count );
         foreach( int t in ( regcountEnumerator.Value as ArrayList ) )
         {
             gw.Write( t );
         }
     }
     gw.Close();
     dirty = false;
 }