Exemplo n.º 1
1
		public 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", m_Accounts.Count.ToString() );

				foreach ( Account a in GetAccounts() )
					a.Save( xml );

				xml.WriteEndElement();

				xml.Close();
			}
		}
Exemplo n.º 2
0
		private static void EventSink_WorldSave(WorldSaveEventArgs e)
		{
			List<BaseCollectionMobile> newMobiles = new List<BaseCollectionMobile>();
			foreach (BaseCollectionMobile mob in m_Mobiles)
			{
				if (!mob.Deleted)
					newMobiles.Add(mob);
			}
			m_Mobiles = newMobiles;

			Persistence.Serialize(
				m_Path,
				writer =>
				{
					writer.WriteMobileList(m_Mobiles);
					writer.Write(m_Mobiles.Count);
					foreach(BaseCollectionMobile mob in m_Mobiles)
					{
						writer.Write((int)mob.CollectionID);
						CollectionData data = mob.GetData();
						data.Write(writer);
						m_Collections[mob.CollectionID] = data;
					}
				});
		}
Exemplo n.º 3
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write((int)2);

                writer.Write(Systems.Count);
                Systems.ForEach(s =>
                {
                    writer.Write((int)s.Loyalty);
                    s.Serialize(writer);
                });
            });
        }
Exemplo n.º 4
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            foreach (TownHouseSign sign in new ArrayList(TownHouseSign.AllSigns))
            {
                sign.ValidateOwnership();
            }

            foreach (TownHouse house in new ArrayList(TownHouse.AllTownHouses))
            {
                if (house.Deleted)
                {
                    TownHouse.AllTownHouses.Remove(house);
                    continue;
                }
            }
        }
Exemplo n.º 5
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Instance.Entries == null ? 0 : Instance.Entries.Count);

                if (Instance.Entries != null)
                {
                    Instance.Entries.ForEach(entry => entry.Serialize(writer));
                }
            });
        }
Exemplo n.º 6
0
        // plasma : save town crier global list
        public static void OnSave(WorldSaveEventArgs e)
        {
            System.Console.WriteLine("Town Crier Global Saving...");
            if (Instance.Entries == null)
            {
                return;
            }

            try
            {
                if (!Directory.Exists("Saves/AngelIsland"))
                {
                    Directory.CreateDirectory("Saves/AngelIsland");
                }

                string filePath = Path.Combine("Saves/AngelIsland", "TCGL.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("TCGL");
                    // just to be complete..
                    xml.WriteAttributeString("Count", m_Instance.Entries.Count.ToString());
                    // Now write each entry
                    foreach (TownCrierEntry tce in Instance.Entries)
                    {
                        tce.Save(xml);
                    }
                    //and end doc
                    xml.WriteEndElement();

                    xml.Close();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Error in GlobalTownCrierEntryList.OnSave(): " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 7
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Permission.Count);

                Permission.ForEach(s =>
                {
                    writer.Write(s.Mobile);
                    writer.Write(s.Reward);
                });
            });
        }
Exemplo n.º 8
0
 /// <summary>
 /// SaveWorld event handler which notifies users that the server may lag
 /// </summary>
 public void OnSaveWorld(WorldSaveEventArgs args)
 {
     if (TShock.Config.AnnounceSave)
     {
         // Protect against internal errors causing save failures
         // These can be caused by an unexpected error such as a bad or out of date plugin
         try
         {
             TShock.Utils.Broadcast("正在保存世界地图数据, 可能会造成片刻的卡顿.", Color.Red);
         }
         catch (Exception ex)
         {
             TShock.Log.Error("保存时的通知失败.");
             TShock.Log.Error(ex.ToString());
         }
     }
 }
Exemplo n.º 9
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Table.Count);

                foreach (var l in Table)
                {
                    writer.Write(l.Key);
                    writer.Write(l.Value);
                }
            });
        }
Exemplo n.º 10
0
 /// <summary>
 /// SaveWorld event handler which notifies users that the server may lag
 /// </summary>
 public void OnSaveWorld(WorldSaveEventArgs args)
 {
     if (TShock.Config.AnnounceSave)
     {
         // Protect against internal errors causing save failures
         // These can be caused by an unexpected error such as a bad or out of date plugin
         try
         {
             TShock.Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red);
         }
         catch (Exception ex)
         {
             TShock.Log.Error("World saved notification failed");
             TShock.Log.Error(ex.ToString());
         }
     }
 }
Exemplo n.º 11
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Donations.Count);

                Donations.ToList().ForEach(s =>
                {
                    writer.Write(s.Key);
                    writer.Write(s.Value);
                });
            });
        }
