コード例 #1
0
ファイル: PlayerMacros.cs プロジェクト: uotools/JuicyUO
        private bool Unserialize(BinaryFileReader reader)
        {
            uint magic = reader.ReadUInt();

            if (magic != MAGIC)
            {
                return(false);
            }

            if (m_Macros == null)
            {
                m_Macros = new List <Action>();
            }
            m_Macros.Clear();

            int version = reader.ReadInt();
            int count   = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Action action = new Action();
                action.Keystroke = (WinKeys)reader.ReadUShort();
                action.Ctrl      = reader.ReadBool();
                action.Alt       = reader.ReadBool();
                action.Shift     = reader.ReadBool();
                reader.ReadBool(); // unused filler byte

                int macroCount = reader.ReadUShort();
                for (int j = 0; j < macroCount; j++)
                {
                    int type = reader.ReadInt();
                    Macro.ValueTypes valueType = (Macro.ValueTypes)reader.ReadByte();
                    if (valueType == Macro.ValueTypes.Integer)
                    {
                        action.Macros.Add(new Macro((MacroType)type, reader.ReadInt()));
                    }
                    else if (valueType == Macro.ValueTypes.String)
                    {
                        action.Macros.Add(new Macro((MacroType)type, reader.ReadString()));
                    }
                    else
                    {
                        action.Macros.Add(new Macro((MacroType)type));
                    }
                }

                m_Macros.Add(action);
            }

            return(true);
        }
コード例 #2
0
ファイル: PlayerMacros.cs プロジェクト: BclEx/object-assets
        private bool Unserialize(BinaryFileReader r)
        {
            var magic = r.ReadUInt();

            if (magic != MAGIC)
            {
                return(false);
            }

            if (_macros == null)
            {
                _macros = new List <Action>();
            }
            _macros.Clear();
            var version = r.ReadInt();
            var count   = r.ReadInt();

            for (var i = 0; i < count; i++)
            {
                var action = new Action();
                action.Keystroke = (WinKeys)r.ReadUShort();
                action.Ctrl      = r.ReadBool();
                action.Alt       = r.ReadBool();
                action.Shift     = r.ReadBool();
                r.ReadBool(); // unused filler byte

                var macroCount = r.ReadUShort();
                for (var j = 0; j < macroCount; j++)
                {
                    var type      = r.ReadInt();
                    var valueType = (Macro.ValueTypes)r.ReadByte();
                    if (valueType == Macro.ValueTypes.Integer)
                    {
                        action.Macros.Add(new Macro((MacroType)type, r.ReadInt()));
                    }
                    else if (valueType == Macro.ValueTypes.String)
                    {
                        action.Macros.Add(new Macro((MacroType)type, r.ReadString()));
                    }
                    else
                    {
                        action.Macros.Add(new Macro((MacroType)type));
                    }
                }
                _macros.Add(action);
            }

            return(true);
        }
コード例 #3
0
        private void ReadHeader(BinaryFileReader reader)
        {
            // Check map for validity
            // Note: disabled, causes decompression of the entire file ( = SLOW)
            //if(inputStream->getSize() < 50)
            //{
            //	throw std::runtime_error("Corrupted map file.");
            //}

            // Map version
            UInt32 byte1 = reader.ReadUInt32();

            Console.WriteLine("Map version:" + byte1);
            mapObject.Header.Version = (EMapFormat)byte1;


            mapObject.Header.AreAnyPlayers = reader.ReadBool();
            Console.WriteLine("AreAnyPlayers:" + mapObject.Header.AreAnyPlayers);

            mapObject.Header.Height = reader.ReadUInt32();
            mapObject.Header.Width  = mapObject.Header.Height;
            Console.WriteLine("Map Height and Width:" + mapObject.Header.Height);

            mapObject.Header.IsTwoLevel = reader.ReadBool();
            Console.WriteLine("twoLevel:" + mapObject.Header.IsTwoLevel);


            mapObject.Header.Name = reader.ReadString();
            Console.WriteLine("Name:" + mapObject.Header.Name);

            mapObject.Header.Description = reader.ReadString();
            Console.WriteLine("Description:" + mapObject.Header.Description);

            mapObject.Header.Difficulty = reader.ReadUInt8();
            Console.WriteLine("Difficulty:" + mapObject.Header.Difficulty);

            int heroLevelLimit = reader.ReadUInt8();

            Console.WriteLine("HeroLevelLimit:" + heroLevelLimit);


            ReadPlayerInfo(reader);

            ReadVictoryLossConditions(reader);

            ReadTeamInfo(reader);

            ReadAllowedHeroes(reader);
        }
