コード例 #1
0
ファイル: Data.cs プロジェクト: furkanugur/imaginenation
        public static void LoadMsgs()
        {
            if (!File.Exists(Path.Combine(General.SavePath, "Pms.bin")))
            {
                return;
            }

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

                int version = reader.ReadInt();

                Mobile m     = null;
                int    count = reader.ReadInt();
                for (int i = 0; i < count; ++i)
                {
                    m = reader.ReadMobile();
                    if (m != null)
                    {
                        GetData(m).LoadMsgs(reader);
                    }
                    else
                    {
                        (new Data()).LoadMsgs(reader);
                    }
                }
            }
        }
コード例 #2
0
        private static void OnLoad()
        {
            if (!File.Exists(Path.Combine(SavePath, SaveFile)))
            {
                return;
            }

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

                m_LastResetTime = reader.ReadDateTime();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    Mobile mobile = reader.ReadMobile();

                    MobileRateInfo info = new MobileRateInfo();

                    info.Deserialize(reader);

                    if (mobile != null)
                    {
                        MobileRateInfo.Entries.Add(mobile, info);
                    }
                }
            }
        }
コード例 #3
0
ファイル: ChatMessage.cs プロジェクト: zerodowned/Ulmeta
        public ChatMessage(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            case 0:
            {
                _client    = reader.ReadMobile();
                _message   = reader.ReadString();
                _recipient = reader.ReadMobile();
                _timestamp = reader.ReadDateTime();

                break;
            }
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if (!File.Exists(DataFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int version = reader.ReadInt();

                switch (version)
                {
                case 0:
                    int tableCount = reader.ReadInt();
                    PerkTable = new Dictionary <Player, Tuple <Perk, Perk> >(tableCount);

                    Player player;
                    Perk   p1, p2;

                    try
                    {
                        for (int i = 0; i < tableCount; i++)
                        {
                            player = reader.ReadMobile <Player>();

                            if (player == null || player.Deleted)
                            {
                                continue;
                            }

                            ConstructorInfo ctor = GetPerkCtor(reader.ReadString());
                            p1 = ctor.Invoke(new object[] { reader }) as Perk;

                            ctor = GetPerkCtor(reader.ReadString());
                            p2   = ctor.Invoke(new object[] { reader }) as Perk;

                            PerkTable[player] = Tuple.Create <Perk, Perk>(p1, p2);
                        }
                    }

                    catch (Exception e)
                    {
                        Utilities.ExceptionManager.LogException("Perk", e);
                    }

                    break;
                }

                reader.Close();
            }
        }
コード例 #5
0
        public void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                serialString = reader.ReadString();

                allianceLeader = reader.ReadMobile() as Player;

                int count = reader.ReadInt();

                for (int n = 1; n <= count; n++)
                {
                    membersOf.Add(reader.ReadMobile());
                }

                int guildCount = reader.ReadInt();

                for (int x = 1; x <= guildCount; x++)
                {
                    childGuilds.Add(reader.ReadGuild() as Guild);
                }

                allianceName = reader.ReadString();
                primaryHue   = reader.ReadInt();
                secondaryHue = reader.ReadInt();
                mountBody    = reader.ReadInt();
                mountID      = reader.ReadInt();

                foreach (Mobile m in membersOf)
                {
                    if (m is Player)
                    {
                        Player p = m as Player;
                        p.CurrentAlliance = this;
                    }
                }
            }
        }
コード例 #6
0
        public void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                m_CombatantMobile = reader.ReadMobile() as PlayerMobile;
                m_combatRating    = reader.ReadInt();

                m_Rank = (CombatRank)reader.ReadInt();

                m_totalDeaths = reader.ReadInt();
                m_totalKills  = reader.ReadInt();
            }
        }
