Exemplo n.º 1
0
		public static void Load()
		{
			if( !Directory.Exists( "Saves/ACC" ) )
				return;

			string filename = "acc.sav";
			string path = @"Saves/ACC/";
			string pathNfile = path+filename;
			DateTime start = DateTime.Now;

			Console.WriteLine();
			Console.WriteLine( "----------" );
			Console.WriteLine( "Loading ACC..." );

			try
			{
				using( FileStream m_FileStream = new FileStream( pathNfile, FileMode.Open, FileAccess.Read ) )
				{
					BinaryReader m_BinaryReader = new BinaryReader( m_FileStream );
					BinaryFileReader reader = new BinaryFileReader( m_BinaryReader );

					if( m_RegSystems == null )
						m_RegSystems = new Hashtable();

					int Count = reader.ReadInt();
					for( int i = 0; i < Count; i++ )
					{
						string system = reader.ReadString();
						Type t = ScriptCompiler.FindTypeByFullName( system );
						bool enabled = reader.ReadBool();

						if( t != null )
						{
							m_RegSystems[system] = enabled;

							if( (bool)m_RegSystems[system] )
							{
								ACCSystem sys = (ACCSystem)Activator.CreateInstance( t );
								if( sys != null )
									sys.StartLoad( path );
							}
						}
					}

					reader.Close();
					m_FileStream.Close();
				}

				Console.WriteLine( "Done in {0:F1} seconds.", (DateTime.Now-start).TotalSeconds );
				Console.WriteLine( "----------" );
				Console.WriteLine();
			}
			catch( Exception e )
			{
				Console.WriteLine( "Failed. Exception: "+e );
			}
		}
Exemplo n.º 2
0
        public static void LoadGlobalOptions()
        {
            if (!File.Exists(Path.Combine(General.SavePath, "GlobalOptions.bin")))
                return;

            using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "GlobalOptions.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                int version = reader.ReadInt();

                if (version >= 2) s_MultiPort = reader.ReadInt();
                if (version >= 2) s_MultiServer = reader.ReadString();

                int count = 0;
                if (version >= 1)
                {
                    count = reader.ReadInt();
                    Notification not = null;
                    for (int i = 0; i < count; ++i)
                    {
                        not = new Notification();
                        not.Load(reader);
                    }
                }

                count = reader.ReadInt();
                string txt = "";
                for (int i = 0; i < count; ++i)
                {
                    txt = reader.ReadString();
                    if(!s_Filters.Contains(txt))
                        s_Filters.Add(txt);
                }

                s_FilterPenalty = (FilterPenalty)reader.ReadInt();
                if(version >= 1) s_MacroPenalty = (MacroPenalty)reader.ReadInt();
                s_MaxMsgs = reader.ReadInt();
                s_ChatSpam = reader.ReadInt();
                s_MsgSpam = reader.ReadInt();
                s_RequestSpam = reader.ReadInt();
                s_FilterBanLength = reader.ReadInt();
                s_FilterWarnings = reader.ReadInt();
                if (version >= 1) s_AntiMacroDelay = reader.ReadInt();
                s_IrcPort = reader.ReadInt();
                s_IrcMaxAttempts = reader.ReadInt();
                s_IrcEnabled = reader.ReadBool();
                s_IrcAutoConnect = reader.ReadBool();
                s_IrcAutoReconnect = reader.ReadBool();
                s_FilterSpeech = reader.ReadBool();
                s_FilterMsg = reader.ReadBool();
                s_Debug = reader.ReadBool();
                s_LogChat = reader.ReadBool();
                s_LogPms = reader.ReadBool();
                s_IrcStaffColor = (IrcColor)reader.ReadInt();
                s_IrcServer = reader.ReadString();
                s_IrcRoom = reader.ReadString();
                s_IrcNick = reader.ReadString();
                s_TotalChats = reader.ReadULong() - 1;
            }
        }
Exemplo n.º 3
0
        public static void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                AllianceLimit = reader.ReadInt();
                useXML = reader.ReadBool();
                int count = reader.ReadInt();

                for (int i = 1; i <= count; i++)
                {
                    BaseAlliance alliance = new BaseAlliance();
                    alliance.Deserialize(reader);
                    Alliances.Add(alliance);
                }
            }

            reader.Close();
        }