コード例 #4
0
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_Loaded = new Hashtable();

            switch (version)
            {
            case 0:
            {
                int keys = reader.ReadInt();
                for (int i = 0; i < keys; i++)
                {
                    School    school    = (School)reader.ReadInt();
                    ArrayList valuelist = new ArrayList();

                    int values = reader.ReadInt();
                    for (int j = 0; j < values; j++)
                    {
                        valuelist.Add(new CSpellInfo(reader));
                    }

                    m_Loaded.Add(school, valuelist);
                }

                CSSettings.FullSpellbooks = reader.ReadBool();
                PrevVersion = reader.ReadInt();

                Refresh();
                Update();
                break;
            }
            }
        }
コード例 #5
0
        public static void LoadData()
        {
            if (File.Exists(SavePath))
            {
                using (FileStream fs = new FileStream(SavePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader     br     = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        int count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            Serial   serial = reader.ReadInt();
                            DuelInfo info   = new DuelInfo(null);

                            info.Deserialize(reader);

                            m_Infos.Add(serial, info);
                        }

                        count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            DuelArena arena = new DuelArena("Loading...");
                            arena.Deserialize(reader);

                            m_Arenas.Add(arena);
                        }

                        m_Enabled = reader.ReadBool();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
コード例 #6
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;
            }
            }
        }
コード例 #7
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;
            }
            }
        }
コード例 #8
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("---------");
            }
        }
コード例 #9
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();
        }
コード例 #10
0
        private void ReadVictoryLossConditions(BinaryFileReader reader)
        {
            //// mapObject.Header.TrigggeredEvents = new List<TrigggeredEvent>();

            var vicCondition = (EVictoryConditionType)reader.ReadUInt8();

            if (vicCondition == EVictoryConditionType.WINSTANDARD)
            {
                // create normal condition
            }
            else
            {
                bool allowNormalVictory = reader.ReadBool();
                bool appliesToAI        = reader.ReadBool();

                if (allowNormalVictory)
                {
                    int playersOnMap = 2;
                    if (playersOnMap == 1)
                    {
                        //// logGlobal->warn("Map %s has only one player but allows normal victory?", mapHeader->name);
                        allowNormalVictory = false; // makes sense? Not much. Works as H3? Yes!
                    }
                }

                switch (vicCondition)
                {
                case EVictoryConditionType.ARTIFACT:
                {
                    int objectType = reader.ReadUInt8();
                    break;
                }

                case EVictoryConditionType.GATHERTROOP:
                {
                    int  objectType = reader.ReadUInt8();
                    uint value      = reader.ReadUInt32();
                    break;
                }

                case EVictoryConditionType.GATHERRESOURCE:
                {
                    int  objectType = reader.ReadUInt8();
                    uint value      = reader.ReadUInt32();
                    break;
                }

                case EVictoryConditionType.BUILDCITY:
                {
                    var pos         = reader.ReadPosition();
                    int objectType  = reader.ReadUInt8();
                    int objectType2 = reader.ReadUInt8();

                    break;
                }

                case EVictoryConditionType.BUILDGRAIL:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case EVictoryConditionType.BEATHERO:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case EVictoryConditionType.CAPTURECITY:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case EVictoryConditionType.BEATMONSTER:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case EVictoryConditionType.TAKEDWELLINGS:
                {
                    break;
                }

                case EVictoryConditionType.TAKEMINES:
                {
                    break;
                }

                case EVictoryConditionType.TRANSPORTITEM:
                {
                    uint value = reader.ReadUInt32();
                    var  pos   = reader.ReadPosition();
                    break;
                }

                default:
                    break;
                }
            }


            ELossConditionType loseCondition = (ELossConditionType)reader.ReadUInt8();

            Console.WriteLine("Lose Condition:" + loseCondition);
            if (loseCondition != ELossConditionType.LOSSSTANDARD)
            {
                switch (loseCondition)
                {
                case ELossConditionType.LOSSCASTLE:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case ELossConditionType.LOSSHERO:
                {
                    var pos = reader.ReadPosition();
                    break;
                }

                case ELossConditionType.TIMEEXPIRES:
                {
                    int val = reader.ReadUInt16();
                    break;
                }

                default:
                    break;
                }
            }
        }
