Example #1
0
        public override void Load(ref System.IO.FileStream File, ref System.IO.BinaryReader Reader)
        {
            File.Position = Offset + Base;
            if (File.Position < File.Length && Size > 0)
            {
                Header      = Reader.ReadUInt32();
                Records     = (int)Reader.ReadUInt32();
                ContentSize = Reader.ReadUInt32();
                Array.Resize(ref _Item, Records);
                for (int i = 0; i <= Records - 1; i++)
                {
                    uint ElementOffset = Reader.ReadUInt32();
                    uint ElementSize   = Reader.ReadUInt32();
                    uint ElementID     = Reader.ReadUInt32();
                    uint Pos           = (uint)File.Position;
                    switch (ElementID)
                    {
                    case 0:
                    {
                        GameObjects GObjs = new GameObjects();
                        GObjs.Offset = ElementOffset;
                        GObjs.Base   = Offset + Base;
                        GObjs.Size   = ElementSize;
                        GObjs.ID     = ElementID;
                        GObjs.Load(ref File, ref Reader);
                        _Item[i] = GObjs;
                        break;
                    }

                    case 1:
                    {
                        Scripts Srpts = new Scripts();
                        Srpts.Offset = ElementOffset;
                        Srpts.Base   = Offset + Base;
                        Srpts.Size   = ElementSize;
                        Srpts.ID     = ElementID;
                        Srpts.Load(ref File, ref Reader);
                        _Item[i] = Srpts;
                        break;
                    }

                    case 2:
                    {
                        Animations Anims = new Animations();
                        Anims.Offset = ElementOffset;
                        Anims.Base   = Offset + Base;
                        Anims.Size   = ElementSize;
                        Anims.ID     = ElementID;
                        Anims.Load(ref File, ref Reader);
                        _Item[i] = Anims;
                        break;
                    }

                    case 3:
                    {
                        OGIs OGInfos = new OGIs();
                        OGInfos.Offset = ElementOffset;
                        OGInfos.Base   = Offset + Base;
                        OGInfos.Size   = ElementSize;
                        OGInfos.ID     = ElementID;
                        OGInfos.Load(ref File, ref Reader);
                        _Item[i] = OGInfos;
                        break;
                    }

                    case 4:
                    {
                        BaseSection BS = new BaseSection();
                        BS.Offset = ElementOffset;
                        BS.Base   = Offset + Base;
                        BS.Size   = ElementSize;
                        BS.ID     = ElementID;
                        BS.Load(ref File, ref Reader);
                        _Item[i] = BS;
                        break;
                    }

                    case 6:
                    {
                        Sound S = new Sound();
                        if (_Item[i - 1] is SoundDescriptions)
                        {
                            S.Shift = (_Item[i - 1].Records + 1) * 12;
                            for (int j = 0; j <= _Item[i - 1].Records - 1; j++)
                            {
                                S.Shift += (int)_Item[i - 1]._Item[j].Size;
                            }
                        }
                        else
                        {
                            S.Shift = 0;
                        }
                        S.Offset = ElementOffset;
                        S.Base   = Offset + Base;
                        S.Size   = ElementSize;
                        S.ID     = ElementID;
                        S.Load(ref File, ref Reader);
                        _Item[i] = S;
                        break;
                    }

                    case 5:
                    {
                        SoundDescriptions SDs = new SoundDescriptions();
                        SDs.Offset = ElementOffset;
                        SDs.Base   = Offset + Base;
                        SDs.Size   = ElementSize;
                        SDs.ID     = ElementID;
                        SDs.Load(ref File, ref Reader);
                        _Item[i] = SDs;
                        break;
                    }

                    default:
                    {
                        SoundbankDescriptions SDs = new SoundbankDescriptions();
                        SDs.Offset = ElementOffset;
                        SDs.Base   = Offset + Base;
                        SDs.Size   = ElementSize;
                        SDs.ID     = ElementID;
                        SDs.Load(ref File, ref Reader);
                        _Item[i] = SDs;
                        break;
                    }
                    }
                    File.Position = Pos;
                }
            }
        }