Exemplo n.º 12
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);     // version

                writer.Write(ReforgingContexts.Count);

                foreach (var kvp in ReforgingContexts)
                {
                    writer.Write(kvp.Key);
                    kvp.Value.Serialize(writer);
                }
            });
        }
Exemplo n.º 13
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);                         // version

                writer.Write(DistillationSystem.Contexts.Count);

                foreach (KeyValuePair <Mobile, DistillationContext> kvp in DistillationSystem.Contexts)
                {
                    writer.Write(kvp.Key);
                    kvp.Value.Serialize(writer);
                }
            });
        }
Exemplo n.º 14
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(FellowshipChainList.Count);

                foreach (var chain in FellowshipChainList)
                {
                    writer.Write(chain.Key);
                    writer.Write((int)chain.Value);
                }
            });
        }
Exemplo n.º 15
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Entries.Count);

                for (int i = 0; i < Entries.Count; i++)
                {
                    writer.Write((int)Entries[i].EventType);
                    Entries[i].Serialize(writer);
                }
            });
        }
Exemplo n.º 16
0
        public static void EventSink_WorldSave(WorldSaveEventArgs e)
        {
            foreach (Server.Network.NetState ns in Server.Network.NetState.Instances)
            {
                if (ns.Mobile == null)
                {
                    continue;
                }

                ns.Mobile.SendGump(new Server.Gumps.SaveGump());

                // change ( 2.0 ) to how mamy seconds you want the gump to remain open
                Timer.DelayCall(TimeSpan.FromSeconds(3.5), new TimerStateCallback(CloseGump), ns.Mobile);
            }

            World.Save();
        }
Exemplo n.º 17
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(1);
                writer.Write(true);

                writer.Write(CreateTable.Count);
                foreach (var kvp in CreateTable)
                {
                    writer.Write(kvp.Key);
                    writer.Write(kvp.Value);
                }
            });
        }
Exemplo n.º 18
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(PurchaseList.Count);

                PurchaseList.ForEach(s =>
                {
                    writer.Write(s.Account);
                    writer.Write(s.Purchase);
                });
            });
        }
Exemplo n.º 19
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Constellations.Count);

                for (var index = 0; index < Constellations.Count; index++)
                {
                    ConstellationInfo info = Constellations[index];
                    info.Serialize(writer);
                }
            });
        }
Exemplo n.º 20
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                _FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(_Table.Count);

                foreach (var t in _Table)
                {
                    writer.Write(t.Key);
                    writer.Write((int)t.Value);
                }
            });
        }
Exemplo n.º 21
0
        private static void OnSave(WorldSaveEventArgs e)
        {
            Console.WriteLine("Rewards Saving...");

            try
            {
                WriteXml(e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                Console.WriteLine("Error Saving Rewards.");
                Console.WriteLine("Exception Message :  {0}", ex.ToString());
                Console.WriteLine("Rewards system has been disabled.");
                Enabled = false;
            }
        }
Exemplo n.º 22
0
        private static void EventSink_WorldSave(WorldSaveEventArgs e)
        {
            int queue   = 0;
            int deleted = RemovedDeletedQueue(out queue);

            if (queue != 0)
            {
                Console.Write("{0} Forum Posts Deleted...", deleted);
            }

            string SavePath = Path.Combine(m_SavePath, "forumdata.sig");

            if (!Directory.Exists(m_SavePath))
            {
                Directory.CreateDirectory(m_SavePath);
            }

            GenericWriter bin = new BinaryFileWriter(SavePath, true);

            try
            {
                bin.Write(( int )0);                  //Versioning

                WritePlayerStatistics(bin);

                bin.Write(( int )(m_Threads.Count));
                foreach (ThreadEntry te in m_Threads)
                {
                    te.Serialize(bin);
                }

                bin.WriteMobileList(m_Moderators);
                bin.Write(( int )m_ThreadDeleteAccessLevel);
                bin.Write(( int )m_ThreadLockAccesLevel);
                bin.Write(( bool )m_AutoCleanup);
                bin.Write(( int )m_AutoCleanupDays);
                bin.Write(( int )m_MinPostCharactersCount);
                bin.Write(( int )m_MaxPostCharactersCount);
                bin.Close();
            }
            catch (Exception err)
            {
                bin.Close();
                Console.Write("An error occurred while trying to save the forums. {0}", err.ToString());
            }
        }
Exemplo n.º 23
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write((int)0);

                if (BestWave != null)
                {
                    writer.Write(1);
                    BestWave.Serialize(writer);
                }
                else
                {
                    writer.Write(0);
                }

                writer.Write(BestSingle.Count);
                foreach (KeyValuePair <Mobile, long> kvp in BestSingle)
                {
                    writer.Write(kvp.Key);
                    writer.Write(kvp.Value);
                }

                writer.Write(OverallTotal.Count);
                foreach (KeyValuePair <Mobile, long> kvp in OverallTotal)
                {
                    writer.Write(kvp.Key);
                    writer.Write(kvp.Value);
                }

                writer.Write(Top20.Count);
                foreach (Dictionary <Mobile, long> dic in Top20)
                {
                    writer.Write(dic.Count);
                    foreach (KeyValuePair <Mobile, long> kvp in dic)
                    {
                        writer.Write(kvp.Key);
                        writer.Write(kvp.Value);
                    }
                }
                ;
            });
        }
