Exemple #1
0
            public static Misc_section[] Read(BinaryReader br)
            {
                var ret = new Misc_section[count];

                for (int i = 0; i < count; i++)
                {
                    var tmp = new Misc_section();
                    tmp.Read(br, i);
                    ret[i] = tmp;
                }
                return(ret);
            }
            public static List <Misc_section> Read(BinaryReader br)
            {
                var ret = new List <Misc_section>(count);

                for (int i = 0; i < count; i++)
                {
                    var tmp = new Misc_section();
                    tmp.Read(br, i);
                    ret.Add(tmp);
                }
                return(ret);
            }
Exemple #3
0
        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public KernelBin()
        {
            Memory.Log.WriteLine($"{nameof(KernelBin)} :: new ");
            ArchiveBase aw = ArchiveWorker.Load(ArchiveString);

            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings[Strings.FileID.KERNEL].GetFilenames()[0]);
            List <Loc> subPositions = Memory.Strings[Strings.FileID.KERNEL].GetFiles().subPositions;

            MemoryStream ms;

            if (buffer == null)
            {
                return;
            }
            using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
            {
                ms.Seek(subPositions[BattleCommand.ID], SeekOrigin.Begin);
                BattleCommands = BattleCommand.Read(br);
                ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                MagicData = Magic_Data.Read(br);
                ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                JunctionableGFsData = Junctionable_GFs_Data.Read(br);
                ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                EnemyAttacksData = Enemy_Attacks_Data.Read(br);
                ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                WeaponsData = Weapons_Data.Read(br);
                ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                RenzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                CharacterStats = Character_Stats.Read(br);
                ms.Seek(subPositions[BattleItemData.ID], SeekOrigin.Begin);
                BattleItemsData    = BattleItemData.Read(br);
                NonBattleItemsData = Non_battle_Items_Data.Read();
                ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                NonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                CommandAbilityData = Command_ability_data.Read(br);
                ms.Seek(subPositions[Kernel.JunctionAbilities.ID], SeekOrigin.Begin);
                JunctionAbilities = Kernel.JunctionAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CommandAbilities.ID], SeekOrigin.Begin);
                CommandAbilities = Kernel.CommandAbilities.Read(br);
                ms.Seek(subPositions[StatPercentageAbilities.ID], SeekOrigin.Begin);
                StatPercentAbilities = StatPercentageAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CharacterAbilities.ID], SeekOrigin.Begin);
                CharacterAbilities = Kernel.CharacterAbilities.Read(br);
                ms.Seek(subPositions[Kernel.PartyAbilities.ID], SeekOrigin.Begin);
                PartyAbilities = Kernel.PartyAbilities.Read(br);
                ms.Seek(subPositions[Kernel.GFAbilities.ID], SeekOrigin.Begin);
                GFAbilities = Kernel.GFAbilities.Read(br);
                ms.Seek(subPositions[Kernel.MenuAbilities.ID], SeekOrigin.Begin);
                MenuAbilities = Kernel.MenuAbilities.Read(br);
                ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                TemporaryCharacterLimitBreaks = Temporary_character_limit_breaks.Read(br);
                ms.Seek(subPositions[Blue_Magic_Quistis_limit_break.id], SeekOrigin.Begin);
                BlueMagicQuistisLimitBreak = Blue_Magic_Quistis_limit_break.Read(br);
                //ms.Seek(subPositions[Quistis_limit_break_parameters.BattleID], SeekOrigin.Begin);
                //QuistisLimitBreakParameters = Quistis_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                ShotIrvineLimitBreak = Shot_Irvine_limit_break.Read(br);
                ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                DuelZellLimitBreak = Duel_Zell_limit_break.Read(br);
                ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                ZellLimitBreakParameters = Zell_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart1 = Rinoa_limit_breaks_part_1.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart2 = Rinoa_limit_breaks_part_2.Read(br);
                ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                SlotArray = Slot_array.Read(br);
                ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                SelphieLimitBreakSets = Selphie_limit_break_sets.Read(br);
                ms.Seek(subPositions[Kernel.Devour.id], SeekOrigin.Begin);
                List <Devour> tmp = Kernel.Devour.Read(br);
                tmp.Add(new Devour {
                    Description = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 112)
                });
                Devour = tmp;
                ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                MiscSection      = Misc_section.Read(br);
                MiscTextPointers = Misc_text_pointers.Read();

                Dictionary <Abilities, Ability> allAbilities = new Dictionary <Abilities, Ability>(Kernel.MenuAbilities.Count + Kernel.JunctionAbilities.Count + Kernel.CommandAbilities.Count + StatPercentageAbilities.Count + Kernel.CharacterAbilities.Count + Kernel.PartyAbilities.Count + Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    combine(MenuAbilities);
                    combine(StatPercentAbilities);
                    combine(JunctionAbilities);
                    combine(CommandAbilities);
                    combine(CharacterAbilities);
                    combine(PartyAbilities);
                    combine(GFAbilities);
                    void combine <T>(IReadOnlyDictionary <Abilities, T> dict)
                        where T : Ability
                    {
                        if (!dict.TryGetValue(ability, out T a))
                        {
                            return;
                        }
                        allAbilities.Add(ability, a);
                    }
                }

                AllAbilities = allAbilities;
                Dictionary <Abilities, EquippableAbility> equippableAbilities = new Dictionary <Abilities, EquippableAbility>(
                    StatPercentageAbilities.Count +
                    Kernel.CharacterAbilities.Count +
                    Kernel.PartyAbilities.Count +
                    Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    if (StatPercentAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = StatPercentAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                    else if (PartyAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = PartyAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                }
                EquippableAbilities = equippableAbilities;
            }
        }
