Beispiel #1
0
        private int ParseSection3(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                int _pos        = tnl_File.Objects.Count;
                int addedOffset = 0;
                tnl_File.Objects.Add(new TNL_Object());

                tnl_File.Objects[_pos].Index = BitConverter.ToInt32(rawBytes, currentOffset).ToString();
                addedOffset += 8;

                tnl_File.Objects[_pos].Str1 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);

                tnl_File.Objects[_pos].I32_2 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                addedOffset += 8;

                tnl_File.Objects[_pos].Str2 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4) + 4;

                tnl_File.Objects[_pos].Str3 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4) + 4;

                tnl_File.Objects[_pos].Str4 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);

                tnl_File.Objects[_pos].I32_3 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                tnl_File.Objects[_pos].I32_4 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset + 4).ToString();
                tnl_File.Objects[_pos].I32_5 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset + 8).ToString();
                currentOffset += addedOffset + 12;
            }
            return(currentOffset);
        }
Beispiel #2
0
        private int ParseSection4(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                int _pos        = tnl_File.Actions.Count();
                int addedOffset = 0;
                tnl_File.Actions.Add(new TNL_Action());

                tnl_File.Actions[_pos].Index = BitConverter.ToInt32(rawBytes, currentOffset).ToString();
                addedOffset += 8;

                tnl_File.Actions[_pos].Str1 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4) + 4;
                tnl_File.Actions[_pos].Str2 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4) + 4;
                tnl_File.Actions[_pos].Str3 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4) + 4;

                string args = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                tnl_File.Actions[_pos].Arguments = EventArguments.Read(args);
                addedOffset   += BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                currentOffset += addedOffset;
            }
            return(currentOffset);
        }
Beispiel #3
0
        public static AUR_File Load(byte[] bytes)
        {
            AUR_File aurFile = new AUR_File();

            //Header
            int auraCount      = BitConverter.ToInt32(bytes, 8);
            int auraOffset     = BitConverter.ToInt32(bytes, 12);
            int auraTypeCount  = BitConverter.ToInt32(bytes, 16);
            int auraTypeOffset = BitConverter.ToInt32(bytes, 20);
            int charaCount     = BitConverter.ToInt32(bytes, 24);
            int charaOffset    = BitConverter.ToInt32(bytes, 28);

            //AuraTypes
            for (int i = 0; i < auraTypeCount; i++)
            {
                aurFile.AuraTypes.Add(new AUR_Type()
                {
                    Type = StringEx.GetString(bytes, BitConverter.ToInt32(bytes, auraTypeOffset + (4 * i)), false)
                });
            }

            //Auras
            for (int i = 0; i < auraCount; i++)
            {
                AUR_Aura aura = new AUR_Aura();

                aura.Index = BitConverter.ToInt32(bytes, auraOffset + 0).ToString();
                aura.I_04  = BitConverter.ToInt32(bytes, auraOffset + 4);

                int effectCount  = BitConverter.ToInt32(bytes, auraOffset + 8);
                int effectOffset = BitConverter.ToInt32(bytes, auraOffset + 12);

                for (int a = 0; a < effectCount; a++)
                {
                    aura.AuraEffects.Add(new AUR_Effect()
                    {
                        Type = aurFile.GetAuraType(BitConverter.ToInt32(bytes, effectOffset)),
                        I_04 = BitConverter.ToInt32(bytes, effectOffset + 4)
                    });
                    effectOffset += 8;
                }

                auraOffset += 16;
                aurFile.Auras.Add(aura);
            }

            //Characters
            for (int i = 0; i < charaCount; i++)
            {
                aurFile.CharacterAuras.Add(new AUR_Character()
                {
                    Index = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 0).ToString(),
                    I_04  = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 4),
                    I_08  = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 8),
                    I_12  = Convert.ToBoolean(BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 12)),
                });
            }

            return(aurFile);
        }
Beispiel #4
0
        //Section Parsers


        private int ParseSection1(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                int _pos        = tnl_File.Characters.Count();
                int addedOffset = 0;
                tnl_File.Characters.Add(new TNL_Character());


                tnl_File.Characters[_pos].I32_1 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                addedOffset += 4;
                tnl_File.Characters[_pos].I8_1 = rawBytes[currentOffset + addedOffset];
                tnl_File.Characters[_pos].I8_2 = rawBytes[currentOffset + addedOffset + 1];
                tnl_File.Characters[_pos].I8_3 = rawBytes[currentOffset + addedOffset + 2];
                addedOffset += 7;
                tnl_File.Characters[_pos].Str1 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += tnl_File.Characters[_pos].Str1.Length;
                tnl_File.Characters[_pos].I16_1 = BitConverter.ToInt16(rawBytes, currentOffset + addedOffset);
                tnl_File.Characters[_pos].I16_2 = BitConverter.ToInt16(rawBytes, currentOffset + addedOffset + 2);
                addedOffset += 8;
                tnl_File.Characters[_pos].Str2 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += tnl_File.Characters[_pos].Str2.Length;
                tnl_File.Characters[_pos].I32_2 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                addedOffset += 8;
                tnl_File.Characters[_pos].Str3 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += tnl_File.Characters[_pos].Str3.Length + 4;
                tnl_File.Characters[_pos].Str4 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += tnl_File.Characters[_pos].Str4.Length;
                tnl_File.Characters[_pos].I32_3 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                currentOffset += addedOffset + 4;
            }
            return(currentOffset);
        }