Exemplo n.º 24
0
        /// <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();
        }
Exemplo n.º 25
0
		private static void OnSave(WorldSaveEventArgs e)
		{
			Persistence.Serialize(
				FilePath,
				writer =>
				{
					writer.Write(0); // version

					writer.Write(DisguiseTimers.Timers.Count);

					foreach (var m in DisguiseTimers.Timers.Keys.OfType<Mobile>())
					{
						writer.Write(m);
						writer.Write(DisguiseTimers.TimeRemaining(m));
						writer.Write(m.NameMod);
					}
				});
		}
Exemplo n.º 26
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(2);

                writer.Write(Systems.Count);
                for (var index = 0; index < Systems.Count; index++)
                {
                    var s = Systems[index];

                    writer.Write((int)s.Loyalty);
                    s.Serialize(writer);
                }
            });
        }
Exemplo n.º 27
0
        private static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);                         // version

                writer.Write(DisguiseTimers.Timers.Count);

                foreach (var m in DisguiseTimers.Timers.Keys.OfType <Mobile>())
                {
                    writer.Write(m);
                    writer.Write(DisguiseTimers.TimeRemaining(m));
                    writer.Write(m.NameMod);
                }
            });
        }
Exemplo n.º 28
0
        private static void Event_WorldSave(WorldSaveEventArgs args)
        {
            try
            {
                if (!Directory.Exists(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                }

                BinaryFileWriter writer = new BinaryFileWriter(SaveFile, true);

                Serialize(writer);

                ConstructXML();
            }

            catch { Console.WriteLine("Error: Event_WorldSave Failed in Alliance Definition."); }
        }
Exemplo n.º 29
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(AllianceEntries.Count);
                for (var index = 0; index < AllianceEntries.Count; index++)
                {
                    var entry = AllianceEntries[index];
                    entry.Serialize(writer);
                }

                writer.Write(MoonstonePowerGeneratorAddon.Boss);
            });
        }
Exemplo n.º 30
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            System.Console.WriteLine("TCCS Saving...");

            try
            {
                if (!Directory.Exists("Saves/AngelIsland"))
                {
                    Directory.CreateDirectory("Saves/AngelIsland");
                }

                string filePath = Path.Combine("Saves/AngelIsland", "TCCS.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("TCCS");

                    xml.WriteAttributeString("count", TCCS.TheList.Count.ToString());

                    foreach (ListEntry le in TCCS.TheList)
                    {
                        le.Save(xml);
                    }

                    xml.WriteEndElement();

                    xml.Close();
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                System.Console.WriteLine("Error in TCCS.OnSave(): " + exc.Message);
                System.Console.WriteLine(exc.StackTrace);
            }
        }
Exemplo n.º 31
0
        //public static void OnKill(object sender, GetDataHandlers.KillMeEventArgs args)
        //{
        //    SendMessage("*" + args.PlayerDeathReason.GetDeathText(args.Player.Name).ToString() + "*"); //.GetDeathText(args.Player.Name).ToString()

        //    IEnumerable<TSPlayer> alive = from ply in TShock.Players
        //                                  where !ply.Dead && ply != null && ply.Name != ""
        //                                  select ply;
        //    if (TShock.Utils.GetActivePlayerCount() > 0 && Plugin4PDA.Bosses.Count() > 0)
        //    {
        //        if (!alive.Any())
        //        {
        //            string bosses = "";
        //            foreach (Plugin4PDA.BossFight boss in Plugin4PDA.Bosses)
        //            {
        //                if (bosses == "")
        //                    bosses = boss.Boss.FullName;
        //                else
        //                    bosses += ", " + boss.Boss.FullName;
        //            }

        //            Plugin4PDA.Bosses.Clear();

        //            TSPlayer.All.SendErrorMessage("Последний игрок(" + args.Player.Name + ") погиб и босс(ы) " + bosses + " улетел(и)!");
        //            SendMessage(null, "***Последний игрок (" + args.Player.Name + ") погиб и босс(ы) __" + bosses + "__ улетел(и)!***"); //.GetDeathText(args.Player.Name).ToString()
        //        }
        //    }
        //}

        public static async void OnSaveWorld(WorldSaveEventArgs args)
        {
            if (TShock.Config.AnnounceSave)
            {
                // Protect against internal errors causing save failures
                // These can be caused by an unexpected error such as a bad or out of date plugin
                try
                {
                    var ch = await Discord.DiscordBot.GetChannelAsync(Discord.Config.ChatID);

                    await Discord.DiscordBot.SendMessageAsync(ch, "*Saving world...*");
                }
                catch (Exception ex)
                {
                    TShock.Log.Error("World saved notification failed");
                    TShock.Log.Error(ex.ToString());
                }
            }
        }