Example #2
0
        public override void Load(BinaryReader reader, int size)
        {
            scriptGameVersion = 2;

            var sk = reader.BaseStream.Position;

            UnkBitfield = reader.ReadUInt32();

            /*
             * for (int i = 0; i < 8; ++i)
             * {
             *  ScriptSlots[i] = reader.ReadByte();
             * }
             */

            var Count_OGI        = reader.ReadByte();
            var Count_Anim       = Count_OGI;
            var Count_Script     = reader.ReadByte();
            var Count_GameObject = reader.ReadByte();
            var Count_UnkI32     = reader.ReadByte();
            //reader.ReadUInt32();
            var Count_Sound = reader.ReadUInt32();

            //Class1 = reader.ReadUInt32();
            //Class2 = reader.ReadUInt32();
            //Class3 = reader.ReadUInt32();
            var len = reader.ReadInt32();

            Name = new string(reader.ReadChars(len));

            // Read UInt32 script slots
            UI32.Clear();
            for (int i = 0; i < Count_UnkI32; ++i)
            {
                UI32.Add(reader.ReadUInt32());
            }

            // Read OGI script slots
            OGIs.Clear();
            for (int i = 0; i < Count_OGI; ++i)
            {
                OGIs.Add(reader.ReadUInt16());
            }

            // Read Animation script slots
            Anims.Clear();
            for (int i = 0; i < Count_Anim; ++i)
            {
                Anims.Add(reader.ReadUInt16());
            }

            // Read Script script slots
            Scripts.Clear();
            for (int i = 0; i < Count_Script; ++i)
            {
                Scripts.Add(reader.ReadUInt16());
            }

            // Read Object script slots
            Objects.Clear();
            for (int i = 0; i < Count_GameObject; ++i)
            {
                Objects.Add(reader.ReadUInt16());
            }

            // Read Sound script slots
            Sounds.Clear();
            for (int i = 0; i < Count_Sound; ++i)
            {
                Sounds.Add(reader.ReadUInt16());
            }

            // Read instance properties
            if ((UnkBitfield & 0x20000000) != 0x0)
            {
                //PHeader = reader.ReadUInt32();
                //reader.BaseStream.Position -= 4;
                var Count_Flags  = reader.ReadByte();
                var Count_Floats = reader.ReadByte();
                var Count_Ints   = reader.ReadByte();
                reader.ReadByte();
                PUI32 = reader.ReadUInt32();

                instFlagsList.Clear();
                for (int i = 0; i < Count_Flags; ++i)
                {
                    instFlagsList.Add(reader.ReadUInt32());
                }

                instFloatsList.Clear();
                for (int i = 0; i < Count_Floats; ++i)
                {
                    instFloatsList.Add(reader.ReadSingle());
                }

                instIntegerList.Clear();
                for (int i = 0; i < Count_Ints; ++i)
                {
                    instIntegerList.Add(reader.ReadUInt32());
                }
            }
            else
            {
                //PHeader = 0;
                PUI32 = 0;
                instFlagsList.Clear();
                instFloatsList.Clear();
                instIntegerList.Clear();
            }

            // Read IDs needed for instance creation
            if ((UnkBitfield & 0x40000000) != 0x0)
            {
                flag = reader.ReadUInt32();
                if ((flag & 0x00000001) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cObjects.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cObjects.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000002) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cOGIs.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cOGIs.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000004) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cAnims.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cAnims.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000008) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cCM.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cCM.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000010) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cScripts.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cScripts.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000020) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cUnk.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cUnk.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000040) != 0)
                {
                    var cnt = reader.ReadInt32();
                    cSounds.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cSounds.Add(reader.ReadUInt16());
                    }
                }
            }

            scriptCommandsAmount = (int)reader.ReadUInt32();
            if (scriptCommandsAmount != 0)
            {
                scriptCommand = new Script.MainScript.ScriptCommand(reader, scriptGameVersion);
                var command = scriptCommand;
                do
                {
                    scriptCommands.Add(command);
                    command = command.nextCommand;
                } while (command != null);
            }
            else
            {
                scriptCommand = null;
            }
            this.size = size;
        }