Beispiel #5
0
        public static AMK_Animation Read(byte[] bytes, int index, int offset, int nameOffset)
        {
            int dataCount  = BitConverter.ToInt32(bytes, offset + 4);
            int dataOffset = BitConverter.ToInt32(bytes, offset + 12);

            if (dataOffset == 0)
            {
                return(null);
            }

            AMK_Animation anim = new AMK_Animation();

            anim.ID        = index;
            anim.Keyframes = new List <AMK_Keyframe>();
            anim.Name      = StringEx.GetString(bytes, nameOffset, false, StringEx.EncodingType.ASCII, 32, true);
            anim.I_00      = BitConverter.ToInt32(bytes, offset + 0);
            anim.I_08      = BitConverter.ToInt32(bytes, offset + 8);

            for (int i = 0; i < dataCount; i++)
            {
                anim.Keyframes.Add(AMK_Keyframe.Read(bytes, dataOffset + (4 * i)));
            }

            return(anim);
        }
Beispiel #6
0
 private int ParseSection5(int currentOffset)
 {
     while (EndOfSectionCheck(currentOffset) == false)
     {
         int _pos = tsd_File.Zones.Count();
         tsd_File.Zones.Add(new TSD_Zone());
         tsd_File.Zones[_pos].Index = BitConverter.ToInt32(rawBytes, currentOffset).ToString();
         tsd_File.Zones[_pos].I_04  = BitConverter.ToInt32(rawBytes, currentOffset + 4);
         tsd_File.Zones[_pos].Str   = StringEx.GetString(rawBytes, currentOffset + 12, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + 8), false);
         currentOffset += 12 + tsd_File.Zones[_pos].Str.Length;
     }
     return(currentOffset);
 }
Beispiel #7
0
        private int ParseSection2(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                int _pos        = tsd_File.Events.Count();
                int addedOffset = 0;

                tsd_File.Events.Add(new TSD_Event());

                tsd_File.Events[_pos].Index = BitConverter.ToInt32(rawBytes, currentOffset + 0).ToString();
                tsd_File.Events[_pos].I_04  = BitConverter.ToInt32(rawBytes, currentOffset + 4);
                addedOffset += 12;


                int stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);

                tsd_File.Events[_pos].Str1 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += stringSize + 4;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tsd_File.Events[_pos].Str2 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += stringSize + 4;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tsd_File.Events[_pos].Str3 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += stringSize + 4;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tsd_File.Events[_pos].Str4 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                addedOffset += stringSize + 4;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                string args = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);
                tsd_File.Events[_pos].Arguments = EventArguments.Read(args);
                addedOffset += stringSize + 4;

                //Read TNL ID array
                int        count  = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                List <int> tnlIds = BitConverter_Ex.ToInt32Array(rawBytes, currentOffset + addedOffset, count).ToList();
                addedOffset += (4 * count);
                tsd_File.Events[_pos].TNL_IDs = ArrayConvert.ConvertToStringList(tnlIds);

                currentOffset += addedOffset;
            }
            return(currentOffset);
        }
Beispiel #8
0
        private int ParseSection2(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                int _pos        = tnl_File.Teachers.Count();
                int addedOffset = 0;
                tnl_File.Teachers.Add(new TNL_Teacher());


                tnl_File.Teachers[_pos].I32_1 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                addedOffset += 4;
                tnl_File.Teachers[_pos].I8_1 = rawBytes[currentOffset + addedOffset];
                tnl_File.Teachers[_pos].I8_2 = rawBytes[currentOffset + addedOffset + 1];
                tnl_File.Teachers[_pos].I8_3 = rawBytes[currentOffset + addedOffset + 2];
                addedOffset += 7;

                int stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tnl_File.Teachers[_pos].Str1 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, stringSize, false);
                addedOffset += stringSize;

                tnl_File.Teachers[_pos].I16_1 = BitConverter.ToInt16(rawBytes, currentOffset + addedOffset);
                tnl_File.Teachers[_pos].I16_2 = BitConverter.ToInt16(rawBytes, currentOffset + addedOffset + 2);
                addedOffset += 8;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tnl_File.Teachers[_pos].Str2 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, stringSize, false);
                addedOffset += stringSize;
                tnl_File.Teachers[_pos].I32_2 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                addedOffset += 8;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tnl_File.Teachers[_pos].Str3 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, stringSize, false);
                addedOffset += stringSize + 4;

                stringSize = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4);
                tnl_File.Teachers[_pos].Str4 = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.UTF8, stringSize, false);
                addedOffset += stringSize;

                tnl_File.Teachers[_pos].I32_3 = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset).ToString();
                currentOffset += addedOffset + 4;
            }
            return(currentOffset);
        }