Exemplo n.º 32
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(0);

                writer.Write(Permission.Count);

                for (var index = 0; index < Permission.Count; index++)
                {
                    var s = Permission[index];

                    writer.Write(s.Mobile);
                    writer.Write(s.Reward);
                }
            });
        }
Exemplo n.º 33
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(1);     // version

                writer.Write(AnvilEntries.Count);
                foreach (var kvp in AnvilEntries)
                {
                    writer.Write(kvp.Key);
                    kvp.Value.Serialize(writer);
                }

                writer.Write(Contexts.Count);
                Contexts.ForEach(c => c.Serialize(writer));
            });
        }
 public static void UpdatePlayerVendors(WorldSaveEventArgs e)
 {
     m_VendorItems.Clear();
     int count = 0;
     foreach (Mobile mob in World.Mobiles.Values)
     {
         if (mob is PlayerVendor)
         {
             PlayerVendor vendor = mob as PlayerVendor;
             if (vendor.Owner != null)
             {
                 processContainer(vendor, vendor.Backpack);
                 count++;
             }
         }
     }
     m_LastVendorUpdate = DateTime.Now;
     m_NextVendorUpdate = m_LastVendorUpdate + m_WorldSaveInterval;
     Console.WriteLine("Caching " + count + " Player Vendors");
 }
Exemplo n.º 35
0
		private static void OnSave(WorldSaveEventArgs e)
		{
			Persistence.Serialize(
				_FilePath,
				writer =>
				{
					writer.Write(0); // version

					writer.Write(PageQueue.List.Count);

					foreach (PageEntry pe in PageQueue.List)
					{
						writer.Write(pe.Sender);
						writer.Write(pe.Message);
						writer.Write((int)pe.Type);
						writer.Write(pe.Handler);
						writer.Write(pe.Sent);
						writer.Write(pe.PageLocation);
						writer.Write(pe.PageMap);

					}
				});
		}
Exemplo n.º 36
0
 private static void EventSink_WorldSave( WorldSaveEventArgs e )
 {
     m_Types.Clear();
 }
Exemplo n.º 37
0
 private static void EventSink_WorldSave(WorldSaveEventArgs args)
 {
     GrowAll();
 }
Exemplo n.º 38
0
 private static void EventSink_WorldSave(WorldSaveEventArgs e)
 {
     new UpdateAllTimer().Start();
 }
		private static void EventSink_WorldSave(WorldSaveEventArgs e)
		{
			Persistence.Serialize(
				m_Path,
				writer =>
				{
					writer.Write(0); // Version
					writer.Write(m_Initialized);
					writer.Write(m_LastRotate);
					writer.WriteItemList(m_AllSpawns, true);
				});
		}
Exemplo n.º 40
0
		public static void Save(WorldSaveEventArgs e)
		{
			Console.WriteLine("Account information Saving...");

			if (!Directory.Exists("Saves/Accounts"))
				Directory.CreateDirectory("Saves/Accounts");

			string filePath = Path.Combine("Saves/Accounts", "accounts.xml");

			bool bNotSaved = true;
			int attempt = 0;
			while (bNotSaved && attempt < 3)
			{
				try
				{
					attempt++;
					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", m_Accounts.Count.ToString());

						foreach (Account a in Accounts.Table.Values)
							a.Save(xml);

						xml.WriteEndElement();

						xml.Close();

						bNotSaved = false;
					}
				}
				catch (Exception ex)
				{
					LogHelper.LogException(ex);
					System.Console.WriteLine("Caught exception in Accounts.Save: {0}", ex.Message);
					System.Console.WriteLine(ex.StackTrace);
					System.Console.WriteLine("Will attempt to recover three times.");
				}
			}
		}
