/// <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; } }
/// <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"/> private KernelBin() { Memory.Log.WriteLine($"{nameof(KernelBin)} :: new "); var aw = ArchiveWorker.Load(ArchiveString); var buffer = aw.GetBinaryFile(Memory.Strings[Strings.FileID.Kernel].GetFileNames()[0]); var subPositions = Memory.Strings[Strings.FileID.Kernel].GetFiles().SubPositions; MemoryStream ms; if (buffer == null) { return; } using (var br = new BinaryReader(ms = new MemoryStream(buffer))) { ms.Seek(subPositions[BattleCommand.ID], SeekOrigin.Begin); BattleCommands = BattleCommand.Read(br); ms.Seek(subPositions[Kernel.MagicData.ID], SeekOrigin.Begin); MagicData = Kernel.MagicData.Read(br); ms.Seek(subPositions[Kernel.JunctionableGFsData.ID], SeekOrigin.Begin); JunctionableGFsData = Kernel.JunctionableGFsData.Read(br); ms.Seek(subPositions[Kernel.EnemyAttacksData.ID], SeekOrigin.Begin); EnemyAttacksData = Kernel.EnemyAttacksData.Read(br, BattleCommands); ms.Seek(subPositions[Kernel.WeaponsData.ID], SeekOrigin.Begin); WeaponsData = Kernel.WeaponsData.Read(br); ms.Seek(subPositions[Kernel.RenzokukenFinishersData.ID], SeekOrigin.Begin); RenzokukenFinishersData = Kernel.RenzokukenFinishersData.Read(br); ms.Seek(subPositions[Kernel.CharacterStats.ID], SeekOrigin.Begin); CharacterStats = Kernel.CharacterStats.Read(br); ms.Seek(subPositions[BattleItemData.ID], SeekOrigin.Begin); BattleItemsData = BattleItemData.Read(br); NonBattleItemsData = Kernel.NonBattleItemsData.Read(); ms.Seek(subPositions[Kernel.NonJunctionableGFsAttacksData.ID], SeekOrigin.Begin); NonJunctionableGFsAttacksData = Kernel.NonJunctionableGFsAttacksData.Read(br); ms.Seek(subPositions[Kernel.CommandAbilityData.ID], SeekOrigin.Begin); CommandAbilityData = Kernel.CommandAbilityData.Read(br); ms.Seek(subPositions[Kernel.JunctionAbilities.ID], SeekOrigin.Begin); JunctionAbilities = Kernel.JunctionAbilities.Read(br); ms.Seek(subPositions[Kernel.CommandAbility.ID], SeekOrigin.Begin); CommandAbilities = Kernel.CommandAbility.Read(br, BattleCommands); 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[Kernel.TemporaryCharacterLimitBreaks.ID], SeekOrigin.Begin); TemporaryCharacterLimitBreaks = Kernel.TemporaryCharacterLimitBreaks.Read(br); ms.Seek(subPositions[Kernel.BlueMagicQuistisLimitBreak.ID], SeekOrigin.Begin); BlueMagicQuistisLimitBreak = Kernel.BlueMagicQuistisLimitBreak.Read(br); //ms.Seek(subPositions[Quistis_limit_break_parameters.ID], SeekOrigin.Begin); //QuistisLimitBreakParameters = Quistis_limit_break_parameters.Read(br); ms.Seek(subPositions[Kernel.ShotIrvineLimitBreak.ID], SeekOrigin.Begin); ShotIrvineLimitBreak = Kernel.ShotIrvineLimitBreak.Read(br); ms.Seek(subPositions[Kernel.DuelZellLimitBreak.ID], SeekOrigin.Begin); DuelZellLimitBreak = Kernel.DuelZellLimitBreak.Read(br); ms.Seek(subPositions[Kernel.ZellLimitBreakParameters.ID], SeekOrigin.Begin); ZellLimitBreakParameters = Kernel.ZellLimitBreakParameters.Read(br); ms.Seek(subPositions[Kernel.RinoaLimitBreaksPart1.ID], SeekOrigin.Begin); RinoaLimitBreaksPart1 = Kernel.RinoaLimitBreaksPart1.Read(br); ms.Seek(subPositions[Kernel.RinoaLimitBreaksPart2.ID], SeekOrigin.Begin); RinoaLimitBreaksPart2 = Kernel.RinoaLimitBreaksPart2.Read(br); ms.Seek(subPositions[Kernel.SlotArray.ID], SeekOrigin.Begin); SlotArray = Kernel.SlotArray.Read(br); ms.Seek(subPositions[Kernel.SelphieLimitBreakSets.ID], SeekOrigin.Begin); SelphieLimitBreakSets = Kernel.SelphieLimitBreakSets.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 = Kernel.Devour.Read(br); ms.Seek(subPositions[Kernel.MiscSection.ID], SeekOrigin.Begin); MiscSection = Kernel.MiscSection.Read(br); MiscTextPointers = Kernel.MiscTextPointers.Read(); var allAbilities = new Dictionary <Abilities, IAbility>( Kernel.MenuAbilities.Count + Kernel.JunctionAbilities.Count + Kernel.CommandAbility.Count + StatPercentageAbilities.Count + Kernel.CharacterAbilities.Count + Kernel.PartyAbilities.Count + Kernel.GFAbilities.Count); var equippableAbilities = new Dictionary <Abilities, IEquippableAbility>( StatPercentageAbilities.Count + Kernel.CharacterAbilities.Count + Kernel.PartyAbilities.Count + Kernel.GFAbilities.Count); foreach (var ability in (Abilities[])(Enum.GetValues(typeof(Abilities)))) { combine(MenuAbilities); combine(StatPercentAbilities); combine(JunctionAbilities); combine(CommandAbilities); combine(CharacterAbilities); combine(PartyAbilities); combine(GFAbilities); combine2(StatPercentAbilities); combine2(CharacterAbilities); combine2(PartyAbilities); combine2(CharacterAbilities); void combine <T>(IReadOnlyDictionary <Abilities, T> dict) where T : IAbility { if (!dict.TryGetValue(ability, out var a) || allAbilities.ContainsKey(ability)) { return; } allAbilities.Add(ability, a); } void combine2 <T>(IReadOnlyDictionary <Abilities, T> dict) where T : IEquippableAbility { if (!dict.TryGetValue(ability, out var a) || equippableAbilities.ContainsKey(ability)) { return; } equippableAbilities.Add(ability, a); } } AllAbilities = allAbilities; EquippableAbilities = equippableAbilities; } }