Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        private static List <ScenarioFileEntry> FindText(Stream stream, uint textStart, bool isUtf8)
        {
            var list = new List <ScenarioFileEntry>();

            while (stream.Position < textStart)
            {
                uint identifyingBytes = stream.ReadUInt32();
                if (identifyingBytes == 0x18000C04)
                {
                    uint pos = (uint)stream.Position;

                    uint pointerToText = stream.ReadUInt32().SwapEndian() + textStart;

                    stream.Position = pointerToText;
                    stream.ReadUInt32().SwapEndian();
                    stream.ReadUInt32().SwapEndian();
                    uint jpNamePtr = stream.ReadUInt32().SwapEndian();
                    uint jpTextPtr = stream.ReadUInt32().SwapEndian();
                    uint enNamePtr = stream.ReadUInt32().SwapEndian();
                    uint enTextPtr = stream.ReadUInt32().SwapEndian();
                    stream.Position = jpNamePtr + textStart; string jpName = isUtf8 ? stream.ReadUTF8Nullterm() : stream.ReadShiftJisNullterm();
                    stream.Position = jpTextPtr + textStart; string jpText = isUtf8 ? stream.ReadUTF8Nullterm() : stream.ReadShiftJisNullterm();
                    stream.Position = enNamePtr + textStart; string enName = isUtf8 ? stream.ReadUTF8Nullterm() : stream.ReadShiftJisNullterm();
                    stream.Position = enTextPtr + textStart; string enText = isUtf8 ? stream.ReadUTF8Nullterm() : stream.ReadShiftJisNullterm();

                    var entry = new ScenarioFileEntry()
                    {
                        Pointer = pos, JpName = jpName, EnName = enName, JpText = jpText, EnText = enText
                    };
                    list.Add(entry);

                    stream.Position = pos + 4;
                }
            }

            return(list);
        }