Exemplo n.º 41
0
		public static void Save(WorldSaveEventArgs e)
		{
			if (EntityAttachments == null)
			{
				return;
			}

			CleanUp();

			if (!Directory.Exists("Saves/Attachments"))
			{
				Directory.CreateDirectory("Saves/Attachments");
			}

			string filePath = Path.Combine("Saves/Attachments", "Attachments.bin"); // the attachment serializations
			string imaPath = Path.Combine("Saves/Attachments", "Attachments.ima"); // the item/mob attachment tables
			string fpiPath = Path.Combine("Saves/Attachments", "Attachments.fpi"); // the file position indices

			BinaryFileWriter writer = null;
			BinaryFileWriter imawriter = null;
			BinaryFileWriter fpiwriter = null;

			try
			{
				writer = new BinaryFileWriter(filePath, true);
				imawriter = new BinaryFileWriter(imaPath, true);
				fpiwriter = new BinaryFileWriter(fpiPath, true);
			}
			catch (Exception err)
			{
				ErrorReporter.GenerateErrorReport(err.ToString());
				return;
			}

			if (writer != null && imawriter != null && fpiwriter != null)
			{
				// save the current global attachment serial state
				ASerial.GlobalSerialize(writer);

				// remove all deleted attachments
				FullDefrag();

				// save the attachments themselves
				if (AllAttachments != null)
				{
					writer.Write(AllAttachments.Count);

					var valuearray = new XmlAttachment[AllAttachments.Count];
					AllAttachments.Values.CopyTo(valuearray, 0);

					var keyarray = new int[AllAttachments.Count];
					AllAttachments.Keys.CopyTo(keyarray, 0);

					for (int i = 0; i < keyarray.Length; i++)
					{
						// write the key
						writer.Write(keyarray[i]);

						XmlAttachment a = valuearray[i];

						// write the value type
						writer.Write(a.GetType().ToString());

						// serialize the attachment itself
						a.Serialize(writer);

						// save the fileposition index
						fpiwriter.Write(writer.Position);
					}
				}
				else
				{
					writer.Write(0);
				}

				writer.Close();

				/* // Collapsed into a single IEntity Hash
                // save the hash table info for items and mobiles
                // mobile attachments
                if (XmlAttach.MobileAttachments != null)
                {
                    imawriter.Write(XmlAttach.MobileAttachments.Count);

                    object[] valuearray = new object[XmlAttach.MobileAttachments.Count];
                    XmlAttach.MobileAttachments.Values.CopyTo(valuearray, 0);

                    object[] keyarray = new object[XmlAttach.MobileAttachments.Count];
                    XmlAttach.MobileAttachments.Keys.CopyTo(keyarray, 0);

                    for (int i = 0; i < keyarray.Length; i++)
                    {
                        // write the key
                        imawriter.Write((Mobile)keyarray[i]);

                        // write out the attachments
                        ArrayList alist = (ArrayList)valuearray[i];

                        imawriter.Write((int)alist.Count);
                        foreach (XmlAttachment a in alist)
                        {
                            // write the attachment serial
                            imawriter.Write((int)a.Serial.Value);

                            // write the value type
                            imawriter.Write((string)a.GetType().ToString());

                            // save the fileposition index
                            fpiwriter.Write((long)imawriter.Position);
                        }
                    }
                }
                else
                {
                    // no mobile attachments
                    imawriter.Write((int)0);
                }

                // item attachments
                if (XmlAttach.ItemAttachments != null)
                {
                    imawriter.Write(XmlAttach.ItemAttachments.Count);

                    object[] valuearray = new object[XmlAttach.ItemAttachments.Count];
                    XmlAttach.ItemAttachments.Values.CopyTo(valuearray, 0);

                    object[] keyarray = new object[XmlAttach.ItemAttachments.Count];
                    XmlAttach.ItemAttachments.Keys.CopyTo(keyarray, 0);

                    for (int i = 0; i < keyarray.Length; i++)
                    {
                        // write the key
                        imawriter.Write((Item)keyarray[i]);

                        // write out the attachments			             
                        ArrayList alist = (ArrayList)valuearray[i];

                        imawriter.Write((int)alist.Count);
                        foreach (XmlAttachment a in alist)
                        {
                            // write the attachment serial
                            imawriter.Write((int)a.Serial.Value);

                            // write the value type
                            imawriter.Write((string)a.GetType().ToString());

                            // save the fileposition index
                            fpiwriter.Write((long)imawriter.Position);
                        }
                    }
                }
                else
                { 
                    // no item attachments
                    imawriter.Write((int)0);
                }*/

				// Alan MOD
				// save the hash table info for items and mobiles
				// mobile attachments

				if (EntityAttachments != null)
				{
					imawriter.Write(EntityAttachments.Count);

					var valuearray = new ArrayList[EntityAttachments.Count];
					EntityAttachments.Values.CopyTo(valuearray, 0);

					var keyarray = new int[EntityAttachments.Count];
					EntityAttachments.Keys.CopyTo(keyarray, 0);

					for (int i = 0; i < keyarray.Length; i++)
					{
						// write the key
						imawriter.Write(keyarray[i]);

						// write out the attachments
						ArrayList alist = valuearray[i];

						imawriter.Write(alist.Count);
						foreach (XmlAttachment a in alist)
						{
							// write the attachment serial
							imawriter.Write(a.Serial.Value);

							// write the value type
							imawriter.Write(a.GetType().ToString());

							// save the fileposition index
							fpiwriter.Write(imawriter.Position);
						}
					}
				}
				else
				{
					// no mobile attachments
					imawriter.Write(0);
				}

				imawriter.Write(0);
				// pretend no item attachments and leave the deserialization as-is -- this way deserialization will still work with older saves -Alan
				// END ALAN MOD

				imawriter.Close();
				fpiwriter.Close();
			}
		}