Beispiel #9
0
        //Section Parsers

        private int ParseSection1(int currentOffset)
        {
            while (EndOfSectionCheck(currentOffset) == false)
            {
                tsd_File.Triggers.Add(new TSD_Trigger()
                {
                    Index     = BitConverter.ToInt32(rawBytes, currentOffset + 0).ToString(),
                    I_04      = BitConverter.ToInt32(rawBytes, currentOffset + 4),
                    I_08      = BitConverter.ToInt32(rawBytes, currentOffset + 8),
                    I_12      = BitConverter.ToInt32(rawBytes, currentOffset + 12),
                    I_16      = BitConverter.ToInt32(rawBytes, currentOffset + 16).ToString(),
                    I_20      = BitConverter.ToInt32(rawBytes, currentOffset + 20),
                    I_24      = BitConverter.ToInt32(rawBytes, currentOffset + 24).ToString(),
                    I_28      = BitConverter.ToInt32(rawBytes, currentOffset + 28),
                    Condition = StringEx.GetString(rawBytes, currentOffset + 36, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + 32), false)
                });

                currentOffset += 36 + BitConverter.ToInt32(rawBytes, currentOffset + 32);
            }
            return(currentOffset);
        }
Beispiel #10
0
        private T ParseSec3Or4 <T>(int currentOffset, out int totalSize) where T : ISec_3_4, new()
        {
            totalSize = 0;
            int addedOffset = 4;
            T   _section    = new T();

            _section.Index = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset), false);

            addedOffset += _section.Index.Length;

            _section.Type = BitConverter.ToInt32(rawBytes, currentOffset + addedOffset);

            addedOffset += 8; //Unk_I and Flag Size

            _section.Str = StringEx.GetString(rawBytes, currentOffset + addedOffset, false, StringEx.EncodingType.ASCII, BitConverter.ToInt32(rawBytes, currentOffset + addedOffset - 4), false);

            addedOffset += _section.Str.Length;

            totalSize += addedOffset;

            return(_section);
        }
Beispiel #11
0
        private void ParseFile()
        {
            int count  = BitConverter.ToInt32(rawBytes, 8);
            int offset = BitConverter.ToInt32(rawBytes, 12);

            if (count > 0)
            {
                csoFile.CsoEntries = new List <CSO_Entry>();

                for (int i = 0; i < count; i++)
                {
                    csoFile.CsoEntries.Add(new CSO_Entry()
                    {
                        I_00   = BitConverter.ToUInt32(rawBytes, offset + 0).ToString(),
                        I_04   = BitConverter.ToUInt32(rawBytes, offset + 4),
                        Str_08 = StringEx.GetString(bytes, BitConverter.ToInt32(rawBytes, offset + 8), false),
                        Str_12 = StringEx.GetString(bytes, BitConverter.ToInt32(rawBytes, offset + 12), false),
                        Str_16 = StringEx.GetString(bytes, BitConverter.ToInt32(rawBytes, offset + 16), false),
                        Str_20 = StringEx.GetString(bytes, BitConverter.ToInt32(rawBytes, offset + 20), false)
                    });
                    offset += 32;
                }
            }
        }
Beispiel #12
0
        public static TNN_File Parse(byte[] bytes)
        {
            TNN_File tnn = new TNN_File();

            int numEntries = BitConverter.ToInt32(bytes, 0);
            int offset     = 4;
            int totalSub   = 0;

            for (int i = 0; i < numEntries; i++)
            {
                TNN_Entry entry = new TNN_Entry();

                entry.I_00 = BitConverter.ToInt32(bytes, offset + 0);
                entry.I_04 = BitConverter.ToInt32(bytes, offset + 4);
                int numSubEntires = BitConverter.ToInt32(bytes, offset + 8);

                offset += 12;

                for (int a = 0; a < numSubEntires; a++)
                {
                    TNN_SubEntry subEntry = new TNN_SubEntry();

                    subEntry.I_00 = BitConverter.ToInt32(bytes, offset + 0);
                    subEntry.I_04 = BitConverter.ToInt32(bytes, offset + 4);
                    subEntry.I_08 = BitConverter.ToInt32(bytes, offset + 8);

                    entry.SubEntries.Add(subEntry);

                    offset += 12;
                    totalSub++;
                }

                tnn.Entries.Add(entry);
            }

            //strings
            List <string> strings = new List <string>();

            while (offset < bytes.Length)
            {
                string str = StringEx.GetString(bytes, offset, false, StringEx.EncodingType.Unicode);

                int estSize = str.Length * 2;

                try
                {
                    while (bytes[estSize + offset] == 0)
                    {
                        estSize++;
                    }
                }
                catch (IndexOutOfRangeException ex)
                {
                }

                offset += estSize;
                strings.Add(str);
            }

            tnn.Strings = strings;
            //Check
            //if (strings.Count != (totalSub * 7) + numEntries)
            //    throw new Exception("nope");

            return(tnn);
        }