コード例 #7
0
ファイル: ChatInfo.cs プロジェクト: zerodowned/Ulmeta
        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;
            }
            }
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KinCityData"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public KinCityData(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
            {
                m_Treasury = reader.ReadInt();
                m_TaxRate  = reader.ReadDouble();
                goto case 1;
            }

            case 1:
            {
                m_UnassignedGuardSlots = reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                m_City                = (KinFactionCities)reader.ReadInt();
                m_ControlingKin       = (IOBAlignment)reader.ReadInt();
                m_CaptureTime         = reader.ReadDeltaTime();
                m_CityLeader          = (PlayerMobile)reader.ReadMobile();
                m_IsVotingStage       = reader.ReadBool();
                m_Sigil               = (KinSigil)reader.ReadItem();
                m_ControlPoints       = reader.ReadInt();
                m_ControlPointDelta   = reader.ReadInt();
                m_NPCFlags            = (NPCFlags)reader.ReadInt();
                m_GuardOption         = (GuardOptions)reader.ReadInt();
                m_LastGuardChangeTime = reader.ReadDeltaTime();

                int length = reader.ReadInt();

                if (length > 0)
                {
                    for (int i = 0; i < length; ++i)
                    {
                        m_BeneficiaryDataList.Add(new BeneficiaryData(reader));
                    }
                }

                break;
            }
            }
        }
コード例 #9
0
        static void EventSink_WorldLoad()
        {
            logs = new List <LogObject>();
            if (!File.Exists(m_File))
            {
                return;
            }
            if (new FileInfo(m_File).Length <= 3)
            {
                return;
            }
            BinaryFileReader br = new BinaryFileReader(new BinaryReader(new FileStream(m_File, FileMode.OpenOrCreate, FileAccess.Read)));
            int read            = br.ReadInt();

            for (int i = 0; i < read; i++)
            {
                logs.Add(new LogObject(br.ReadMobile(), br.ReadString()));
            }
        }
コード例 #10
0
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if (!File.Exists(DataFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int tableCount = reader.ReadInt();
                EoCTable = new Dictionary <Player, EoCContext>(tableCount);

                for (int i = 0; i < tableCount; i++)
                {
                    if (!reader.ReadBool())
                    {
                        continue;
                    }

                    Player pl = reader.ReadMobile <Player>();

                    if (pl != null && !pl.Deleted)
                    {
                        EoCTable[pl] = new EoCContext(reader);
                    }
                }

                int hitsCount = reader.ReadInt();
                HitsTable = new Dictionary <Player, HitsTimer>(hitsCount);

                for (int i = 0; i < hitsCount; i++)
                {
                    if (!reader.ReadBool())
                    {
                        continue;
                    }

                    Player player = reader.ReadMobile <Player>();

                    if (player == null || player.Deleted)
                    {
                        continue;
                    }

                    HitsTable[player] = new HitsTimer(player);

                    DateTime next = reader.ReadDateTime();

                    if (next < DateTime.Now)
                    {
                        next = DateTime.Now;
                    }

                    HitsTable[player].Delay = (next - DateTime.Now);
                }

                reader.Close();
            }
        }
コード例 #11
0
ファイル: EoCGenerator.cs プロジェクト: greeduomacro/hubroot
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if( !File.Exists(DataFile) )
                return;

            using( FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read) )
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int tableCount = reader.ReadInt();
                EoCTable = new Dictionary<Player, EoCContext>(tableCount);

                for( int i = 0; i < tableCount; i++ )
                {
                    if( !reader.ReadBool() )
                        continue;

                    Player pl = reader.ReadMobile<Player>();

                    if( pl != null && !pl.Deleted )
                        EoCTable[pl] = new EoCContext(reader);
                }

                int hitsCount = reader.ReadInt();
                HitsTable = new Dictionary<Player, HitsTimer>(hitsCount);

                for( int i = 0; i < hitsCount; i++ )
                {
                    if( !reader.ReadBool() )
                        continue;

                    Player player = reader.ReadMobile<Player>();

                    if( player == null || player.Deleted )
                        continue;

                    HitsTable[player] = new HitsTimer(player);

                    DateTime next = reader.ReadDateTime();

                    if( next < DateTime.Now )
                        next = DateTime.Now;

                    HitsTable[player].Delay = (next - DateTime.Now);
                }

                reader.Close();
            }
        }