Exemplo n.º 42
0
		private static void EventSink_WorldSave(WorldSaveEventArgs e)
		{
			try
			{
				if (!Directory.Exists(SaveDirectory))
					Directory.CreateDirectory(SaveDirectory);
				GenericWriter writer = new BinaryFileWriter(new FileStream(PointsFile, FileMode.OpenOrCreate), true);
				InternalSave(writer);
				writer.Close();
				Console.WriteLine("Onsite Dueling System: DuelPoints saved!");
			}
			catch (Exception ex)
			{
				Console.WriteLine("Onsite Dueling System: Save failed!");
				Console.WriteLine("Caught an exception: {0}", ex.ToString());
			}
		}
Exemplo n.º 43
0
		private static void EventSink_WorldSave( WorldSaveEventArgs e )
		{
			Save();
		}
Exemplo n.º 44
0
        private static void Serialize(WorldSaveEventArgs e)
        {
            if (!Directory.Exists(m_Directory))
                Directory.CreateDirectory(m_Directory);

            GenericWriter writer = new BinaryFileWriter(m_FilePath, true);

            writer.Write(Version);//version
            writer.Close();
        }
Exemplo n.º 45
0
 public static void Save( WorldSaveEventArgs e )
 {
     PurgeList();
 }
Exemplo n.º 46
0
		public static void Save(WorldSaveEventArgs e)
		{
			if (MobileAttachments == null && ItemAttachments == null)
			{
				return;
			}

			CleanUp();

			if (!Directory.Exists("Saves/Attachments"))
			{
				Directory.CreateDirectory("Saves/Attachments");
			}

			string filePath = Path.Combine("Saves/Attachments", "Attachments.bin"); // the attachment serializations
			string imaPath = Path.Combine("Saves/Attachments", "Attachments.ima"); // the item/mob attachment tables
			string fpiPath = Path.Combine("Saves/Attachments", "Attachments.fpi"); // the file position indices

			BinaryFileWriter writer = null;
			BinaryFileWriter imawriter = null;
			BinaryFileWriter fpiwriter = null;

			try
			{
				writer = new BinaryFileWriter(filePath, true);
				imawriter = new BinaryFileWriter(imaPath, true);
				fpiwriter = new BinaryFileWriter(fpiPath, true);
			}
			catch (Exception err)
			{
				ErrorReporter.GenerateErrorReport(err.ToString());
				return;
			}

			if (writer != null && imawriter != null && fpiwriter != null)
			{
				// save the current global attachment serial state
				ASerial.GlobalSerialize(writer);

				// remove all deleted attachments
				FullDefrag();

				// save the attachments themselves
				if (AllAttachments != null)
				{
					writer.Write(AllAttachments.Count);

					var valuearray = new object[AllAttachments.Count];
					AllAttachments.Values.CopyTo(valuearray, 0);

					var keyarray = new object[AllAttachments.Count];
					AllAttachments.Keys.CopyTo(keyarray, 0);

					for (int i = 0; i < keyarray.Length; i++)
					{
						// write the key
						writer.Write((int)keyarray[i]);

						XmlAttachment a = valuearray[i] as XmlAttachment;

						// write the value type
						writer.Write(a.GetType().ToString());

						// serialize the attachment itself
						a.Serialize(writer);

						// save the fileposition index
						fpiwriter.Write(writer.Position);
					}
				}
				else
				{
					writer.Write(0);
				}

				writer.Close();

				// save the hash table info for items and mobiles
				// mobile attachments
				if (MobileAttachments != null)
				{
					imawriter.Write(MobileAttachments.Count);

					var valuearray = new object[MobileAttachments.Count];
					MobileAttachments.Values.CopyTo(valuearray, 0);

					var keyarray = new object[MobileAttachments.Count];
					MobileAttachments.Keys.CopyTo(keyarray, 0);

					for (int i = 0; i < keyarray.Length; i++)
					{
						// write the key
						imawriter.Write((Mobile)keyarray[i]);

						// write out the attachments
						ArrayList alist = (ArrayList)valuearray[i];

						imawriter.Write(alist.Count);
						foreach (XmlAttachment a in alist)
						{
							// write the attachment serial
							imawriter.Write(a.Serial.Value);

							// write the value type
							imawriter.Write(a.GetType().ToString());

							// save the fileposition index
							fpiwriter.Write(imawriter.Position);
						}
					}
				}
				else
				{
					// no mobile attachments
					imawriter.Write(0);
				}

				// item attachments
				if (ItemAttachments != null)
				{
					imawriter.Write(ItemAttachments.Count);

					var valuearray = new object[ItemAttachments.Count];
					ItemAttachments.Values.CopyTo(valuearray, 0);

					var keyarray = new object[ItemAttachments.Count];
					ItemAttachments.Keys.CopyTo(keyarray, 0);

					for (int i = 0; i < keyarray.Length; i++)
					{
						// write the key
						imawriter.Write((Item)keyarray[i]);

						// write out the attachments			             
						ArrayList alist = (ArrayList)valuearray[i];

						imawriter.Write(alist.Count);
						foreach (XmlAttachment a in alist)
						{
							// write the attachment serial
							imawriter.Write(a.Serial.Value);

							// write the value type
							imawriter.Write(a.GetType().ToString());

							// save the fileposition index
							fpiwriter.Write(imawriter.Position);
						}
					}
				}
				else
				{
					// no item attachments
					imawriter.Write(0);
				}

				imawriter.Close();
				fpiwriter.Close();
			}
		}