Exemplo n.º 4
0
		public ChatInfo( BinaryFileReader reader )
		{
			int version = reader.ReadInt();

			switch( version )
			{
				case 0:
					{
						_buddyList = reader.ReadStrongMobileList<Mobile>();
						_client = reader.ReadMobile();
						_ignoreList = reader.ReadStrongMobileList<Mobile>();
						_visible = reader.ReadBool();
						break;
					}
			}
		}
Exemplo n.º 5
0
		public static void Load()
		{
            try
            {
                if (!File.Exists(Path.Combine(General.SavePath, "Gumps.bin")))
                    return;

                using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    if (version >= 0)
                    {
                        s_ForceMenu = reader.ReadBool();
                        int count = reader.ReadInt();
                        GumpInfo info;

                        for (int i = 0; i < count; ++i)
                        {
                            info = new GumpInfo();
                            info.Load(reader);

                            if (info.Type == null)
                                continue;

                            s_ForceInfos[info.Type] = info;
                        }

                        count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            info = new GumpInfo();
                            info.Load(reader);

                            if (info.Mobile == null || info.Type == null)
                                continue;

                            if (s_Infos[info.Mobile] == null)
                                s_Infos[info.Mobile] = new Hashtable();

                            ((Hashtable)s_Infos[info.Mobile])[info.Type] = info;
                        }
                    }

                    reader.End();
                }
            }
            catch (Exception e)
            {
                Errors.Report(General.Local(198));
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
            }
		}