Exemple #4
0
        public static Dictionary <Abilities, Equipable_Ability> EquipableAbilities; // contains 4 types;

        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public Kernel_bin()
        {
            aw = new ArchiveWorker(ArchiveString);
            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings.Filenames[(int)Strings.FileID.KERNEL]);
            List <Loc> subPositions = Memory.Strings.Files[Strings.FileID.KERNEL].subPositions;

            using (MemoryStream ms = new MemoryStream(buffer))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    BattleCommands = Battle_Commands.Read(br);
                    ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                    MagicData = Magic_Data.Read(br);
                    ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                    JunctionableGFsData = Junctionable_GFs_Data.Read(br);
                    ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                    EnemyAttacksData = Enemy_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                    WeaponsData = Weapons_Data.Read(br);
                    ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                    RenzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                    ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                    CharacterStats = Character_Stats.Read(br);
                    ms.Seek(subPositions[Battle_Items_Data.id], SeekOrigin.Begin);
                    BattleItemsData    = Battle_Items_Data.Read(br);
                    NonbattleItemsData = Non_battle_Items_Data.Read();
                    ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                    NonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                    Commandabilitydata = Command_ability_data.Read(br);
                    ms.Seek(subPositions[Junction_abilities.id], SeekOrigin.Begin);
                    Junctionabilities = Junction_abilities.Read(br);
                    ms.Seek(subPositions[Command_abilities.id], SeekOrigin.Begin);
                    Commandabilities = Command_abilities.Read(br);
                    ms.Seek(subPositions[Stat_percent_abilities.id], SeekOrigin.Begin);
                    Statpercentabilities = Stat_percent_abilities.Read(br);
                    ms.Seek(subPositions[Character_abilities.id], SeekOrigin.Begin);
                    Characterabilities = Character_abilities.Read(br);
                    ms.Seek(subPositions[Party_abilities.id], SeekOrigin.Begin);
                    Partyabilities = Party_abilities.Read(br);
                    ms.Seek(subPositions[GF_abilities.id], SeekOrigin.Begin);
                    GFabilities = GF_abilities.Read(br);
                    ms.Seek(subPositions[Menu_abilities.id], SeekOrigin.Begin);
                    Menuabilities = Menu_abilities.Read(br);
                    ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                    Temporarycharacterlimitbreaks = Temporary_character_limit_breaks.Read(br);
                    ms.Seek(subPositions[Blue_magic_Quistis_limit_break.id], SeekOrigin.Begin);
                    BluemagicQuistislimitbreak = Blue_magic_Quistis_limit_break.Read(br);
                    //ms.Seek(subPositions[Quistis_limit_break_parameters.id], SeekOrigin.Begin);
                    //Quistislimitbreakparameters = Quistis_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                    ShotIrvinelimitbreak = Shot_Irvine_limit_break.Read(br);
                    ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                    DuelZelllimitbreak = Duel_Zell_limit_break.Read(br);
                    ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                    Zelllimitbreakparameters = Zell_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                    Rinoalimitbreakspart1 = Rinoa_limit_breaks_part_1.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                    Rinoalimitbreakspart2 = Rinoa_limit_breaks_part_2.Read(br);
                    ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                    Slotarray = Slot_array.Read(br);
                    ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                    Selphielimitbreaksets = Selphie_limit_break_sets.Read(br);
                    ms.Seek(subPositions[Devour.id], SeekOrigin.Begin);
                    Devour_ = Devour.Read(br);
                    ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                    Miscsection      = Misc_section.Read(br);
                    Misctextpointers = Misc_text_pointers.Read();

                    EquipableAbilities = new Dictionary <Abilities, Equipable_Ability>(
                        Stat_percent_abilities.count +
                        Character_abilities.count +
                        Party_abilities.count +
                        GF_abilities.count);
                    foreach (Abilities ability in (Abilities[])Enum.GetValues(typeof(Abilities)))
                    {
                        if (Statpercentabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Statpercentabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Characterabilities[ability];
                        }
                        else if (Partyabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Partyabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Characterabilities[ability];
                        }
                    }
                }
        }