Exemplo n.º 47
0
		private static void EventSink_WorldSave(WorldSaveEventArgs e)
		{
			Instance.Serialize();
		}
Exemplo n.º 48
0
 public static void OnSave(WorldSaveEventArgs e)
 {
     SaveRatings();
 }
Exemplo n.º 49
0
 public static void Save(WorldSaveEventArgs e)
 {
     for (int i = 0; i < m_AllHouses.Count; ++i)
         m_AllHouses[i].CheckDecay();
 }
Exemplo n.º 50
0
 public static void StartTimer(WorldSaveEventArgs args)
 {
     Timer.DelayCall(TimeSpan.FromSeconds(YardSettings.SecondsToCleanup), CleanYards);
 }
Exemplo n.º 51
0
 public static void EventSink_Save( WorldSaveEventArgs e )
 {
     FactionCollection factions = Faction.Factions;
     foreach ( Faction faction in factions )
     {
         faction.UpdateRanks();
     }
 }
Exemplo n.º 52
0
		private static void EventSink_WorldSave( WorldSaveEventArgs e )
		{
			int queue = 0;
			int deleted = RemovedDeletedQueue(out queue);

			if ( queue != 0 )
				Console.Write( "{0} Forum Posts Deleted...", deleted );
			
			string SavePath = Path.Combine( m_SavePath, "forumdata.sig" );

			if( !Directory.Exists( m_SavePath ) )
				Directory.CreateDirectory( m_SavePath );

			GenericWriter bin = new BinaryFileWriter( SavePath, true );
			
			try
			{
				bin.Write( ( int )0 );//Versioning

				WritePlayerStatistics( bin );
				
				bin.Write( ( int )( m_Threads.Count ) );
				foreach( ThreadEntry te in m_Threads )
				{
					te.Serialize( bin );
				}

				bin.WriteMobileList( m_Moderators );
				bin.Write( ( int )m_ThreadDeleteAccessLevel );
				bin.Write( ( int )m_ThreadLockAccesLevel );
				bin.Write( ( bool )m_AutoCleanup );
				bin.Write( ( int )m_AutoCleanupDays );
				bin.Write( ( int )m_MinPostCharactersCount );
				bin.Write( ( int )m_MaxPostCharactersCount );
				bin.Close();
			}
			catch( Exception err )
			{
				bin.Close();
				Console.Write( "An error occurred while trying to save the forums. {0}", err.ToString());
			}
		}
Exemplo n.º 53
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
                {
                    writer.Write(0); // version

                    writer.Write(Contexts.Count);
                    Contexts.ForEach(c => c.Serialize(writer));
                });
        }
Exemplo n.º 54
0
		public static void Save( WorldSaveEventArgs e )
		{
			Timer.DelayCall( TimeSpan.Zero, new TimerCallback( PurgeList ) );
		}
Exemplo n.º 55
0
		/// <summary>
		///     On world save verify and save the jailings
		/// </summary>
		private static void OnWorldSave(WorldSaveEventArgs e)
		{
			Verify();
			Save();
		}