Beispiel #13
0
        void ParseCharacters()
        {
            int offset = chara1Offset;

            for (int i = 0; i < chara1Count; i++)
            {
                qxd_File.Characters1.Add(new Quest_Characters()
                {
                    Index          = BitConverter.ToInt32(rawBytes, offset).ToString(),
                    CharaShortName = StringEx.GetString(bytes, offset + 4, false, StringEx.EncodingType.ASCII, 3),
                    I_08           = BitConverter.ToInt32(rawBytes, offset + 8),
                    I_12           = BitConverter.ToInt32(rawBytes, offset + 12),
                    I_16           = BitConverter.ToInt32(rawBytes, offset + 16),
                    F_20           = BitConverter.ToSingle(rawBytes, offset + 20),
                    F_24           = BitConverter.ToSingle(rawBytes, offset + 24),
                    F_28           = BitConverter.ToSingle(rawBytes, offset + 28),
                    F_32           = BitConverter.ToSingle(rawBytes, offset + 32),
                    F_36           = BitConverter.ToSingle(rawBytes, offset + 36),
                    F_40           = BitConverter.ToSingle(rawBytes, offset + 40),
                    F_44           = BitConverter.ToSingle(rawBytes, offset + 44),
                    F_48           = BitConverter.ToSingle(rawBytes, offset + 48),
                    F_52           = BitConverter.ToSingle(rawBytes, offset + 52),
                    F_56           = BitConverter.ToSingle(rawBytes, offset + 56),
                    F_60           = BitConverter.ToSingle(rawBytes, offset + 60),
                    F_64           = BitConverter.ToSingle(rawBytes, offset + 64),
                    F_68           = BitConverter.ToSingle(rawBytes, offset + 68),
                    F_72           = BitConverter.ToSingle(rawBytes, offset + 72),
                    F_76           = BitConverter.ToSingle(rawBytes, offset + 76),
                    F_80           = BitConverter.ToSingle(rawBytes, offset + 80),
                    I_84           = BitConverter.ToInt32(rawBytes, offset + 84).ToString(),
                    _Skills        = new Skills
                    {
                        I_00 = BitConverter.ToUInt16(rawBytes, offset + 88).ToString(),
                        I_02 = BitConverter.ToUInt16(rawBytes, offset + 90).ToString(),
                        I_04 = BitConverter.ToUInt16(rawBytes, offset + 92).ToString(),
                        I_06 = BitConverter.ToUInt16(rawBytes, offset + 94).ToString(),
                        I_08 = BitConverter.ToUInt16(rawBytes, offset + 96).ToString(),
                        I_10 = BitConverter.ToUInt16(rawBytes, offset + 98).ToString(),
                        I_12 = BitConverter.ToUInt16(rawBytes, offset + 100).ToString(),
                        I_14 = BitConverter.ToUInt16(rawBytes, offset + 102).ToString(),
                        I_16 = BitConverter.ToUInt16(rawBytes, offset + 104).ToString(),
                    },
                    I_106 = BitConverter_Ex.ToInt16Array(rawBytes, offset + 106, 7),
                    I_120 = BitConverter.ToInt16(rawBytes, offset + 120),
                    I_122 = BitConverter.ToUInt16(rawBytes, offset + 122).ToString()
                });
                offset += 124;
            }

            offset = chara2Offset;

            for (int i = 0; i < chara2Count; i++)
            {
                qxd_File.Characters2.Add(new Quest_Characters()
                {
                    Index          = BitConverter.ToInt32(rawBytes, offset).ToString(),
                    CharaShortName = StringEx.GetString(bytes, offset + 4, false, StringEx.EncodingType.ASCII),
                    I_08           = BitConverter.ToInt32(rawBytes, offset + 8),
                    I_12           = BitConverter.ToInt32(rawBytes, offset + 12),
                    I_16           = BitConverter.ToInt32(rawBytes, offset + 16),
                    F_20           = BitConverter.ToSingle(rawBytes, offset + 20),
                    F_24           = BitConverter.ToSingle(rawBytes, offset + 24),
                    F_28           = BitConverter.ToSingle(rawBytes, offset + 28),
                    F_32           = BitConverter.ToSingle(rawBytes, offset + 32),
                    F_36           = BitConverter.ToSingle(rawBytes, offset + 36),
                    F_40           = BitConverter.ToSingle(rawBytes, offset + 40),
                    F_44           = BitConverter.ToSingle(rawBytes, offset + 44),
                    F_48           = BitConverter.ToSingle(rawBytes, offset + 48),
                    F_52           = BitConverter.ToSingle(rawBytes, offset + 52),
                    F_56           = BitConverter.ToSingle(rawBytes, offset + 56),
                    F_60           = BitConverter.ToSingle(rawBytes, offset + 60),
                    F_64           = BitConverter.ToSingle(rawBytes, offset + 64),
                    F_68           = BitConverter.ToSingle(rawBytes, offset + 68),
                    F_72           = BitConverter.ToSingle(rawBytes, offset + 72),
                    F_76           = BitConverter.ToSingle(rawBytes, offset + 76),
                    F_80           = BitConverter.ToSingle(rawBytes, offset + 80),
                    I_84           = BitConverter.ToInt32(rawBytes, offset + 84).ToString(),
                    _Skills        = new Skills
                    {
                        I_00 = BitConverter.ToUInt16(rawBytes, offset + 88).ToString(),
                        I_02 = BitConverter.ToUInt16(rawBytes, offset + 90).ToString(),
                        I_04 = BitConverter.ToUInt16(rawBytes, offset + 92).ToString(),
                        I_06 = BitConverter.ToUInt16(rawBytes, offset + 94).ToString(),
                        I_08 = BitConverter.ToUInt16(rawBytes, offset + 96).ToString(),
                        I_10 = BitConverter.ToUInt16(rawBytes, offset + 98).ToString(),
                        I_12 = BitConverter.ToUInt16(rawBytes, offset + 100).ToString(),
                        I_14 = BitConverter.ToUInt16(rawBytes, offset + 102).ToString(),
                        I_16 = BitConverter.ToUInt16(rawBytes, offset + 104).ToString(),
                    },
                    I_106 = BitConverter_Ex.ToInt16Array(rawBytes, offset + 106, 7),
                    I_120 = BitConverter.ToInt16(rawBytes, offset + 120),
                    I_122 = BitConverter.ToUInt16(rawBytes, offset + 122).ToString()
                });
                offset += 124;
            }
        }