Exemplo n.º 6
0
        private static void Load()
        {
            try
            {
                string SavePath = Path.Combine( m_SavePath, "forumdata.sig" );

                using( FileStream fs = new FileStream( SavePath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                {
                    BinaryReader br = new BinaryReader( fs );
                    BinaryFileReader reader = new BinaryFileReader( br );

                    int version = reader.ReadInt();
                    switch( version )
                    {
                        case 0:
                        {
                            m_PlayerStatistics = ReadPlayerStatistics( reader );
                            int count = reader.ReadInt();
                            for( int i = 0; i < count; i++ )
                            {
                                ThreadEntry te = new ThreadEntry();
                                te.Deserialize( reader );
                                m_Threads.Add( te );
                            }
                            m_Moderators = reader.ReadMobileList();
                            m_ThreadDeleteAccessLevel = (AccessLevel)reader.ReadInt();
                            m_ThreadLockAccesLevel = ( AccessLevel )reader.ReadInt();
                            m_AutoCleanup = reader.ReadBool();
                            m_AutoCleanupDays = reader.ReadInt();
                            m_MinPostCharactersCount = reader.ReadInt();
                            m_MaxPostCharactersCount = reader.ReadInt();
                            break;
                        }
                    }                    
                }

                m_Threads.Sort( new DateSort() );
                Console.WriteLine( "done" );
                Console.WriteLine( "---------" );
            }
            catch(Exception err)
            {
                Console.WriteLine( "An error occured while loading the forums...{0}", err.ToString() );
                Console.WriteLine( "---------" );
            }
        }        
Exemplo n.º 7
0
		public static void Load()
		{
			if (m_Loaded)
				return;

			m_Loaded = true;
			m_LoadingType = null;

			Console.WriteLine("World: Loading...");

			DateTime start = DateTime.Now;

			m_Loading = true;

			// Take care of some World class-specific stuff
			try
			{
				BinaryFileReader datreader = new BinaryFileReader(new BinaryReader(new FileStream("Saves/World.dat", FileMode.Open, FileAccess.Read)));
				int version = datreader.ReadInt();

				switch (version)
				{
					case 1:
						{
							int count = datreader.ReadInt();
							m_ReservedSerials = new Dictionary<int, bool>(count);
							for (int i = 0; i < count; i++)
								m_ReservedSerials[datreader.ReadInt()] = true;

							goto case 0;
						}
					case 0:
						{
							m_FreezeDryEnabled = datreader.ReadBool();
							break;
						}
					default:
						{
							throw new Exception("Invalid World.dat savefile version.");
						}
				}

				datreader.Close();
			}
			catch (Exception e)
			{
				Console.WriteLine("Error reading World.dat, using default values:");
				Console.WriteLine(e.ToString());
				m_ReservedSerials = new Dictionary<int, bool>(0);
				m_FreezeDryEnabled = false;
			}

			m_DeleteList = new ArrayList();

			int mobileCount = 0, itemCount = 0, guildCount = 0, regionCount = 0;

			object[] ctorArgs = new object[1];
			Type[] ctorTypes = new Type[1] { typeof(Serial) };

			ArrayList items = new ArrayList();
			ArrayList mobiles = new ArrayList();
			ArrayList guilds = new ArrayList();
			ArrayList regions = new ArrayList();

			if (File.Exists(mobIdxPath) && File.Exists(mobTdbPath))
			{
				using (FileStream idx = new FileStream(mobIdxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryReader idxReader = new BinaryReader(idx);

					using (FileStream tdb = new FileStream(mobTdbPath, FileMode.Open, FileAccess.Read, FileShare.Read))
					{
						BinaryReader tdbReader = new BinaryReader(tdb);

						int count = tdbReader.ReadInt32();

						ArrayList types = new ArrayList(count);

						for (int i = 0; i < count; ++i)
						{
							string typeName = tdbReader.ReadString();

							Type t = ScriptCompiler.FindTypeByFullName(typeName);

							if (t == null)
							{
								Console.WriteLine("failed");
								Console.WriteLine("Error: Type '{0}' was not found. Delete all of those types? (y/n)", typeName);

								if (Console.ReadLine() == "y")
								{
									types.Add(null);
									Console.Write("World: Loading...");
									continue;
								}

								Console.WriteLine("Types will not be deleted. An exception will be thrown when you press return");

								throw new Exception(String.Format("Bad type '{0}'", typeName));
							}

							ConstructorInfo ctor = t.GetConstructor(ctorTypes);

							if (ctor != null)
							{
								types.Add(new object[] { ctor, null });
							}
							else
							{
								throw new Exception(String.Format("Type '{0}' does not have a serialization constructor", t));
							}
						}

						mobileCount = idxReader.ReadInt32();

						m_Mobiles = new Dictionary<Serial, Mobile>(mobileCount);

						for (int i = 0; i < mobileCount; ++i)
						{
							int typeID = idxReader.ReadInt32();
							int serial = idxReader.ReadInt32();
							long pos = idxReader.ReadInt64();
							int length = idxReader.ReadInt32();

							object[] objs = (object[])types[typeID];

							if (objs == null)
								continue;

							Mobile m = null;
							ConstructorInfo ctor = (ConstructorInfo)objs[0];
							string typeName = (string)objs[1];

							try
							{
								ctorArgs[0] = (Serial)serial;
								m = (Mobile)(ctor.Invoke(ctorArgs));
							}
							catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

							if (m != null)
							{
								mobiles.Add(new MobileEntry(m, typeID, typeName, pos, length));
								AddMobile(m);
							}
						}

						tdbReader.Close();
					}

					idxReader.Close();
				}
			}
			else
			{
				m_Mobiles = new Dictionary<Serial, Mobile>();
			}

			if (File.Exists(itemIdxPath) && File.Exists(itemTdbPath))
			{
				using (FileStream idx = new FileStream(itemIdxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryReader idxReader = new BinaryReader(idx);

					using (FileStream tdb = new FileStream(itemTdbPath, FileMode.Open, FileAccess.Read, FileShare.Read))
					{
						BinaryReader tdbReader = new BinaryReader(tdb);

						int count = tdbReader.ReadInt32();

						ArrayList types = new ArrayList(count);

						for (int i = 0; i < count; ++i)
						{
							string typeName = tdbReader.ReadString();

							Type t = ScriptCompiler.FindTypeByFullName(typeName);

							if (t == null)
							{
								Console.WriteLine("failed");
								Console.WriteLine("Error: Type '{0}' was not found. Delete all of those types? (y/n)", typeName);

								if (Console.ReadLine() == "y")
								{
									types.Add(null);
									Console.Write("World: Loading...");
									continue;
								}

								Console.WriteLine("Types will not be deleted. An exception will be thrown when you press return");

								throw new Exception(String.Format("Bad type '{0}'", typeName));
							}

							ConstructorInfo ctor = t.GetConstructor(ctorTypes);

							if (ctor != null)
							{
								types.Add(new object[] { ctor, typeName });
							}
							else
							{
								throw new Exception(String.Format("Type '{0}' does not have a serialization constructor", t));
							}
						}

						itemCount = idxReader.ReadInt32();

						m_Items = new Dictionary<Serial, Item>(itemCount);

						for (int i = 0; i < itemCount; ++i)
						{
							int typeID = idxReader.ReadInt32();
							int serial = idxReader.ReadInt32();
							long pos = idxReader.ReadInt64();
							int length = idxReader.ReadInt32();

							object[] objs = (object[])types[typeID];

							if (objs == null)
								continue;

							Item item = null;
							ConstructorInfo ctor = (ConstructorInfo)objs[0];
							string typeName = (string)objs[1];

							try
							{
								ctorArgs[0] = (Serial)serial;
								item = (Item)(ctor.Invoke(ctorArgs));
							}
							catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

							if (item != null)
							{
								items.Add(new ItemEntry(item, typeID, typeName, pos, length));
								AddItem(item);
							}
						}

						tdbReader.Close();
					}

					idxReader.Close();
				}
			}
			else
			{
				m_Items = new Dictionary<Serial, Item>();
			}

			if (File.Exists(guildIdxPath))
			{
				using (FileStream idx = new FileStream(guildIdxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryReader idxReader = new BinaryReader(idx);

					guildCount = idxReader.ReadInt32();

					CreateGuildEventArgs createEventArgs = new CreateGuildEventArgs(-1);
					for (int i = 0; i < guildCount; ++i)
					{
						idxReader.ReadInt32();//no typeid for guilds
						int id = idxReader.ReadInt32();
						long pos = idxReader.ReadInt64();
						int length = idxReader.ReadInt32();

						createEventArgs.Id = id;
						BaseGuild guild = EventSink.InvokeCreateGuild(createEventArgs);//new Guild( id );
						if (guild != null)
							guilds.Add(new GuildEntry(guild, pos, length));
					}

					idxReader.Close();
				}
			}

			if (File.Exists(regionIdxPath))
			{
				using (FileStream idx = new FileStream(regionIdxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryReader idxReader = new BinaryReader(idx);

					regionCount = idxReader.ReadInt32();

					for (int i = 0; i < regionCount; ++i)
					{
						int typeID = idxReader.ReadInt32();
						int serial = idxReader.ReadInt32();
						long pos = idxReader.ReadInt64();
						int length = idxReader.ReadInt32();

						Region r = Region.FindByUId(serial);

						if (r != null)
						{
							regions.Add(new RegionEntry(r, pos, length));
							Region.AddRegion(r);
							regionCount++;
						}
					}

					idxReader.Close();
				}
			}

			bool failedMobiles = false, failedItems = false, failedGuilds = false, failedRegions = false;
			Type failedType = null;
			Serial failedSerial = Serial.Zero;
			Exception failed = null;
			int failedTypeID = 0;

			if (File.Exists(mobBinPath))
			{
				using (FileStream bin = new FileStream(mobBinPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin));

					for (int i = 0; i < mobiles.Count; ++i)
					{
						MobileEntry entry = (MobileEntry)mobiles[i];
						Mobile m = (Mobile)entry.Object;

						if (m != null)
						{
							reader.Seek(entry.Position, SeekOrigin.Begin);

							try
							{
								m_LoadingType = entry.TypeName;
								m.Deserialize(reader);

								if (reader.Position != (entry.Position + entry.Length))
									throw new Exception(String.Format("***** Bad serialize on {0} *****", m.GetType()));
							}
							catch (Exception e)
							{
								mobiles.RemoveAt(i);

								failed = e;
								failedMobiles = true;
								failedType = m.GetType();
								failedTypeID = entry.TypeID;
								failedSerial = m.Serial;

								break;
							}
						}
					}

					reader.Close();
				}
			}

			if (!failedMobiles && File.Exists(itemBinPath))
			{
				using (FileStream bin = new FileStream(itemBinPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin));

					for (int i = 0; i < items.Count; ++i)
					{
						ItemEntry entry = (ItemEntry)items[i];
						Item item = (Item)entry.Object;

						if (item != null)
						{
							reader.Seek(entry.Position, SeekOrigin.Begin);

							try
							{
								m_LoadingType = entry.TypeName;
								item.Deserialize(reader);

								if (reader.Position != (entry.Position + entry.Length))
									throw new Exception(String.Format("***** Bad serialize on {0} *****", item.GetType()));
							}
							catch (Exception e)
							{
								items.RemoveAt(i);

								failed = e;
								failedItems = true;
								failedType = item.GetType();
								failedTypeID = entry.TypeID;
								failedSerial = item.Serial;

								break;
							}
						}
					}

					reader.Close();
				}
			}

			m_LoadingType = null;

			if (!failedMobiles && !failedItems && File.Exists(guildBinPath))
			{
				using (FileStream bin = new FileStream(guildBinPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin));

					for (int i = 0; i < guilds.Count; ++i)
					{
						GuildEntry entry = (GuildEntry)guilds[i];
						BaseGuild g = (BaseGuild)entry.Object;

						if (g != null)
						{
							reader.Seek(entry.Position, SeekOrigin.Begin);

							try
							{
								g.Deserialize(reader);

								if (reader.Position != (entry.Position + entry.Length))
									throw new Exception(String.Format("***** Bad serialize on Guild {0} *****", g.Id));
							}
							catch (Exception e)
							{
								guilds.RemoveAt(i);

								failed = e;
								failedGuilds = true;
								failedType = typeof(BaseGuild);
								failedTypeID = g.Id;
								failedSerial = g.Id;

								break;
							}
						}
					}

					reader.Close();
				}
			}

			if (!failedMobiles && !failedItems && File.Exists(regionBinPath))
			{
				using (FileStream bin = new FileStream(regionBinPath, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin));

					for (int i = 0; i < regions.Count; ++i)
					{
						RegionEntry entry = (RegionEntry)regions[i];
						Region r = (Region)entry.Object;

						if (r != null)
						{
							reader.Seek(entry.Position, SeekOrigin.Begin);

							try
							{
								r.Deserialize(reader);

								if (reader.Position != (entry.Position + entry.Length))
									throw new Exception(String.Format("***** Bad serialize on {0} *****", r.GetType()));
							}
							catch (Exception e)
							{
								regions.RemoveAt(i);

								failed = e;
								failedRegions = true;
								failedType = r.GetType();
								failedTypeID = entry.TypeID;
								failedSerial = r.UId;

								break;
							}
						}
					}

					reader.Close();
				}
			}

			if (failedItems || failedMobiles || failedGuilds || failedRegions)
			{
				Console.WriteLine("An error was encountered while loading a saved object");

				Console.WriteLine(" - Type: {0}", failedType);
				Console.WriteLine(" - Serial: {0}", failedSerial);

				Console.WriteLine("Delete the object? (y/n)");

				if (Console.ReadLine() == "y")
				{
					if (failedType != typeof(BaseGuild) && !failedType.IsSubclassOf(typeof(Region)))
					{
						Console.WriteLine("Delete all objects of that type? (y/n)");

						if (Console.ReadLine() == "y")
						{
							if (failedMobiles)
							{
								for (int i = 0; i < mobiles.Count; )
								{
									if (((MobileEntry)mobiles[i]).TypeID == failedTypeID)
										mobiles.RemoveAt(i);
									else
										++i;
								}
							}
							else if (failedItems)
							{
								for (int i = 0; i < items.Count; )
								{
									if (((ItemEntry)items[i]).TypeID == failedTypeID)
										items.RemoveAt(i);
									else
										++i;
								}
							}
						}
					}

					SaveIndex(mobiles, mobIdxPath);
					SaveIndex(items, itemIdxPath);
					SaveIndex(guilds, guildIdxPath);
					SaveIndex(regions, regionIdxPath);
				}

				Console.WriteLine("After pressing return an exception will be thrown and the server will terminate");
				Console.ReadLine();

				throw new Exception(String.Format("Load failed (items={0}, mobiles={1}, guilds={2}, regions={3}, type={4}, serial={5})", failedItems, failedMobiles, failedGuilds, failedRegions, failedType, failedSerial), failed);
			}

			EventSink.InvokeWorldLoad();

			m_Loading = false;

			for (int i = 0; i < m_DeleteList.Count; ++i)
			{
				object o = m_DeleteList[i];

				if (o is Item)
					((Item)o).Delete();
				else if (o is Mobile)
					((Mobile)o).Delete();
			}

			m_DeleteList.Clear();

			foreach (Item item in m_Items.Values)
			{
				if (item.Parent == null)
					item.UpdateTotals();

				item.ClearProperties();
			}

			ArrayList list = new ArrayList(m_Mobiles.Values);

			foreach (Mobile m in list)
			{
				m.ForceRegionReEnter(true);
				m.UpdateTotals();

				m.ClearProperties();
			}

			// adam: not currently used 
			//DateTime copy = DateTime.Now;
			// make sure we take the snapshotted Temp and move it out into working data
			//if (Directory.Exists("Temp"))
			//Directory.Delete("Temp", true);
			//if (Directory.Exists("Saves/Temp"))
			//CopyDirectory("Saves/Temp", "Temp");
			//Console.WriteLine("Copying Temp/ took {0}ms.", (DateTime.Now - copy).TotalMilliseconds);

			Console.WriteLine("done ({1} items, {2} mobiles) ({0:F1} seconds)", (DateTime.Now - start).TotalSeconds, m_Items.Count, m_Mobiles.Count);
		}
        public static void Load()
        {
            string filePath = Path.Combine("LokaiSaves/LokaiSkills", "LokaiSkills.bin");

            if (!File.Exists(filePath))
            {
                Console.WriteLine("LokaiSkills.bin did not exist so we are initializing the values.");
                m_LinguisticsLevel     = AccessLevel.Player;
                m_RidingChecksEnabled  = true;
                m_SailingChecksEnabled = true;
                m_LinguisticsEnabled   = true;
                m_CommerceEnabled      = true;
                m_ShowLokaiSkillInGump = new bool[] { true, true, true, true, true, true, true, true, true,
                                                      true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                                                      true, true, true, true, true, true, true };
                return;
            }
            BinaryFileReader reader = null;
            FileStream       fs     = null;

            try
            {
                fs     = new FileStream(filePath, (FileMode)3, (FileAccess)1, (FileShare)1);
                reader = new BinaryFileReader(new BinaryReader(fs));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return;
            }

            if (reader != null)
            {
                int check = 0;
                try
                {
                    int version = reader.ReadEncodedInt();
                    check++;
                    m_LinguisticsLevel = (AccessLevel)reader.ReadEncodedInt();
                    check++;
                    m_CommerceEnabled = reader.ReadBool();
                    check++;
                    m_RidingChecksEnabled = reader.ReadBool();
                    check++;
                    m_SailingChecksEnabled = reader.ReadBool();
                    check++;
                    m_LinguisticsEnabled = reader.ReadBool();
                    check++;

                    m_ShowLokaiSkillInGump = new bool[] { true, true, true, true, true, true, true, true, true,
                                                          true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                                                          true, true, true, true, true, true, true };
                    ShowButchering = reader.ReadBool();
                    check++;
                    ShowSkinning = reader.ReadBool();
                    check++;
                    ShowAnimalRiding = reader.ReadBool();
                    check++;
                    ShowSailing = reader.ReadBool();
                    check++;
                    ShowDetectEvil = reader.ReadBool();
                    check++;
                    ShowCureDisease = reader.ReadBool();
                    check++;
                    ShowPickPocket = reader.ReadBool();
                    check++;
                    ShowPilfering = reader.ReadBool();
                    check++;
                    ShowFraming = reader.ReadBool();
                    check++;
                    ShowBrickLaying = reader.ReadBool();
                    check++;
                    ShowRoofing = reader.ReadBool();
                    check++;
                    ShowStoneMasonry = reader.ReadBool();
                    check++;
                    ShowVentriloquism = reader.ReadBool();
                    check++;
                    ShowHypnotism = reader.ReadBool();
                    check++;
                    ShowPreyTracking = reader.ReadBool();
                    check++;
                    ShowSpeakToAnimals = reader.ReadBool();
                    check++;
                    ShowWoodworking = reader.ReadBool();
                    check++;
                    ShowCooperage = reader.ReadBool();
                    check++;
                    ShowSpinning = reader.ReadBool();
                    check++;
                    ShowWeaving = reader.ReadBool();
                    check++;
                    ShowConstruction = reader.ReadBool();
                    check++;
                    ShowCommerce = reader.ReadBool();
                    check++;
                    ShowBrewing = reader.ReadBool();
                    check++;
                    ShowHerblore = reader.ReadBool();
                    check++;
                    ShowTreePicking = reader.ReadBool();
                    check++;
                    ShowTreeSapping = reader.ReadBool();
                    check++;
                    ShowTreeCarving = reader.ReadBool();
                    check++;
                    ShowTreeDigging = reader.ReadBool();
                    check++;
                    ShowTeaching = reader.ReadBool();
                    check++;
                    ShowLinguistics = reader.ReadBool();
                    check++;
                    reader.Close();
                }
                catch
                {
                    Console.WriteLine("Error reading .bin file at line {0}, so we are initializing the values again.", check);
                    m_LinguisticsLevel     = AccessLevel.Player;
                    m_RidingChecksEnabled  = true;
                    m_SailingChecksEnabled = true;
                    m_LinguisticsEnabled   = true;
                    m_CommerceEnabled      = true;
                    m_ShowLokaiSkillInGump = new bool[] { true, true, true, true, true, true, true, true, true,
                                                          true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                                                          true, true, true, true, true, true, true };
                    Console.WriteLine(".bin File closed.");
                    reader.Close();
                }
            }
            else
            {
                Console.WriteLine("Reader was NULL, so we are initializing the values again.");
                m_LinguisticsLevel     = AccessLevel.Player;
                m_RidingChecksEnabled  = true;
                m_SailingChecksEnabled = true;
                m_LinguisticsEnabled   = true;
                m_CommerceEnabled      = true;
                m_ShowLokaiSkillInGump = new bool[] { true, true, true, true, true, true, true, true, true,
                                                      true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                                                      true, true, true, true, true, true, true };
            }
        }
		// Loads the MobileAndSpellList file the save method creates.
		public static void Load()
		{
			try
			{
				if ( !Directory.Exists( "Saves/BlueMagic/" ) )
					Console.WriteLine( "Blue Magic: No save file found." );
				else if ( !File.Exists( "Saves/BlueMagic/MobileAndSpellList.bin" ) )
					Console.WriteLine( "Blue Magic: No save file found." );
				else
				{
					Console.WriteLine( " " );
					Console.Write( "Blue Magic: Save file found, loading..." );

					using ( BinaryReader binReader = new BinaryReader( File.Open("Saves/BlueMagic/MobileAndSpellList.bin", FileMode.Open) ) )
					{
						BinaryFileReader reader = new BinaryFileReader( binReader );

						int keycount = reader.ReadInt();
						int oldspellcount = reader.ReadInt();

						for( int i = 0; i < keycount; i++ )
						{
							Serial serial = reader.ReadInt();

							if ( GetMobile( serial ) == null )
								continue;

							bool[] bools = new bool[SPELLCOUNT];

							for ( int j = 0; j < oldspellcount; j++ )
							{
								bools[j] = reader.ReadBool();
							}

							try
							{
								BlueMageSpells.Add( serial, bools );
							}
							catch
							{
								Console.WriteLine( "Adding serial " + serial.ToString() + " to blue spells known has failed" );
							}

						}

						reader.Close();
					}

					Console.WriteLine( "Done." );
				}
			}
			catch( Exception ex )
			{
				Console.WriteLine( "BlueMagic Load failed" );
				Console.WriteLine( "The exception was: " + ex.Message );
				Console.WriteLine( "Continuing normal world load." );
			}
		}
Exemplo n.º 10
0
		public static void OnLoad()
		{
			try
			{
				Console.WriteLine("KinSystemSettings Loading...");
				string filePath = Path.Combine("Saves/AngelIsland", "KinSystemSettings.bin");

				if (!File.Exists(filePath))
					return;

				BinaryFileReader datreader = new BinaryFileReader(new BinaryReader(new FileStream(filePath, FileMode.Open, FileAccess.Read)));
				int version = datreader.ReadInt();

				switch (version)
				{
					case 11:
						A_MaxShoppers = datreader.ReadInt();
						goto case 10;
					case 10:
						A_F_Visitor = datreader.ReadInt();
						A_Visitor = datreader.ReadInt();
						A_F_Sale = datreader.ReadInt();
						A_Sale = datreader.ReadInt();
						A_GPMaint = datreader.ReadInt();
						A_GPHire = datreader.ReadInt();
						A_GDeath = datreader.ReadInt();
						A_F_Death = datreader.ReadInt();
						A_Death = datreader.ReadInt();
						A_GCChampLevel = datreader.ReadInt();
						A_GCDeath = datreader.ReadInt();
						A_MaxVisitors = datreader.ReadInt();
						goto case 9;
					case 9:
						GuardChangeTimeHours = datreader.ReadInt();
						goto case 8;
					case 8:
						CityGuardSlots = datreader.ReadInt();
						GuardMaintMinutes = datreader.ReadInt();
						GuardTypeLowSilverCost = datreader.ReadInt();
						GuardTypeMediumSilverCost = datreader.ReadInt();
						GuardTypeHighSilverCost = datreader.ReadInt();
						GuardTypeLowSilverMaintCost = datreader.ReadInt();
						GuardTypeMediumSilverMaintCost = datreader.ReadInt();
						GuardTypeHighSilverMaintCost = datreader.ReadInt();
						goto case 7;
					case 7:
						KinAwards = datreader.ReadBool();
						goto case 6;
					case 6:
						OutputCaptureData = datreader.ReadBool();
						goto case 5;
					case 5:
						CityCaptureEnabled = datreader.ReadBool();
						VortexCaptureProportion = datreader.ReadDouble();
						VortexMinDamagePercentage = datreader.ReadDouble();
						BeneficiaryQualifyPercentage = datreader.ReadDouble();
						BeneficiaryCap = datreader.ReadInt();
						CaptureDefenseRange = datreader.ReadInt();
						VortexExpireMinutes = datreader.ReadInt();
						BaseCaptureMinutes = datreader.ReadInt();
						goto case 4;
					case 4:
						KinNameHueEnabled = datreader.ReadBool();
						goto case 3;
					case 3:
						ShowStatloss = datreader.ReadBool();
						ShowKinSingleClick = datreader.ReadBool();
						goto case 2;
					case 2:
						KinAggressionMinutes = datreader.ReadDouble();
						KinBeneficialMinutes = datreader.ReadDouble();
						KinHealerModifier = datreader.ReadDouble();
						goto case 1;
					case 1:
						PointsEnabled = datreader.ReadBool();
						StatLossEnabled = datreader.ReadBool();
						StatLossPercentageSkills = datreader.ReadDouble();
						StatLossPercentageStats = datreader.ReadDouble();
						StatLossDurationMinutes = datreader.ReadDouble();
						break;
				}

				datreader.Close();
			}
			catch (Exception re)
			{
				System.Console.WriteLine("ERROR LOADING KinSystemSettings!");
				Scripts.Commands.LogHelper.LogException(re);
			}
		}
Exemplo n.º 11
0
        private static void OnLoad()
        {
            try{

            if ( !File.Exists( Path.Combine( "Saves/Chat/", "Chat.bin" ) ) )
                return;

            using ( FileStream bin = new FileStream( Path.Combine( "Saves/Chat/", "Chat.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

                int version = reader.ReadInt();

                if ( version >= 12 )
                    s_PublicPlusIRC = reader.ReadBool();

                if ( version >= 11 )
                    s_FilterPenalty = (FilterPenalty)reader.ReadInt();

                if ( version >= 10 )
                    s_AllianceChat = reader.ReadBool();

                if ( version >= 9 )
                    s_AllowFaction = reader.ReadBool();

                if ( version >= 8 )
                    s_GuildMenuAccess = reader.ReadBool();

                if ( version >= 7 )
                    s_MaxPmHistory = reader.ReadInt();

                if ( version >= 6 )
                    s_IrcAutoReconnect = reader.ReadBool();

                if ( version >= 5 )
                    s_IrcMaxAttempts = reader.ReadInt();

                if ( version >= 4 )
                    s_IrcAutoConnect = reader.ReadBool();

                if ( version >= 3 )
                    s_IrcStaffColor = (IrcColor)reader.ReadInt();

                if ( version >= 2 )
                    s_IrcNick = reader.ReadString();

                if ( version >= 1 )
                {
                    s_IrcEnabled = reader.ReadBool();
                    s_IrcServer = reader.ReadString();
                    s_IrcRoom = reader.ReadString();
                    s_IrcPort = reader.ReadInt();
                }

                if ( version >= 0 )
                {
                    int count = reader.ReadInt();

                    for( int i = 0; i < count; ++i )
                        s_Filters.Add( reader.ReadString() );

                    s_SpamLimiter = reader.ReadDouble();
                    s_FilterBanLength = reader.ReadDouble();

                    if ( version < 11 )
                        reader.ReadBool(); // FilterBan removed

                    s_ShowLocation = reader.ReadBool();
                    s_ShowStaff = reader.ReadBool();
                    s_PublicStyle = (PublicStyle)reader.ReadInt();

                    count = reader.ReadInt();
                    ChatInfo info;

                    for( int i = 0; i < count; ++i )
                    {
                        info = new ChatInfo( reader.ReadMobile() );
                        if ( !info.Load( reader ) )
                            return;
                    }
                }

                reader.End();
            }

            if ( s_IrcAutoConnect )
                IrcConnection.Connection.Connect();

            }catch{ Errors.Report( "ChatInfo-> OnLoad" ); }
        }