private bool LoadFile(Stream stream, uint shopStart, uint shopCount, uint itemStart, uint itemCount, EndianUtils.Endianness endian, BitUtils.Bitness bits) { ShopDefinitions = new List <ShopDefinition>((int)shopCount); ShopItems = new List <ShopItem>((int)itemCount); for (int i = 0; i < shopCount; ++i) { stream.Position = shopStart + i * (28 + bits.NumberOfBytes()); var shop = new ShopDefinition(stream, endian, bits); ShopDefinitions.Add(shop); } for (int i = 0; i < itemCount; ++i) { stream.Position = itemStart + i * 56; var item = new ShopItem(stream, endian); ShopItems.Add(item); } foreach (var shop in ShopDefinitions) { shop.ShopItems = ShopItems.Where(x => x.ShopID == shop.InGameID).ToArray(); } ShopDictionary = new Dictionary <uint, ShopDefinition>(); foreach (var shop in ShopDefinitions) { ShopDictionary.Add(shop.InGameID, shop); } return(true); }
public Skill(System.IO.Stream stream, uint refStringStart, EndianUtils.Endianness endian, BitUtils.Bitness bits) { uint entrySize = stream.ReadUInt32().FromEndian(endian); if (entrySize != (0x3C + bits.NumberOfBytes())) { throw new Exception("Unknown Skill size."); } ID = stream.ReadUInt32().FromEndian(endian); InGameID = stream.ReadUInt32().FromEndian(endian); ulong refStringLocation = stream.ReadUInt(bits, endian); NameStringDicID = stream.ReadUInt32().FromEndian(endian); DescStringDicID = stream.ReadUInt32().FromEndian(endian); Unknown7 = stream.ReadUInt32().FromEndian(endian); LearnableByBitmask = stream.ReadUInt32().FromEndian(endian); EquipCost = stream.ReadUInt32().FromEndian(endian); LearnCost = stream.ReadUInt32().FromEndian(endian); Category = stream.ReadUInt32().FromEndian(endian); // Game sums up this value per category, then figures out the OVL-symbol from the totals SymbolValue = stream.ReadUInt32().FromEndian(endian); Unknown13 = stream.ReadUInt32().FromEndian(endian).UIntToFloat(); Unknown14 = stream.ReadUInt32().FromEndian(endian).UIntToFloat(); Unknown15 = stream.ReadUInt32().FromEndian(endian).UIntToFloat(); Inactive = stream.ReadUInt32().FromEndian(endian); RefString = stream.ReadAsciiNulltermFromLocationAndReset((long)(refStringStart + refStringLocation)); }
public ShopDefinition(System.IO.Stream stream, EndianUtils.Endianness endian, BitUtils.Bitness bits) { InGameID = stream.ReadUInt32().FromEndian(endian); StringDicID = stream.ReadUInt32().FromEndian(endian); stream.ReadUInt32().FromEndian(endian); // second instance of string dic id? stream.ReadUInt32().FromEndian(endian); // always empty? OnTrigger = stream.ReadUInt32().FromEndian(endian); ChangeToShop = stream.ReadUInt32().FromEndian(endian); stream.DiscardBytes(4 + bits.NumberOfBytes()); // always empty? }
public GradeShopEntry(System.IO.Stream stream, uint refStringStart, EndianUtils.Endianness endian, BitUtils.Bitness bits) { uint entrySize = stream.ReadUInt32().FromEndian(endian); if (entrySize != (0x18 + bits.NumberOfBytes())) { throw new Exception("Unexpected GradeShopEntry size."); } ID = stream.ReadUInt32().FromEndian(endian); InGameID = stream.ReadUInt32().FromEndian(endian); ulong refStringLocation = stream.ReadUInt(bits, endian); NameStringDicID = stream.ReadUInt32().FromEndian(endian); DescStringDicID = stream.ReadUInt32().FromEndian(endian); GradeCost = stream.ReadUInt32().FromEndian(endian); RefString = stream.ReadAsciiNulltermFromLocationAndReset((long)(refStringStart + refStringLocation)); }
private static List <ScenarioFileEntry> FindText(Stream stream, uint textStart, TextUtils.GameTextEncoding encoding, EndianUtils.Endianness endian, BitUtils.Bitness bits) { var list = new List <ScenarioFileEntry>(); uint toMatch = (0x040C0000 + 2 * 4 + 4 * bits.NumberOfBytes()); while (stream.Position < textStart) { uint identifyingBytes = stream.ReadUInt32().FromEndian(endian); if (identifyingBytes == toMatch) { uint pos = (uint)stream.Position; uint pointerToText = stream.ReadUInt32().FromEndian(endian) + textStart; stream.Position = pointerToText; stream.ReadUInt32().FromEndian(endian); stream.ReadUInt32().FromEndian(endian); ulong jpNamePtr = stream.ReadUInt(bits, endian); ulong jpTextPtr = stream.ReadUInt(bits, endian); ulong enNamePtr = stream.ReadUInt(bits, endian); ulong enTextPtr = stream.ReadUInt(bits, endian); stream.Position = (long)(jpNamePtr + textStart); string jpName = stream.ReadNulltermString(encoding); stream.Position = (long)(jpTextPtr + textStart); string jpText = stream.ReadNulltermString(encoding); stream.Position = (long)(enNamePtr + textStart); string enName = stream.ReadNulltermString(encoding); stream.Position = (long)(enTextPtr + textStart); string enText = stream.ReadNulltermString(encoding); var entry = new ScenarioFileEntry() { Pointer = pos, JpName = jpName, EnName = enName, JpText = jpText, EnText = enText }; list.Add(entry); stream.Position = pos + 4; } } return(list); }
private void LoadFile(Stream TO8CHTX, EndianUtils.Endianness endian, TextUtils.GameTextEncoding encoding, BitUtils.Bitness bits, int languageCount) { Header = new ChatFileHeader(); ulong pos = (ulong)TO8CHTX.Position; Header.Identify = TO8CHTX.ReadUInt64().FromEndian(endian); Header.Filesize = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Lines = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Unknown = TO8CHTX.ReadUInt32().FromEndian(endian); Header.TextStart = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Empty = TO8CHTX.ReadUInt64().FromEndian(endian); Lines = new ChatFileLine[Header.Lines]; int entrySize = (int)(4 + (languageCount + 1) * bits.NumberOfBytes()); for (int i = 0; i < Header.Lines; i++) { Lines[i] = new ChatFileLine(); Lines[i].Location = 0x20 + i * entrySize; Lines[i].NamePointer = TO8CHTX.ReadUInt(bits, endian); Lines[i].TextPointers = new ulong[languageCount]; for (int j = 0; j < languageCount; ++j) { Lines[i].TextPointers[j] = TO8CHTX.ReadUInt(bits, endian); } Lines[i].Unknown = TO8CHTX.ReadUInt32().FromEndian(endian); Lines[i].SName = TO8CHTX.ReadNulltermStringFromLocationAndReset((long)(pos + Lines[i].NamePointer + Header.TextStart), encoding); Lines[i].STexts = new string[languageCount]; for (int j = 0; j < languageCount; ++j) { Lines[i].STexts[j] = TO8CHTX.ReadNulltermStringFromLocationAndReset((long)(pos + Lines[i].TextPointers[j] + Header.TextStart), encoding).Replace('@', ' '); } } }
public FloorInfo(System.IO.Stream stream, uint refStringStart, EndianUtils.Endianness endian, BitUtils.Bitness bits) { uint atLeastBytes = (0x10 + 2 * (bits.NumberOfBytes())); EntrySize = stream.ReadUInt32().FromEndian(endian); if (EntrySize < atLeastBytes) { throw new Exception("This file confuses me."); } uint unknown2 = stream.ReadUInt32().FromEndian(endian); uint unknown3 = stream.ReadUInt32().FromEndian(endian); ulong unknown4 = stream.ReadUInt(bits, endian); uint unknown5 = stream.ReadUInt32().FromEndian(endian); ulong unknown6 = stream.ReadUInt(bits, endian); if (EntrySize > atLeastBytes) { stream.DiscardBytes(EntrySize - atLeastBytes); } RefString1 = stream.ReadAsciiNulltermFromLocationAndReset((long)(refStringStart + unknown4)); RefString2 = stream.ReadAsciiNulltermFromLocationAndReset((long)(refStringStart + unknown6)); }
public Arte(System.IO.Stream stream, uint refStringStart, EndianUtils.Endianness endian, BitUtils.Bitness bits) { uint Size = stream.PeekUInt32().FromEndian(endian); if ((Size % 4) != 0) { throw new Exception("Arte data size not divisble by 4."); } Size -= (bits.NumberOfBytes() - 4) * 2; // just hack this so i don't have to rewrite this mess... Data = new uint[Size / 4]; for (int i = 0; i < Data.Length; ++i) { if (i == 3 || i == 4) { Data[i] = (uint)stream.ReadUInt(bits, endian); // just hack this so i don't have to rewrite this mess... } else { Data[i] = stream.ReadUInt32().FromEndian(endian); } } ID = Data[1]; InGameID = Data[2]; uint refStringLocaton = Data[3]; // seems to be identical with Data[4] RefString = stream.ReadAsciiNulltermFromLocationAndReset(refStringStart + refStringLocaton); NameStringDicId = Data[5]; DescStringDicId = Data[6]; Type = (ArteType)Data[7]; TPUsage = Data[8]; ElementFire = Data[10]; ElementEarth = Data[11]; ElementWind = Data[12]; ElementWater = Data[13]; ElementLight = Data[14]; ElementDarkness = Data[15]; // for some reason the data order different between versions? if (Size == 876) { LearnRequirementsOtherArtesType = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesType.Length; ++i) { LearnRequirementsOtherArtesType[i] = Data[128 + 22 + i]; } LearnRequirementsOtherArtesId = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesId.Length; ++i) { LearnRequirementsOtherArtesId[i] = Data[128 + 28 + i]; } LearnRequirementsOtherArtesUsageCount = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesUsageCount.Length; ++i) { LearnRequirementsOtherArtesUsageCount[i] = Data[128 + 34 + i]; } AlteredArteRequirementType = new uint[5]; for (int i = 0; i < AlteredArteRequirementType.Length; ++i) { AlteredArteRequirementType[i] = Data[127 + 69 + i]; } AlteredArteRequirementId = new uint[5]; for (int i = 0; i < AlteredArteRequirementId.Length; ++i) { AlteredArteRequirementId[i] = Data[127 + 74 + i]; } //CharacterRelatedField = Data[?]; Character = Data[21]; FatalStrikeType = Data[210]; UsableInMenu = Data[128 + 44]; } else { LearnRequirementsOtherArtesType = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesType.Length; ++i) { LearnRequirementsOtherArtesType[i] = Data[22 + i]; } LearnRequirementsOtherArtesId = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesId.Length; ++i) { LearnRequirementsOtherArtesId[i] = Data[28 + i]; } LearnRequirementsOtherArtesUsageCount = new uint[6]; for (int i = 0; i < LearnRequirementsOtherArtesUsageCount.Length; ++i) { LearnRequirementsOtherArtesUsageCount[i] = Data[34 + i]; } AlteredArteRequirementType = new uint[5]; for (int i = 0; i < AlteredArteRequirementType.Length; ++i) { AlteredArteRequirementType[i] = Data[69 + i]; } AlteredArteRequirementId = new uint[5]; for (int i = 0; i < AlteredArteRequirementId.Length; ++i) { AlteredArteRequirementId[i] = Data[74 + i]; } CharacterRelatedField = Data[95]; Character = Data[96]; FatalStrikeType = Data[83]; UsableInMenu = Data[44]; } // always identical: 16, 17 // 59 is some sort of status effect field }