Beispiel #14
0
        void ParseQuestData()
        {
            int offset = questsOffset;

            for (int i = 0; i < questsCount; i++)
            {
                //counts & offsets
                int msgEntryCount       = BitConverter.ToInt32(rawBytes, offset + 32);
                int equipRewardCount    = BitConverter.ToInt32(rawBytes, offset + 160);
                int skillRewardCount    = BitConverter.ToInt32(rawBytes, offset + 168);
                int unk1count           = BitConverter.ToInt32(rawBytes, offset + 88);
                int unk2Count           = BitConverter.ToInt32(rawBytes, offset + 96);
                int charaUnlockCount    = BitConverter.ToInt32(rawBytes, offset + 176);
                int stagePortraitCount  = BitConverter.ToInt32(rawBytes, offset + 184);
                int qedFileCount        = BitConverter.ToInt32(rawBytes, offset + 112);
                int msgEntryOffset      = BitConverter.ToInt32(rawBytes, offset + 36);
                int equipRewardOffset   = BitConverter.ToInt32(rawBytes, offset + 164);
                int skillRewardOffset   = BitConverter.ToInt32(rawBytes, offset + 172);
                int unk1Offset          = BitConverter.ToInt32(rawBytes, offset + 92);
                int unk2Offset          = BitConverter.ToInt32(rawBytes, offset + 100);
                int charaUnlockOffset   = BitConverter.ToInt32(rawBytes, offset + 180);
                int stagePortraitOffset = BitConverter.ToInt32(rawBytes, offset + 188);
                int qedFileOffset       = BitConverter.ToInt32(rawBytes, offset + 116);

                qxd_File.Quests.Add(new Quest_Data());
                qxd_File.Quests[i].Name = StringEx.GetString(bytes, offset, false, StringEx.EncodingType.ASCII, 16);

                qxd_File.Quests[i].Index = BitConverter.ToInt32(rawBytes, offset + 16).ToString();
                qxd_File.Quests[i].I_20  = BitConverter.ToInt32(rawBytes, offset + 20);
                qxd_File.Quests[i].I_24  = BitConverter.ToInt32(rawBytes, offset + 24);
                qxd_File.Quests[i].I_28  = BitConverter.ToInt32(rawBytes, offset + 28);
                qxd_File.Quests[i].I_40  = BitConverter.ToInt16(rawBytes, offset + 40);
                qxd_File.Quests[i].I_42  = BitConverter.ToInt16(rawBytes, offset + 42);
                qxd_File.Quests[i].I_44  = BitConverter.ToInt16(rawBytes, offset + 44);
                qxd_File.Quests[i].I_46  = BitConverter.ToInt16(rawBytes, offset + 46);
                qxd_File.Quests[i].I_64  = BitConverter.ToInt32(rawBytes, offset + 64);
                qxd_File.Quests[i].I_104 = BitConverter.ToInt16(rawBytes, offset + 104);
                qxd_File.Quests[i].I_106 = BitConverter.ToInt16(rawBytes, offset + 106);
                qxd_File.Quests[i].I_108 = BitConverter.ToInt16(rawBytes, offset + 108);
                qxd_File.Quests[i].I_110 = BitConverter.ToInt16(rawBytes, offset + 110);
                qxd_File.Quests[i].I_120 = BitConverter.ToInt32(rawBytes, offset + 120);
                qxd_File.Quests[i].I_124 = BitConverter.ToInt32(rawBytes, offset + 124);
                qxd_File.Quests[i].I_128 = BitConverter.ToInt32(rawBytes, offset + 128);
                qxd_File.Quests[i].I_132 = BitConverter.ToInt32(rawBytes, offset + 132);
                qxd_File.Quests[i].I_136 = BitConverter.ToInt32(rawBytes, offset + 136);
                qxd_File.Quests[i].I_140 = BitConverter.ToInt32(rawBytes, offset + 140);
                qxd_File.Quests[i].I_144 = BitConverter.ToInt32(rawBytes, offset + 144);
                qxd_File.Quests[i].I_148 = BitConverter.ToInt32(rawBytes, offset + 148);
                qxd_File.Quests[i].I_152 = BitConverter.ToInt32(rawBytes, offset + 152);
                qxd_File.Quests[i].I_156 = BitConverter.ToInt32(rawBytes, offset + 156);
                qxd_File.Quests[i].I_192 = BitConverter.ToInt32(rawBytes, offset + 192);
                qxd_File.Quests[i].I_248 = BitConverter.ToInt32(rawBytes, offset + 248);
                qxd_File.Quests[i].I_252 = BitConverter.ToInt32(rawBytes, offset + 252);
                qxd_File.Quests[i].I_256 = (QxdUpdate)BitConverter.ToInt32(rawBytes, offset + 256);
                qxd_File.Quests[i].I_260 = (QxdDlc)BitConverter.ToInt32(rawBytes, offset + 260);
                qxd_File.Quests[i].I_264 = BitConverter.ToInt32(rawBytes, offset + 264);
                qxd_File.Quests[i].I_268 = BitConverter.ToInt16(rawBytes, offset + 268);
                qxd_File.Quests[i].I_270 = BitConverter.ToInt16(rawBytes, offset + 270);
                qxd_File.Quests[i].I_272 = BitConverter.ToInt16(rawBytes, offset + 272);
                qxd_File.Quests[i].I_274 = BitConverter.ToInt16(rawBytes, offset + 274);
                qxd_File.Quests[i].F_276 = BitConverter.ToSingle(rawBytes, offset + 276);
                qxd_File.Quests[i].I_280 = BitConverter.ToInt32(rawBytes, offset + 280);


                qxd_File.Quests[i].I_48 = BitConverter_Ex.ToInt32Array(rawBytes, offset + 48, 4);
                qxd_File.Quests[i].I_68 = BitConverter_Ex.ToInt32Array(rawBytes, offset + 68, 5);

                qxd_File.Quests[i].I_232 = BitConverter_Ex.ToInt16Array(rawBytes, offset + 232, 8);

                if (unk1count > 0)
                {
                    int tempOffset = unk1Offset;
                    qxd_File.Quests[i].UnknownNum1 = new List <UnkNum1>();
                    for (int a = 0; a < unk1count; a++)
                    {
                        qxd_File.Quests[i].UnknownNum1.Add(new UnkNum1()
                        {
                            I_00 = BitConverter_Ex.ToInt16Array(rawBytes, tempOffset, 16)
                        });

                        tempOffset += 32;
                    }
                }
                if (unk2Count > 0)
                {
                    int tempOffset = unk2Offset;
                    qxd_File.Quests[i].UnknownNum2 = new List <UnkNum2>();
                    for (int a = 0; a < unk2Count; a++)
                    {
                        qxd_File.Quests[i].UnknownNum2.Add(new UnkNum2()
                        {
                            I_00 = BitConverter_Ex.ToInt16Array(rawBytes, tempOffset, 16)
                        });

                        tempOffset += 32;
                    }
                }

                if (equipRewardCount > 0)
                {
                    qxd_File.Quests[i].EquipReward = new List <EquipmentReward>();
                    int equipOffset = equipRewardOffset;
                    for (int b = 0; b < equipRewardCount; b++)
                    {
                        qxd_File.Quests[i].EquipReward.Add(new EquipmentReward()
                        {
                            I_00 = (QxdItemType)BitConverter.ToInt32(rawBytes, equipOffset),
                            I_04 = BitConverter.ToInt32(rawBytes, equipOffset + 4),
                            I_08 = BitConverter.ToInt32(rawBytes, equipOffset + 8),
                            I_12 = BitConverter.ToInt32(rawBytes, equipOffset + 12),
                            I_16 = BitConverter.ToInt32(rawBytes, equipOffset + 16),
                            I_20 = BitConverter.ToInt16(rawBytes, equipOffset + 20),
                            F_24 = BitConverter.ToSingle(rawBytes, equipOffset + 24),
                            I_28 = BitConverter.ToInt32(rawBytes, equipOffset + 28)
                        });

                        equipOffset += 32;
                    }
                }

                if (skillRewardCount > 0)
                {
                    qxd_File.Quests[i].Skill_Reward = new List <SkillReward>();
                    int skillOffset = skillRewardOffset;
                    for (int b = 0; b < skillRewardCount; b++)
                    {
                        qxd_File.Quests[i].Skill_Reward.Add(new SkillReward()
                        {
                            I_00 = (QxdSkillType)BitConverter.ToInt32(rawBytes, skillOffset + 0),
                            I_04 = BitConverter.ToInt32(rawBytes, skillOffset + 4),
                            I_08 = BitConverter.ToInt32(rawBytes, skillOffset + 8),
                            I_12 = BitConverter.ToInt32(rawBytes, skillOffset + 12),
                            F_16 = BitConverter.ToSingle(rawBytes, skillOffset + 16)
                        });
                        skillOffset += 20;
                    }
                }



                if (charaUnlockCount > 0)
                {
                    qxd_File.Quests[i].Chara_Unlock = new List <CharaUnlock>();
                    int charaOffset = charaUnlockOffset;
                    for (int b = 0; b < charaUnlockCount; b++)
                    {
                        qxd_File.Quests[i].Chara_Unlock.Add(new CharaUnlock()
                        {
                            ShortName    = StringEx.GetString(bytes, charaOffset, false, StringEx.EncodingType.ASCII, 3),
                            CostumeIndex = BitConverter.ToInt16(rawBytes, charaOffset + 4),
                            I_06         = BitConverter.ToInt16(rawBytes, charaOffset + 6)
                        });
                        charaOffset += 8;
                    }
                }

                int portraitOffset = 196;
                qxd_File.Quests[i].EnemyPortraitDisplay = new List <EnemyPortrait>();
                for (int b = 0; b < 6; b++)
                {
                    qxd_File.Quests[i].EnemyPortraitDisplay.Add(new EnemyPortrait());
                    qxd_File.Quests[i].EnemyPortraitDisplay[b].CharaID      = BitConverter.ToInt16(rawBytes, offset + portraitOffset);
                    qxd_File.Quests[i].EnemyPortraitDisplay[b].CostumeIndex = BitConverter.ToInt16(rawBytes, offset + portraitOffset + 2);
                    qxd_File.Quests[i].EnemyPortraitDisplay[b].State        = BitConverter.ToInt16(rawBytes, offset + portraitOffset + 4);
                    portraitOffset += 6;
                }

                if (stagePortraitCount > 0)
                {
                    qxd_File.Quests[i].StageDisplay = new List <short>();
                    for (int j = 0; j < 32; j += 2)
                    {
                        qxd_File.Quests[i].StageDisplay.Add(BitConverter.ToInt16(rawBytes, stagePortraitOffset + j));
                    }
                }

                if (msgEntryCount > 0)
                {
                    qxd_File.Quests[i].MsgFiles = new List <string>();
                    int msgOffset = msgEntryOffset;
                    for (int j = 0; j < msgEntryCount; j++)
                    {
                        qxd_File.Quests[i].MsgFiles.Add(StringEx.GetString(bytes, msgOffset, false, StringEx.EncodingType.ASCII, 32));
                        msgOffset += 32;
                    }
                }

                if (qedFileCount > 0)
                {
                    qxd_File.Quests[i].QedFiles = new List <string>();
                    int qedOffset = qedFileOffset;
                    for (int j = 0; j < qedFileCount; j++)
                    {
                        qxd_File.Quests[i].QedFiles.Add(StringEx.GetString(bytes, qedOffset, false, StringEx.EncodingType.ASCII, 32));
                        qedOffset += 32;
                    }
                }
                offset += 284;
            }
        }