コード例 #11
0
        private void ReadPredefinedHeroes(BinaryFileReader reader)
        {
            if (mapObject.Header.Version == EMapFormat.WOG || mapObject.Header.Version == EMapFormat.SOD)
            {
                for (int z = 0; z < GameConstants.HEROES_QUANTITY; z++)
                {
                    Console.WriteLine(string.Format("===Reading Predefined Hero [{0}]", z));

                    int custom = reader.ReadUInt8();
                    if (custom == 0)
                    {
                        Console.WriteLine("is not custom.");
                        continue;
                    }

                    // Create Hero
                    bool hasExp = reader.ReadBool();
                    if (hasExp)
                    {
                        uint exp = reader.ReadUInt32();
                        Console.WriteLine("Has exp:" + exp);
                    }

                    bool hasSecondSkills = reader.ReadBool();
                    if (hasSecondSkills)
                    {
                        uint howMany = reader.ReadUInt32();
                        Console.WriteLine("Has Second Skills count=" + howMany);

                        for (int yy = 0; yy < howMany; ++yy)
                        {
                            int first  = reader.ReadUInt8();
                            int second = reader.ReadUInt8();
                            Console.WriteLine(string.Format("Skill First: {0} Second: {1}", first, second));
                        }
                    }

                    // Set Artifacts
                    bool artSet = reader.ReadBool();
                    if (artSet)
                    {
                        Console.WriteLine("Artifact is set.");

                        if (false)
                        {
                            // Already set the pack
                        }

                        for (int pom = 0; pom < 16; pom++)
                        {
                            LoadArtifactToSlot(reader, null, pom);
                        }

                        if (true)
                        {
                            LoadArtifactToSlot(reader, null, 0);   //catapult
                        }

                        LoadArtifactToSlot(reader, null, 0);   //SpellBook


                        // Misc5 possibly
                        LoadArtifactToSlot(reader, null, 0);   //Misc

                        // Backpack items
                        int amount = reader.ReadUInt16();
                        Console.WriteLine("Backpack item amount:" + amount);
                        for (int ss = 0; ss < amount; ++ss)
                        {
                            LoadArtifactToSlot(reader, null, 0);
                        }
                    }

                    bool hasCustomBio = reader.ReadBool();
                    if (hasCustomBio)
                    {
                        string biography = reader.ReadString();
                        Console.WriteLine("biography: " + biography);
                    }

                    int sex = reader.ReadUInt8();
                    Console.WriteLine("sex: " + sex);

                    // Spells
                    bool hasCustomSpells = reader.ReadBool();
                    if (hasCustomSpells)
                    {
                        HashSet <int> spells = new HashSet <int>();
                        reader.ReadBitMask(spells, 9, GameConstants.SPELLS_QUANTITY, false);
                        Console.WriteLine("Spells: " + JsonConvert.SerializeObject(spells));
                    }

                    bool hasCustomPrimSkills = reader.ReadBool();
                    if (hasCustomPrimSkills)
                    {
                        Console.WriteLine("Has Custom Primary Skills.");
                        for (int xx = 0; xx < GameConstants.PRIMARY_SKILLS; xx++)
                        {
                            int value = reader.ReadUInt8();
                            Console.WriteLine("Primary Skills: " + value);
                        }
                    }
                }
            }
        }
コード例 #12
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);
            }
        }
コード例 #13
0
ファイル: ForumCore.cs プロジェクト: greeduomacro/last-wish
		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( "Loading...done" );
			}
			catch(Exception err)
			{
				Console.WriteLine( "An error occured while loading the forums...{0}", err.ToString() );
			}
		}
コード例 #14
0
        // 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.");
            }
        }
コード例 #15
0
ファイル: CSS.cs プロジェクト: evildude807/kaltar
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_Loaded = new Hashtable();

            switch (version)
            {
                case 0:
                    {
                        int keys = reader.ReadInt();
                        for (int i = 0; i < keys; i++)
                        {
                            School school = (School)reader.ReadInt();
                            ArrayList valuelist = new ArrayList();

                            int values = reader.ReadInt();
                            for (int j = 0; j < values; j++)
                            {
                                valuelist.Add(new CSpellInfo(reader));
                            }

                            m_Loaded.Add(school, valuelist);
                        }

                        CSSettings.FullSpellbooks = reader.ReadBool();
                        PrevVersion = reader.ReadInt();

                        Refresh();
                        Update();
                        break;
                    }
            }
        }
コード例 #16
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"); }
        }
コード例 #17
0
 public void LoadPlugin(BinaryFileReader reader)
 {
     SkillReportsHelper.EnableProfileReport   = reader.ReadBool();
     SkillReportsHelper.EnableSelectionReport = reader.ReadBool();
 }
コード例 #18
0
ファイル: Data.cs プロジェクト: furkanugur/imaginenation
        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;
            }
        }
