private static void Save( WorldSaveEventArgs e ) { if ( !Directory.Exists( "Saves/Accounts" ) ) Directory.CreateDirectory( "Saves/Accounts" ); string filePath = Path.Combine( "Saves/Accounts", "accounts.xml" ); using ( StreamWriter op = new StreamWriter( filePath ) ) { XmlTextWriter xml = new XmlTextWriter( op ); xml.Formatting = Formatting.Indented; xml.IndentChar = '\t'; xml.Indentation = 1; xml.WriteStartDocument( true ); xml.WriteStartElement( "accounts" ); xml.WriteAttributeString( "count", Accounts.Count.ToString() ); foreach ( Account account in Accounts.GetAccounts() ) account.Save( xml ); xml.WriteEndElement(); xml.Close(); } }
/// <summary> /// Saves persistent data /// </summary> private static void OnWorldSave( WorldSaveEventArgs args ) { if( !Directory.Exists(DataPath) ) Directory.CreateDirectory(DataPath); BinaryFileWriter writer = new BinaryFileWriter(DataFile, true); writer.Write((int)EoCTable.Count); foreach( KeyValuePair<Player, EoCContext> kvp in EoCTable ) { if( kvp.Key == null || kvp.Key.Deleted ) { writer.Write(false); } else { writer.Write(true); writer.WriteMobile<Player>(kvp.Key); kvp.Value.Serialize(writer); } } writer.Write((int)HitsTable.Count); foreach( KeyValuePair<Player, HitsTimer> kvp in HitsTable ) { if( kvp.Key != null && !kvp.Key.Deleted && kvp.Value.Running ) { writer.Write(true); writer.WriteMobile<Player>(kvp.Key); writer.Write(kvp.Value.Next); } else { writer.Write(false); } } writer.Close(); }