Beispiel #15
0
        public static TTC_File Parse(byte[] bytes)
        {
            if (BitConverter.ToUInt32(bytes, 0) != TTC_SIGNATURE)
            {
                throw new InvalidDataException("TTC signature not found!");
            }
            TTC_File ttc = new TTC_File();

            int count  = BitConverter.ToInt32(bytes, 8);
            int offset = BitConverter.ToInt32(bytes, 12) + 16;

            //Parse ttc entries
            for (int i = 0; i < count; i++)
            {
                TTC_Entry entry = new TTC_Entry();
                entry.CmsID = BitConverter.ToInt32(bytes, offset + (16 * i) + 12);

                int numLists   = BitConverter.ToInt32(bytes, offset + (16 * i) + 0);
                int dataStart  = BitConverter.ToInt32(bytes, offset + (16 * i) + 4) + offset;
                int startIndex = BitConverter.ToInt32(bytes, offset + (16 * i) + 8);

                for (int a = 0; a < numLists; a++)
                {
                    TTC_EventList eventList = new TTC_EventList();
                    eventList.Type = (TtcEventListType)BitConverter.ToInt32(bytes, dataStart + (16 * (startIndex + a)) + 12);

                    int numEvents       = BitConverter.ToInt32(bytes, dataStart + (16 * (startIndex + a)) + 0);
                    int eventDataStart  = BitConverter.ToInt32(bytes, dataStart + (16 * (startIndex + a)) + 4) + offset;
                    int eventStartIndex = BitConverter.ToInt32(bytes, dataStart + (16 * (startIndex + a)) + 8);

                    for (int b = 0; b < numEvents; b++)
                    {
                        TTC_Event _event = new TTC_Event();


                        _event.Costume        = BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 4);
                        _event.Transformation = BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 8);
                        _event.Condition      = (TtcEventCondition)BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 16);

                        int nameIdx = BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 20);

                        if (nameIdx != -1 && nameIdx < offset)
                        {
                            _event.Name = StringEx.GetString(bytes, nameIdx + 16, false);
                        }

                        //validation
                        if (BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 0) != entry.CmsID)
                        {
                            throw new InvalidDataException("Warning: CMS ID mismatch!");
                        }

                        if (BitConverter.ToInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 12) != (int)eventList.Type)
                        {
                            throw new InvalidDataException("Warning: EventList Type mismatch!");
                        }

                        if (BitConverter.ToUInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 24) != 0xFFFFFFFF)
                        {
                            throw new InvalidDataException("Warning: unk_24 is not 0xFFFFFFFF!");
                        }

                        if (BitConverter.ToUInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 28) != 0xFFFFFFFF)
                        {
                            throw new InvalidDataException("Warning: unk_28 is not 0xFFFFFFFF!");
                        }

                        if (BitConverter.ToUInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 32) != 0xFFFFFFFF)
                        {
                            throw new InvalidDataException("Warning: unk_32 is not 0xFFFFFFFF!");
                        }

                        if (BitConverter.ToUInt32(bytes, eventDataStart + (40 * (eventStartIndex + b)) + 36) != 0xFFFFFFFF)
                        {
                            throw new InvalidDataException("Warning: unk_36 is not 0xFFFFFFFF!");
                        }

                        eventList.Events.Add(_event);
                    }

                    entry.EventLists.Add(eventList);
                }

                ttc.Entries.Add(entry);
            }

            return(ttc);
        }