Exemple #5
0
        public static IReadOnlyDictionary <Abilities, Equipable_Ability> EquipableAbilities => s_equipableAbilities;      // contains 4 types;

        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public Kernel_bin()
        {
            Memory.Log.WriteLine($"{nameof(Kernel_bin)} :: new ");
            aw = new ArchiveWorker(ArchiveString);
            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings[Strings.FileID.KERNEL].GetFilenames()[0]);
            List <Loc> subPositions = Memory.Strings[Strings.FileID.KERNEL].GetFiles().subPositions;

            MemoryStream ms = null;

            if (buffer != null)
            {
                using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
                {
                    ms.Seek(subPositions[Battle_Commands.id], SeekOrigin.Begin);
                    s_battleCommands = Battle_Commands.Read(br);
                    ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                    s_magicData = Magic_Data.Read(br);
                    ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                    s_junctionableGFsData = Junctionable_GFs_Data.Read(br);
                    ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                    s_enemyAttacksData = Enemy_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                    s_weaponsData = Weapons_Data.Read(br);
                    ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                    s_renzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                    ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                    s_characterStats = Character_Stats.Read(br);
                    ms.Seek(subPositions[Battle_Items_Data.id], SeekOrigin.Begin);
                    s_battleItemsData    = Battle_Items_Data.Read(br);
                    s_nonbattleItemsData = Non_battle_Items_Data.Read();
                    ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                    s_nonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                    s_commandabilitydata = Command_ability_data.Read(br);
                    ms.Seek(subPositions[Junction_abilities.id], SeekOrigin.Begin);
                    s_junctionabilities = Junction_abilities.Read(br);
                    ms.Seek(subPositions[Command_abilities.id], SeekOrigin.Begin);
                    s_commandabilities = Command_abilities.Read(br);
                    ms.Seek(subPositions[Stat_percent_abilities.id], SeekOrigin.Begin);
                    s_statpercentabilities = Stat_percent_abilities.Read(br);
                    ms.Seek(subPositions[Character_abilities.id], SeekOrigin.Begin);
                    s_characterabilities = Character_abilities.Read(br);
                    ms.Seek(subPositions[Party_abilities.id], SeekOrigin.Begin);
                    s_partyabilities = Party_abilities.Read(br);
                    ms.Seek(subPositions[GF_abilities.id], SeekOrigin.Begin);
                    s_gFabilities = GF_abilities.Read(br);
                    ms.Seek(subPositions[Menu_abilities.id], SeekOrigin.Begin);
                    s_menuabilities = Menu_abilities.Read(br);
                    ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                    s_temporarycharacterlimitbreaks = Temporary_character_limit_breaks.Read(br);
                    ms.Seek(subPositions[Blue_magic_Quistis_limit_break.id], SeekOrigin.Begin);
                    s_bluemagicQuistislimitbreak = Blue_magic_Quistis_limit_break.Read(br);
                    //ms.Seek(subPositions[Quistis_limit_break_parameters.id], SeekOrigin.Begin);
                    //Quistislimitbreakparameters = Quistis_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                    s_shotIrvinelimitbreak = Shot_Irvine_limit_break.Read(br);
                    ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                    s_duelZelllimitbreak = Duel_Zell_limit_break.Read(br);
                    ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                    s_zelllimitbreakparameters = Zell_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                    s_rinoalimitbreakspart1 = Rinoa_limit_breaks_part_1.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                    s_rinoalimitbreakspart2 = Rinoa_limit_breaks_part_2.Read(br);
                    ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                    s_slotarray = Slot_array.Read(br);
                    ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                    s_selphielimitbreaksets = Selphie_limit_break_sets.Read(br);
                    ms.Seek(subPositions[Devour.id], SeekOrigin.Begin);
                    s_devour_ = Devour.Read(br);
                    s_devour_.Add(new Devour {
                        Description = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 112)
                    });
                    ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                    s_miscsection      = Misc_section.Read(br);
                    s_misctextpointers = Misc_text_pointers.Read();

                    s_allAbilities = new Dictionary <Abilities, Ability>(
                        Menu_abilities.count +
                        Junction_abilities.count +
                        Command_abilities.count +
                        Stat_percent_abilities.count +
                        Character_abilities.count +
                        Party_abilities.count +
                        GF_abilities.count);
                    foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                    {
                        combine(Menuabilities);
                        combine(Statpercentabilities);
                        combine(Junctionabilities);
                        combine(Commandabilities);
                        combine(Characterabilities);
                        combine(Partyabilities);
                        combine(GFabilities);
                        bool combine <T>(IReadOnlyDictionary <Abilities, T> dict)
                            where T : Ability
                        {
                            if (dict.TryGetValue(ability, out T a))
                            {
                                s_allAbilities.Add(ability, a);
                                return(true);
                            }
                            return(false);
                        }
                    }

                    s_equipableAbilities = new Dictionary <Abilities, Equipable_Ability>(
                        Stat_percent_abilities.count +
                        Character_abilities.count +
                        Party_abilities.count +
                        GF_abilities.count);
                    foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                    {
                        if (Statpercentabilities.ContainsKey(ability))
                        {
                            s_equipableAbilities[ability] = Statpercentabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            s_equipableAbilities[ability] = Characterabilities[ability];
                        }
                        else if (Partyabilities.ContainsKey(ability))
                        {
                            s_equipableAbilities[ability] = Partyabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            s_equipableAbilities[ability] = Characterabilities[ability];
                        }
                    }
                    ms = null;
                }
            }
        }