コード例 #19
0
        private void ReadPlayerInfo(BinaryFileReader reader)
        {
            for (int i = 0; i < GameConstants.PLAYER_LIMIT_T; i++)
            {
                PlayerInfo playerInfo = new PlayerInfo();

                Console.WriteLine("Reading Player [" + i.ToString() + "]");

                playerInfo.CanHumanPlay    = reader.ReadBool();
                playerInfo.CanComputerPlay = reader.ReadBool();
                Console.WriteLine("canHumanPlay: " + playerInfo.CanHumanPlay);
                Console.WriteLine("canComputerPlay: " + playerInfo.CanComputerPlay);

                if (!playerInfo.CanHumanPlay && !playerInfo.CanComputerPlay)
                {
                    switch (mapObject.Header.Version)
                    {
                    case EMapFormat.SOD:
                    case EMapFormat.WOG:
                        reader.Skip(13);
                        break;

                    case EMapFormat.AB:
                        reader.Skip(12);
                        break;

                    case EMapFormat.ROE:
                        reader.Skip(6);
                        break;
                    }
                    continue;
                }

                playerInfo.AiTactic = (EAiTactic)reader.ReadUInt8();
                Console.WriteLine("aiTactic:" + playerInfo.AiTactic);

                if (mapObject.Header.Version == EMapFormat.SOD || mapObject.Header.Version == EMapFormat.WOG)
                {
                    playerInfo.P7 = reader.ReadUInt8();
                }
                else
                {
                    playerInfo.P7 = -1;
                }

                Console.WriteLine("p7:" + playerInfo.P7);

                // Reading the Factions for Player
                playerInfo.AllowedFactions = new List <int>();
                int allowedFactionsMask = reader.ReadUInt8();
                Console.WriteLine("allowedFactionsMask:" + allowedFactionsMask);

                int totalFactionCount = GameConstants.F_NUMBER;
                if (mapObject.Header.Version != EMapFormat.ROE)
                {
                    allowedFactionsMask += reader.ReadUInt8() << 8;
                }
                else
                {
                    totalFactionCount--; //exclude conflux for ROE
                }
                for (int fact = 0; fact < totalFactionCount; ++fact)
                {
                    if ((allowedFactionsMask & (1 << fact)) > 0)
                    {
                        playerInfo.AllowedFactions.Add(fact);
                    }
                }

                playerInfo.IsFactionRandom = reader.ReadBool();
                playerInfo.HasMainTown     = reader.ReadBool();
                Console.WriteLine("isFactionRandom:" + playerInfo.IsFactionRandom);
                Console.WriteLine("hasMainTown:" + playerInfo.HasMainTown);

                if (playerInfo.HasMainTown)
                {
                    /// Added in new version, not tested yet
                    if (mapObject.Header.Version != EMapFormat.ROE)
                    {
                        playerInfo.GenerateHeroAtMainTown = reader.ReadBool();
                        playerInfo.GenerateHero           = reader.ReadBool();
                    }
                    else
                    {
                        playerInfo.GenerateHeroAtMainTown = true;
                        playerInfo.GenerateHero           = false;
                    }

                    var townPosition = reader.ReadPosition();
                    Console.WriteLine(string.Format("Main Town Position: {0}, {1}, {2}", townPosition.PosX, townPosition.PosY, townPosition.PosZ));
                    playerInfo.MainTownPosition = townPosition;
                }

                playerInfo.HasRandomHero = reader.ReadBool();
                Console.WriteLine("hasRandomHero:" + playerInfo.HasRandomHero);

                playerInfo.MainCustomHeroId = reader.ReadUInt8();
                Console.WriteLine("mainCustomHeroId:" + playerInfo.MainCustomHeroId);

                if (playerInfo.MainCustomHeroId != 0xff)
                {
                    playerInfo.MainCustomHeroPortrait = reader.ReadUInt8();
                    if (playerInfo.MainCustomHeroPortrait == 0xff)
                    {
                        playerInfo.MainCustomHeroPortrait = -1;
                    }

                    playerInfo.MainCustomHeroName = reader.ReadString();
                    Console.WriteLine("mainCustomHeroPortrait:" + playerInfo.MainCustomHeroPortrait);
                    Console.WriteLine("heroName:" + playerInfo.MainCustomHeroName);
                }
                else
                {
                    playerInfo.MainCustomHeroId = -1;
                }

                if (mapObject.Header.Version != EMapFormat.ROE)
                {
                    playerInfo.PowerPlaceHolders = reader.ReadUInt8();
                    int heroCount = reader.ReadUInt8();
                    reader.Skip(3);

                    playerInfo.HeroIds = new List <HeroIdentifier>();
                    for (int pp = 0; pp < heroCount; ++pp)
                    {
                        HeroIdentifier heroId = new HeroIdentifier();
                        heroId.Id   = reader.ReadUInt8();
                        heroId.Name = reader.ReadString();
                        playerInfo.HeroIds.Add(heroId);
                    }
                }
            }
        }
コード例 #20
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 Dictionary <string, bool>();
                    }

                    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 (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);
            }
        }
コード例 #21
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();
            }
        }
コード例 #22
0
		public void LoadPlugin(BinaryFileReader reader)
		{
			SkillReportsHelper.EnableProfileReport = reader.ReadBool();
			SkillReportsHelper.EnableSelectionReport = reader.ReadBool();
		}
コード例 #23
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();
            }
        }
コード例 #24
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);
            }
        }