Exemplo n.º 56
0
        /*
        public static void OnGuildChat(GuildChatEventArgs e)
        {
            string speech = e.Speech;
            string name = e.Mobile.Name;
            string account = e.Mobile.Account != null ? e.Mobile.Account.ToString() : "[No account]";
            string region = e.Mobile.Region.Name;
            string guild = e.Mobile.Guild.Abbreviation == "none" ? e.Mobile.Guild.Name : e.Mobile.Guild.Abbreviation;
            string datetime = DateTime.Now.ToString();

            string text = string.Format("{0} [{1}] [{2}]: Guild[{3}] <{4}> {5}", datetime, account, region, guild, name, speech);

            guildchatlist.Add(text);

            if (guildchatlist.Count > 1000)
                SaveGuildChat();
        }
        
        public static void OnPartyChat(PartyChatEventArgs e)
        {
            string speech = e.Speech;
            string from = e.From.Name;
            string to = e.To == null ? "" : e.To.Name;
            string account = e.From.Account != null ? e.From.Account.ToString() : "[No account]";
            string region = e.From.Region.Name;
            string datetime = DateTime.Now.ToString();

            string text;

            if (string.IsNullOrEmpty(to))
                text = string.Format("{0} [{1}] [{2}]: Party[{3}] {4}", datetime, account, region, from, speech);
            else
                text = string.Format("{0} [{1}] [{2}]: Party[{3} -> {4}] {5}", datetime, account, region, from, to, speech);
            
            partychatlist.Add(text);

            if (partychatlist.Count > 1000)
                SavePartyChat();
        }
        
        public static void OnAllianceChat(AllianceChatEventArgs e)
        {
            string speech = e.Speech;
            string name = e.Mobile.Name;
            string account = e.Mobile.Account != null ? e.Mobile.Account.ToString() : "[No account]";
            string region = e.Mobile.Region.Name;
            string guild = e.Mobile.Guild.Abbreviation == "none" ? e.Mobile.Guild.Name : e.Mobile.Guild.Abbreviation;
            string datetime = DateTime.Now.ToString();

            string text = string.Format("{0} [{1}] [{2}]: Guild[{3}] <{4}> {5}", datetime, account, region, guild, name, speech);

            alliancechatlist.Add(text);

            if (alliancechatlist.Count > 1000)
                SaveAllianceChat();
        }
        */
        public static void OnSave(WorldSaveEventArgs w)
        {
            SaveSpeech();
            //SaveGuildChat();
            //SavePartyChat();
            //SaveAllianceChat();
        }
Exemplo n.º 57
0
        public static void OnSave(WorldSaveEventArgs e)
        {
			if (!m_Available)
			{
				Console.WriteLine("RareFactory unavailable for saving!");
				return;
			}

            Console.WriteLine("RareFactory Saving..");

            // Save the instance counts for each
            FactorySave();

        }
Exemplo n.º 58
0
		private static void EventSink_WorldSave(WorldSaveEventArgs args)
		{
			if (ms_DeleteCache != null && ms_DeleteCache.Count > 0)
				for (int i = ms_DeleteCache.Count - 1; i >= 0; --i)
					((Guildstone)ms_DeleteCache[i]).Delete();
		}
Exemplo n.º 59
0
 public void InvokeWorldSave( WorldSaveEventArgs e )
 {
     if ( WorldSave != null )
         WorldSave( e );
 }
Exemplo n.º 60
0
        public static void onSave(WorldSaveEventArgs e)
        {
            System.Console.WriteLine("Saving Jailings");
            if (!Directory.Exists(jailDirectory))
                Directory.CreateDirectory(jailDirectory);
            GenericWriter idxWriter;
            GenericWriter binWriter;
            long tPos;
            /*if (World.SaveType == 0)
            {
                idxWriter = new BinaryFileWriter(idxPath, false);
                binWriter = new BinaryFileWriter(binPath, true);
            }
            else
            {*/
                idxWriter = new AsyncWriter(idxPath, false);
                binWriter = new AsyncWriter(binPath, true);
            //}
            idxWriter.Write((int)m_jailings.Count);
            try
            {
                foreach (JailSystem tJail in m_jailings.Values)
                {
                    tPos = binWriter.Position;
                    idxWriter.Write((int)0);
                    idxWriter.Write((int)tJail.ID);
                    idxWriter.Write((long)tPos);
                    try
                    {
                        tJail.Serialize((GenericWriter)binWriter);
                    }
                    catch (Exception err)
                    {
                        System.Console.WriteLine("{0}, {1} serialize", err.Message, err.TargetSite);
                    }
                    idxWriter.Write((int)(binWriter.Position - tPos));
                }
                saveingameeditsettings((GenericWriter)binWriter);

            }
            catch (Exception er)
            {
                System.Console.WriteLine("{0}, {1}", er.Message, er.TargetSite);
            }
            finally
            {
            }
            idxWriter.Close();
            binWriter.Close();
            System.Console.WriteLine("Jailings Saved");
        }