Example #3
0
        /// <summary>
        /// Create new RM2 chunk
        /// </summary>
        public void NewRM2()
        {
            Array.Resize(ref Item, 12);
            Records         = 12;
            Item[0]         = new GraphicsSection();
            Item[0].ID      = 11;
            Item[0].Records = 9;
            Array.Resize(ref Item[0]._Item, 9);
            for (int i = 0; i <= 8; i++)
            {
                switch (i)
                {
                case 0:
                {
                    Item[0][i] = new Textures();
                    break;
                }

                case 1:
                {
                    Item[0][i] = new Materials();
                    break;
                }

                case 2:
                {
                    Item[0][i] = new Models();
                    break;
                }

                case 3:
                {
                    Item[0][i] = new GCs();
                    break;
                }

                case 4:
                {
                    Item[0][i] = new ID4Models();
                    break;
                }

                case 5:
                {
                    Item[0][i] = new BaseSection();
                    break;
                }

                case 6:
                {
                    Item[0][i] = new GCs();
                    break;
                }

                case 7:
                {
                    Item[0][i] = new BaseSection();
                    break;
                }

                case 8:
                {
                    Item[0][i] = new BaseSection();
                    break;
                }
                }
                Item[0][i].ID = (uint)i;
            }
            Array.Resize(ref Item, 12);
            Item[1]         = new CodeSection();
            Item[1].ID      = 10;
            Item[1].Records = 13;
            Array.Resize(ref Item[1]._Item, 13);
            for (int i = 0; i <= 12; i++)
            {
                switch (i)
                {
                case 0:
                {
                    Item[1][i] = new GameObjects();
                    break;
                }

                case 1:
                {
                    Item[1][i] = new Scripts();
                    break;
                }

                case 2:
                {
                    Item[1][i] = new Animations();
                    break;
                }

                case 3:
                {
                    Item[1][i] = new OGIs();
                    break;
                }

                case 4:
                {
                    Item[1][i] = new BaseSection();
                    break;
                }

                case 5:
                {
                    Item[1][i] = new SoundDescriptions();
                    break;
                }

                case 6:
                {
                    Item[1][i] = new Sound();
                    break;
                }

                case 7:
                case 8:
                case 9:
                case 10:
                case 11:
                case 12:
                {
                    Item[1][i] = new SoundbankDescriptions();
                    break;
                }
                }
                Item[1][i].ID = (uint)i;
            }
            Item[2]    = new BaseItem();
            Item[2].ID = 8;
            Item[3]    = new GeoData();
            Item[3].ID = 9;
            for (int j = 4; j <= 11; j++)
            {
                Item[j]         = new InstanceInfoSection();
                Item[j].ID      = (uint)j - 4;
                Item[j].Records = 9;
                Array.Resize(ref Item[j]._Item, 9);
                for (int i = 0; i <= 8; i++)
                {
                    switch (i)
                    {
                    case 0:
                    {
                        Item[j][i] = new BaseSection();
                        break;
                    }

                    case 1:
                    {
                        Item[j][i] = new Behaviors();
                        break;
                    }

                    case 2:
                    {
                        Item[j][i] = new FuckingShits();
                        break;
                    }

                    case 3:
                    {
                        Item[j][i] = new Positions();
                        break;
                    }

                    case 4:
                    {
                        Item[j][i] = new Paths();
                        break;
                    }

                    case 5:
                    {
                        Item[j][i] = new SurfaceBehaviours();
                        break;
                    }

                    case 6:
                    {
                        Item[j][i] = new Instances();
                        break;
                    }

                    case 7:
                    {
                        Item[j][i] = new Triggers();
                        break;
                    }

                    case 8:
                    {
                        Item[j][i] = new BaseSection();
                        break;
                    }
                    }
                    Item[j][i].ID = (uint)i;
                }
            }
            Recalculate();
        }