コード例 #12
0
ファイル: XmlAttach.cs プロジェクト: jasegiffin/JustUO
		public static void Load()
		{
			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

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

			FileStream fs = null;
			BinaryFileReader reader = null;
			FileStream imafs = null;
			BinaryFileReader imareader = null;
			FileStream fpifs = null;
			BinaryFileReader fpireader = null;

			try
			{
				fs = new FileStream(filePath, (FileMode)3, (FileAccess)1, (FileShare)1);
				reader = new BinaryFileReader(new BinaryReader(fs));
				imafs = new FileStream(imaPath, (FileMode)3, (FileAccess)1, (FileShare)1);
				imareader = new BinaryFileReader(new BinaryReader(imafs));
				fpifs = new FileStream(fpiPath, (FileMode)3, (FileAccess)1, (FileShare)1);
				fpireader = new BinaryFileReader(new BinaryReader(fpifs));
			}
			catch (Exception e)
			{
				ErrorReporter.GenerateErrorReport(e.ToString());
				return;
			}

			if (reader != null && imareader != null && fpireader != null)
			{
				// restore the current global attachment serial state
				try
				{
					ASerial.GlobalDeserialize(reader);
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				ASerial.serialInitialized = true;

				// read in the serial attachment hash table information
				int count = 0;
				try
				{
					count = reader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					// read the serial
					ASerial serialno = null;
					try
					{
						serialno = new ASerial(reader.ReadInt());
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					// read the attachment type
					string valuetype = null;
					try
					{
						valuetype = reader.ReadString();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					// read the position of the beginning of the next attachment deser within the .bin file
					long position = 0;
					try
					{
						position = fpireader.ReadLong();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					bool skip = false;

					XmlAttachment o = null;
					try
					{
						o = (XmlAttachment)Activator.CreateInstance(Type.GetType(valuetype), new object[] {serialno});
					}
					catch
					{
						skip = true;
					}

					if (skip)
					{
						if (!AlreadyReported(valuetype))
						{
							Console.WriteLine("\nError deserializing attachments {0}.\nMissing a serial constructor?\n", valuetype);
							ReportDeserError(valuetype, "Missing a serial constructor?");
						}
						// position the .ima file at the next deser point
						try
						{
							reader.Seek(position, SeekOrigin.Begin);
						}
						catch
						{
							ErrorReporter.GenerateErrorReport(
								"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
							return;
						}
						continue;
					}

					try
					{
						o.Deserialize(reader);
					}
					catch
					{
						skip = true;
					}

					// confirm the read position
					if (reader.Position != position || skip)
					{
						if (!AlreadyReported(valuetype))
						{
							Console.WriteLine("\nError deserializing attachments {0}\n", valuetype);
							ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
						}
						// position the .ima file at the next deser point
						try
						{
							reader.Seek(position, SeekOrigin.Begin);
						}
						catch
						{
							ErrorReporter.GenerateErrorReport(
								"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
							return;
						}
						continue;
					}

					// add it to the hash table
					try
					{
						AllAttachments.Add(serialno.Value, o);
					}
					catch
					{
						ErrorReporter.GenerateErrorReport(
							String.Format(
								"\nError deserializing {0} serialno {1}. Attachments save file corrupted. Attachment load aborted.\n",
								valuetype,
								serialno.Value));
						return;
					}
				}

				// read in the mobile attachment hash table information
				try
				{
					count = imareader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					Mobile key = null;
					try
					{
						key = imareader.ReadMobile();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					int nattach = 0;
					try
					{
						nattach = imareader.ReadInt();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					for (int j = 0; j < nattach; j++)
					{
						// and serial
						ASerial serialno = null;
						try
						{
							serialno = new ASerial(imareader.ReadInt());
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the attachment type
						string valuetype = null;
						try
						{
							valuetype = imareader.ReadString();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the position of the beginning of the next attachment deser within the .bin file
						long position = 0;
						try
						{
							position = fpireader.ReadLong();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						XmlAttachment o = FindAttachmentBySerial(serialno.Value);

						if (o == null || imareader.Position != position)
						{
							if (!AlreadyReported(valuetype))
							{
								Console.WriteLine("\nError deserializing attachments of type {0}.\n", valuetype);
								ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
							}
							// position the .ima file at the next deser point
							try
							{
								imareader.Seek(position, SeekOrigin.Begin);
							}
							catch
							{
								ErrorReporter.GenerateErrorReport(
									"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
								return;
							}
							continue;
						}

						// attachment successfully deserialized so attach it
						AttachTo(key, o, false);
					}
				}

				// read in the item attachment hash table information
				try
				{
					count = imareader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					Item key = null;
					try
					{
						key = imareader.ReadItem();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					int nattach = 0;
					try
					{
						nattach = imareader.ReadInt();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					for (int j = 0; j < nattach; j++)
					{
						// and serial
						ASerial serialno = null;
						try
						{
							serialno = new ASerial(imareader.ReadInt());
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the attachment type
						string valuetype = null;
						try
						{
							valuetype = imareader.ReadString();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the position of the beginning of the next attachment deser within the .bin file
						long position = 0;
						try
						{
							position = fpireader.ReadLong();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						XmlAttachment o = FindAttachmentBySerial(serialno.Value);

						if (o == null || imareader.Position != position)
						{
							if (!AlreadyReported(valuetype))
							{
								Console.WriteLine("\nError deserializing attachments of type {0}.\n", valuetype);
								ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
							}
							// position the .ima file at the next deser point
							try
							{
								imareader.Seek(position, SeekOrigin.Begin);
							}
							catch
							{
								ErrorReporter.GenerateErrorReport(
									"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
								return;
							}
							continue;
						}

						// attachment successfully deserialized so attach it
						AttachTo(key, o, false);
					}
				}
				if (fs != null)
				{
					fs.Close();
				}
				if (imafs != null)
				{
					imafs.Close();
				}
				if (fpifs != null)
				{
					fpifs.Close();
				}

				if (desererror != null)
				{
					ErrorReporter.GenerateErrorReport("Error deserializing particular attachments.");
				}
			}
		}
コード例 #13
0
        public static void Load(bool initonly)
        {
            if (initonly)
            {
                Console.WriteLine("Initializing ResourcePool database...");
            }
            else
            {
                Console.WriteLine("Resource Pool Loading...");
            }

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

            bool             newconfig = false;
            FileStream       rpfs      = new FileStream("Saves/ResourcePool/ResourcePool.dat", FileMode.OpenOrCreate, FileAccess.Read);
            BinaryFileReader rpreader  = new BinaryFileReader(new BinaryReader(rpfs));

            if (!rpreader.End())
            {
                int rpversion = rpreader.ReadInt();
                switch (rpversion)
                {
                case 0:
                {
                    m_LastModified = rpreader.ReadDateTime();
                    FileInfo fi = new FileInfo("Data/ResourcePool/config.xml");
                    if (fi.LastWriteTime != m_LastModified)
                    {
                        m_LastModified = fi.LastWriteTime;
                        newconfig      = true;
                    }
                    else
                    {
                        newconfig = false;
                    }

                    break;
                }

                default:
                    throw new Exception("Error loading ResourcePool: Invalid ResourcePool.dat save version");
                }
            }
            else
            {
                m_LastModified = (new FileInfo("Data/ResourcePool/config.xml")).LastWriteTime;
                Console.WriteLine("Warning: Saves/ResourcePool/ResourcePool.dat not found.");
                newconfig = true;
            }

            if (newconfig)
            {
                Console.WriteLine("New configuration detected! Reading from Data/...");
            }
            XmlTextReader reader;

            reader = new XmlTextReader((newconfig ? "Data/ResourcePool/config.xml" : "Saves/ResourcePool/config.xml"));
            reader.WhitespaceHandling = WhitespaceHandling.None;

            FileStream       rcfs     = new FileStream("Saves/ResourcePool/Consignments.dat", FileMode.OpenOrCreate, FileAccess.Read);
            FileStream       dfs      = new FileStream("Saves/ResourcePool/Debts.dat", FileMode.OpenOrCreate, FileAccess.Read);
            BinaryFileReader rcreader = new BinaryFileReader(new BinaryReader(rcfs));
            BinaryFileReader dreader  = new BinaryFileReader(new BinaryReader(dfs));

            try { reader.MoveToContent(); }
            catch
            {
                Console.WriteLine("Save xml data not found or invalid, reverting to defaults");
                reader = new XmlTextReader("Data/ResourcePool/config.xml");
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.MoveToContent();
            }

            int version = Int32.Parse(reader.GetAttribute("version"));

            reader.ReadStartElement("ResourcePool");

            switch (version)
            {
            case 0:
            {
                m_PaymentFactor     = Double.Parse(reader.ReadElementString("PaymentFactor"));
                m_FailsafePriceHike = Double.Parse(reader.ReadElementString("FailsafePriceHike"));

                m_Resources = new Hashtable();
                while (reader.LocalName == "ResourceData")
                {
                    ResourceData rd = new ResourceData(reader, (initonly ? null : rcreader));
                    if (rd != null)
                    {
                        m_Resources[rd.Type] = rd;
                    }
                }
                while (reader.LocalName == "RDRedirect")
                {
                    RDRedirect rd = new RDRedirect(reader, (initonly ? null : rcreader));
                    if (rd != null)
                    {
                        m_Resources[rd.Type] = rd;
                    }
                }

                m_Debts = new Hashtable();

                if (initonly)
                {
                    break;
                }

                while (!dreader.End())
                {
                    try
                    {
                        Mobile m    = dreader.ReadMobile();
                        double debt = dreader.ReadDouble();
                        if (m != null)
                        {
                            m_Debts[m] = debt;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception occured attempting to desrialize from Debts.dat : " + ex.Message);
                        break;
                    }
                }

                break;
            }

            case 1:
            {
                m_PaymentFactor     = Double.Parse(reader.ReadElementString("PaymentFactor"));
                m_FailsafePriceHike = Double.Parse(reader.ReadElementString("FailsafePriceHike"));

                m_Resources = new Hashtable();
                while (reader.LocalName == "ResourceData")
                {
                    ResourceData rd = new ResourceData(reader, (initonly ? null : rcreader));
                    if (rd != null)
                    {
                        m_Resources[rd.Type] = rd;
                    }
                }
                while (reader.LocalName == "RDRedirect")
                {
                    RDRedirect rd = new RDRedirect(reader, (initonly ? null : rcreader));
                    if (rd != null)
                    {
                        m_Resources[rd.Type] = rd;
                    }
                }

                m_Debts = new Hashtable();

                if (initonly)
                {
                    break;
                }

                // read count
                int count = dreader.ReadInt();

                for (int ix = 0; ix < count; ix++)
                {
                    Mobile m    = dreader.ReadMobile();
                    double debt = dreader.ReadDouble();
                    if (m != null)
                    {
                        m_Debts[m] = debt;
                    }
                }

                break;
            }

            default:
            {
                throw new Exception("Invalid ResourcePool save version.");
            }
            }

            reader.ReadEndElement();
            reader.Close();
            rcfs.Close();
            rpfs.Close();
            dfs.Close();
        }
コード例 #14
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"); }
        }
コード例 #15
0
ファイル: Perk.cs プロジェクト: zerodowned/Ulmeta
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if (!File.Exists(DataFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int version = reader.ReadInt();

                switch (version)
                {
                case 0:
                    int tableCount = reader.ReadInt();
                    PerkTable = new Dictionary <Player, Tuple <Perk, Perk> >(tableCount);

                    Player player;
                    Perk   p1, p2;

                    try
                    {
                        for (int i = 0; i < tableCount; i++)
                        {
                            player = reader.ReadMobile <Player>();

                            if (player == null || player.Deleted)
                            {
                                continue;
                            }

                            ConstructorInfo ctor = GetPerkCtor(reader.ReadString());
                            p1 = ctor.Invoke(new object[] { reader }) as Perk;

                            ctor = GetPerkCtor(reader.ReadString());
                            p2   = ctor.Invoke(new object[] { reader }) as Perk;

                            PerkTable[player] = Tuple.Create <Perk, Perk>(p1, p2);
                        }
                    }

                    catch (Exception e)
                    {
                        //Console.WriteLine();
                        //Utility.PushColor(ConsoleColor.Yellow);
                        //Console.Write("Warning: ");
                        //Utility.PushColor(ConsoleColor.White);
                        //Console.WriteLine("[Perks, OnWorldLoad ("+e.Message+")]");

                        //if (e.InnerException != null)
                        //Console.WriteLine("[Inner Exception: (" + e.InnerException + ")]");
                    }

                    break;
                }

                reader.Close();
            }
        }