Beispiel #16
0
        public static TTB_File Parse(byte[] bytes)
        {
            if (BitConverter.ToUInt32(bytes, 0) != TTB_SIGNATURE)
            {
                throw new InvalidDataException("TTB signature not found!");
            }

            TTB_File ttb = new TTB_File();

            //Headers
            int stringSize = BitConverter.ToInt32(bytes, 12);
            int numEntries = BitConverter.ToInt32(bytes, stringSize + 16);
            int dataStart  = BitConverter.ToInt32(bytes, stringSize + 20) + stringSize + 16; //Relative

            //Data
            for (int i = 0; i < numEntries; i++)
            {
                TTB_Entry entry = new TTB_Entry();
                entry.CmsID = BitConverter.ToInt32(bytes, dataStart + (16 * i) + 12);

                int numEvents      = BitConverter.ToInt32(bytes, dataStart + (16 * i));
                int eventDataStart = BitConverter.ToInt32(bytes, dataStart + (16 * i) + 4) + stringSize + 16; //Relative to header 2 (after strings)
                int startIndex     = BitConverter.ToInt32(bytes, dataStart + (16 * i) + 8);
                eventDataStart += 116 * startIndex;

                for (int a = 0; a < numEvents; a++)
                {
                    TTB_Event _event = new TTB_Event();

                    _event.Index           = BitConverter.ToInt32(bytes, eventDataStart + 0).ToString();
                    _event.Cms_Id1         = BitConverter.ToInt32(bytes, eventDataStart + 4);
                    _event.Costume         = BitConverter.ToInt32(bytes, eventDataStart + 8);
                    _event.Transformation  = BitConverter.ToInt32(bytes, eventDataStart + 12);
                    _event.Cms_Id2         = BitConverter.ToInt32(bytes, eventDataStart + 16);
                    _event.Costume2        = BitConverter.ToInt32(bytes, eventDataStart + 20);
                    _event.Transformation2 = BitConverter.ToInt32(bytes, eventDataStart + 24);
                    _event.Cms_Id3         = BitConverter.ToInt32(bytes, eventDataStart + 28);
                    _event.Costume3        = BitConverter.ToInt32(bytes, eventDataStart + 32);
                    _event.Transformation3 = BitConverter.ToInt32(bytes, eventDataStart + 36);
                    _event.Cms_Id4         = BitConverter.ToInt32(bytes, eventDataStart + 40);
                    _event.Costume4        = BitConverter.ToInt32(bytes, eventDataStart + 44);
                    _event.Transformation4 = BitConverter.ToInt32(bytes, eventDataStart + 48);
                    _event.Cms_Id5         = BitConverter.ToInt32(bytes, eventDataStart + 52);
                    _event.Costume5        = BitConverter.ToInt32(bytes, eventDataStart + 56);
                    _event.Transformation5 = BitConverter.ToInt32(bytes, eventDataStart + 60);
                    _event.Type            = (EventType)BitConverter.ToInt32(bytes, eventDataStart + 64);
                    _event.I_68            = BitConverter.ToUInt32(bytes, eventDataStart + 68);
                    _event.I_72            = BitConverter.ToUInt32(bytes, eventDataStart + 72);

                    _event.Order1 = BitConverter.ToInt32(bytes, eventDataStart + 76);
                    _event.Order2 = BitConverter.ToInt32(bytes, eventDataStart + 84);
                    _event.Order3 = BitConverter.ToInt32(bytes, eventDataStart + 92);
                    _event.Order4 = BitConverter.ToInt32(bytes, eventDataStart + 100);
                    _event.Order5 = BitConverter.ToInt32(bytes, eventDataStart + 108);

                    //Names
                    int name1 = BitConverter.ToInt32(bytes, eventDataStart + 80);
                    int name2 = BitConverter.ToInt32(bytes, eventDataStart + 88);
                    int name3 = BitConverter.ToInt32(bytes, eventDataStart + 96);
                    int name4 = BitConverter.ToInt32(bytes, eventDataStart + 104);
                    int name5 = BitConverter.ToInt32(bytes, eventDataStart + 112);

                    if (name1 != -1 && name1 < stringSize)
                    {
                        _event.Voice1 = StringEx.GetString(bytes, name1 + 16, false);
                    }

                    if (name2 != -1 && name2 < stringSize)
                    {
                        _event.Voice2 = StringEx.GetString(bytes, name2 + 16, false);
                    }

                    if (name3 != -1 && name3 < stringSize)
                    {
                        _event.Voice3 = StringEx.GetString(bytes, name3 + 16, false);
                    }

                    if (name4 != -1 && name4 < stringSize)
                    {
                        _event.Voice4 = StringEx.GetString(bytes, name4 + 16, false);
                    }

                    if (name5 != -1 && name5 < stringSize)
                    {
                        _event.Voice5 = StringEx.GetString(bytes, name5 + 16, false);
                    }

                    entry.SubEntries.Add(_event);
                    eventDataStart += 116;
                }

                ttb.Entries.Add(entry);
            }

            return(ttb);
        }