Example #4
0
        public override void Load(BinaryReader reader, int size)
        {
            if (ParentType == SectionType.ScriptX)
            {
                scriptGameVersion = 1;
            }
            else if (ParentType == SectionType.ScriptDemo)
            {
                scriptGameVersion = 2;
            }
            else
            {
                scriptGameVersion = 0;
            }

            var sk = reader.BaseStream.Position;

            UnkBitfield = reader.ReadUInt32();
            for (int i = 0; i < 8; ++i)
            {
                ScriptSlots[i] = reader.ReadByte();
            }

            //Class1 = reader.ReadUInt32();
            //Class2 = reader.ReadUInt32();
            //Class3 = reader.ReadUInt32();
            var len = reader.ReadInt32();

            Name = new string(reader.ReadChars(len));

            // Read UInt32 script slots
            var cnt = reader.ReadInt32();

            UI32.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                UI32.Add(reader.ReadUInt32());
            }

            // Read OGI script slots
            cnt = reader.ReadInt32();
            OGIs.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                OGIs.Add(reader.ReadUInt16());
            }

            // Read Animation script slots
            cnt = reader.ReadInt32();
            Anims.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                Anims.Add(reader.ReadUInt16());
            }

            // Read Script script slots
            cnt = reader.ReadInt32();
            Scripts.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                Scripts.Add(reader.ReadUInt16());
            }

            // Read Object script slots
            cnt = reader.ReadInt32();
            Objects.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                Objects.Add(reader.ReadUInt16());
            }

            // Read Sound script slots
            cnt = reader.ReadInt32();
            Sounds.Clear();
            for (int i = 0; i < cnt; ++i)
            {
                Sounds.Add(reader.ReadUInt16());
            }

            // Read instance properties
            if ((UnkBitfield & 0x20000000) != 0x0)
            {
                PHeader = reader.ReadUInt32();
                PUI32   = reader.ReadUInt32();

                cnt = reader.ReadInt32();
                instFlagsList.Clear();
                for (int i = 0; i < cnt; ++i)
                {
                    instFlagsList.Add(reader.ReadUInt32());
                }

                cnt = reader.ReadInt32();
                instFloatsList.Clear();
                for (int i = 0; i < cnt; ++i)
                {
                    instFloatsList.Add(reader.ReadSingle());
                }

                cnt = reader.ReadInt32();
                instIntegerList.Clear();
                for (int i = 0; i < cnt; ++i)
                {
                    instIntegerList.Add(reader.ReadUInt32());
                }
            }
            else
            {
                PHeader = 0;
                PUI32   = 0;
                instFlagsList.Clear();
                instFloatsList.Clear();
                instIntegerList.Clear();
            }
            // Read IDs needed for instance creation
            if ((UnkBitfield & 0x40000000) != 0x0)
            {
                flag = reader.ReadUInt32();
                if ((flag & 0x00000001) != 0)
                {
                    cnt = reader.ReadInt32();
                    cObjects.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cObjects.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000002) != 0)
                {
                    cnt = reader.ReadInt32();
                    cOGIs.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cOGIs.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000004) != 0)
                {
                    cnt = reader.ReadInt32();
                    cAnims.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cAnims.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000008) != 0)
                {
                    cnt = reader.ReadInt32();
                    cCM.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cCM.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000010) != 0)
                {
                    cnt = reader.ReadInt32();
                    cScripts.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cScripts.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000020) != 0)
                {
                    cnt = reader.ReadInt32();
                    cUnk.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cUnk.Add(reader.ReadUInt16());
                    }
                }
                if ((flag & 0x00000040) != 0)
                {
                    cnt = reader.ReadInt32();
                    cSounds.Clear();
                    for (int i = 0; i < cnt; ++i)
                    {
                        cSounds.Add(reader.ReadUInt16());
                    }
                }
            }
            scriptCommandsAmount = (int)reader.ReadUInt32();
            if (scriptCommandsAmount != 0)
            {
                scriptCommand = new Script.MainScript.ScriptCommand(reader, scriptGameVersion);
                var command = scriptCommand;
                do
                {
                    scriptCommands.Add(command);
                    command = command.nextCommand;
                } while (command != null);
            }
            else
            {
                scriptCommand = null;
            }
            this.size = size;
        }