Example #1
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                data = reader.Read <SoundMasterListData>();

                if (data.infoOffset > 0)
                {
                    input.Position = data.infoOffset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    infos          = new long[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        infos[i] = reader.ReadInt64();
                    }
                }
                else
                {
                    infos = new long[0];
                }

                if (data.ownerOffset > 0)
                {
                    input.Position = data.ownerOffset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    owners         = new ulong[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        owners[i] = reader.ReadUInt64();
                    }
                }
                else
                {
                    owners = new ulong[0];
                }

                if (data.soundOffset > 0)
                {
                    input.Position = data.soundOffset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    sounds         = new ulong[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        sounds[i] = reader.ReadUInt64();
                    }
                }
                else
                {
                    sounds = new ulong[0];
                }
            }
        }
Example #2
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <GameModeHeader>();

                if (header.strings > 0)
                {
                    input.Position = header.strings;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    strings        = new OWRecord[info.count];
                    input.Position = (long)info.offset;
                    for (uint i = 0; i < info.count; ++i)
                    {
                        strings[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    strings = new OWRecord[0];
                }

                if (header.@params > 0)
                {
                    input.Position = header.@params;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    @params        = new OWRecord[info.count];
                    input.Position = (long)info.offset;
                    for (uint i = 0; i < info.count; ++i)
                    {
                        @params[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    @params = new OWRecord[0];
                }

                if (header.types > 0)
                {
                    input.Position = header.types;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    types          = new OWRecord[info.count];
                    input.Position = (long)info.offset;
                    for (uint i = 0; i < info.count; ++i)
                    {
                        types[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    types = new OWRecord[0];
                }
            }
        }
Example #3
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <TextureOverrideMasterHeader>();
                if (header.offsetRecords > 0)
                {
                    input.Position = (long)header.offsetRecords;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    records        = new OWRecord[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        records[i] = reader.Read <OWRecord>();
                    }
                }

                if (header.offsetInfo == 0)
                {
                    return;
                }

                input.Position = (long)header.offsetInfo;
                STUDReferenceArrayInfo info = reader.Read <STUDReferenceArrayInfo>();

                uint size = 0;
                sizes          = new uint[info.count];
                input.Position = (long)info.indiceOffset;
                for (ulong i = 0; i < info.count; ++i)
                {
                    sizes[i] = reader.ReadUInt32();
                    if (sizes[i] > size)
                    {
                        size = sizes[i];
                    }
                }

                replace        = new ulong[size];
                references     = new TextureOverride.TextureOverrideInlineReference[size];
                input.Position = (long)info.referenceOffset;
                for (uint i = 0; i < size; ++i)
                {
                    references[i] = reader.Read <TextureOverride.TextureOverrideInlineReference>();
                    replace[i]    = references[i].key;
                }
                target = new ulong[size];
                for (uint i = 0; i < size; ++i)
                {
                    input.Position = (long)(references[i].offset + 8UL);
                    target[i]      = reader.ReadUInt64();
                }
            }
        }
Example #4
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <DecalHeader>();

                input.Position = (long)header.textures;
                STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                records        = new DecalRecord[ptr.count];
                input.Position = (long)ptr.offset;
                for (ulong i = 0; i < ptr.count; ++i)
                {
                    records[i] = reader.Read <DecalRecord>();
                }
            }
        }
Example #5
0
        public STUD(Stream input, bool initalizeAll = true, STUDManager manager = null, bool leaveOpen = false, bool suppress = false)
        {
            if (manager == null)
            {
                this.manager = STUDManager.Instance;
                manager      = this.manager;
            }
            else
            {
                this.manager = manager;
            }

            if (input == null)
            {
                return;
            }

            this.suppress = suppress;
            studstream    = input;

            using (BinaryReader reader = new BinaryReader(input, Encoding.Default, leaveOpen)) {
                start  = input.Position;
                header = reader.Read <STUDHeader>();
                if (header.magic != STUD_MAGIC)
                {
                    records   = new STUDInstanceRecord[0];
                    instances = new ISTUDInstance[0];
                    return;
                }
                input.Position = start + (long)header.instanceTableOffset;
                STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();

                records   = new STUDInstanceRecord[ptr.count];
                instances = new ISTUDInstance[ptr.count];

                for (ulong i = 0; i < ptr.count; ++i)
                {
                    records[i] = reader.Read <STUDInstanceRecord>();
                }

                end = input.Position;

                if (initalizeAll)
                {
                    InitializeAll(input, suppress);
                }
            }
        }
Example #6
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                data = reader.Read <SoundListData>();

                if (data.offsetLists > 0)
                {
                    input.Position = data.offsetLists;
                    STUDArrayInfo array = reader.Read <STUDArrayInfo>();
                    info           = new SoundListInfo[array.count];
                    entries        = new SoundListEntry[array.count][];
                    input.Position = (long)array.offset;
                    for (ulong i = 0; i < array.count; ++i)
                    {
                        info[i] = reader.Read <SoundListInfo>();
                    }

                    for (ulong i = 0; i < array.count; ++i)
                    {
                        if (info[i].offset > 0)
                        {
                            input.Position = info[i].offset;
                            STUDArrayInfo innerArray = reader.Read <STUDArrayInfo>();
                            entries[i]     = new SoundListEntry[innerArray.count];
                            input.Position = (long)innerArray.offset;
                            for (ulong j = 0; j < innerArray.count; ++j)
                            {
                                entries[i][j] = reader.Read <SoundListEntry>();
                            }
                        }
                        else
                        {
                            entries[i] = new SoundListEntry[0];
                        }
                    }
                }
                else
                {
                    info    = new SoundListInfo[0];
                    entries = new SoundListEntry[0][];
                }
            }
        }
Example #7
0
 public void Read(Stream input, OWLib.STUD stud)
 {
     using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
         header = reader.Read <AnimationListHeader>();
         if (header.arrayOffset == 0)
         {
             entries = new AnimationListEntry[0];
             return;
         }
         input.Position = (long)header.arrayOffset;
         STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
         entries        = new AnimationListEntry[ptr.count];
         input.Position = (long)ptr.offset;
         for (ulong i = 0; i < ptr.count; ++i)
         {
             entries[i] = reader.Read <AnimationListEntry>();
         }
     }
 }
Example #8
0
 public void Read(Stream input, OWLib.STUD stud)
 {
     using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
         header = reader.Read <ChildParameter>();
         if (header.offset > 0)
         {
             input.Position = (long)header.offset;
             STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
             children       = new Child[ptr.count];
             input.Position = (long)ptr.offset;
             for (ulong i = 0; i < ptr.count; ++i)
             {
                 children[i] = reader.Read <Child>();
             }
         }
         else
         {
             children = new Child[0];
         }
     }
 }
Example #9
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                master = reader.Read <MasterRecord>();

                if (master.bundles > 0)
                {
                    input.Position = master.bundles;
                    STUDArrayInfo array = reader.Read <STUDArrayInfo>();
                    bundles        = new Bundle[array.count];
                    input.Position = (long)array.offset;
                    for (ulong i = 0; i < array.count; ++i)
                    {
                        bundles[i] = reader.Read <Bundle>();
                    }
                }
                else
                {
                    bundles = new Bundle[0];
                }
            }
        }
Example #10
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <SubModel>();

                if (header.offset > 0)
                {
                    input.Position = header.offset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    entries        = new SubModelEntry[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        entries[i] = reader.Read <SubModelEntry>();
                    }
                }
                else
                {
                    entries = new SubModelEntry[0];
                }
            }
        }
Example #11
0
 public void Read(Stream input, OWLib.STUD stud)
 {
     using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
         header  = reader.Read <InventoryItemHeader>();
         data    = reader.Read <EmoteData>();
         subdata = new OWRecord[0];
         if (data.offset > 0)
         {
             input.Position = data.offset;
             STUDArrayInfo info = reader.Read <STUDArrayInfo>();
             if (info.offset > 0)
             {
                 input.Position = (long)info.offset;
                 subdata        = new OWRecord[info.count];
                 for (ulong i = 0; i < info.count; ++i)
                 {
                     subdata[i] = reader.Read <OWRecord>();
                 }
             }
         }
     }
 }
Example #12
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                data = reader.Read <SoundBankData>();

                if (data.sfxOffset > 0)
                {
                    input.Position = data.sfxOffset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    sfx            = new OWRecord[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        sfx[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    sfx = new OWRecord[0];
                }

                if (data.musicOffset > 0)
                {
                    input.Position = data.musicOffset;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    music          = new OWRecord[info.count];
                    input.Position = (long)info.offset;
                    for (ulong i = 0; i < info.count; ++i)
                    {
                        music[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    music = new OWRecord[0];
                }
            }
        }
Example #13
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <InventoryMetadata>();

                if (header.herowide > 0)
                {
                    input.Position = header.herowide;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    standardItems = new OWRecord[info.count];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            standardItems[i] = reader.Read <OWRecord>();
                        }
                    }
                }
                else
                {
                    standardItems = new OWRecord[0] {
                    };
                }

                if (header.lootbox_info > 0)
                {
                    input.Position = header.lootbox_info;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    lootboxInfo = new OWRecord[info.count];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            lootboxInfo[i] = reader.Read <OWRecord>();
                        }
                    }
                }
                else
                {
                    lootboxInfo = new OWRecord[0] {
                    };
                }

                if (header.event_box_info > 0)
                {
                    input.Position = header.event_box_info;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    eventLootboxInfo = new Bound[info.count];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            eventLootboxInfo[i] = reader.Read <Bound>();
                        }
                    }
                }
                else
                {
                    eventLootboxInfo = new Bound[0] {
                    };
                }

                if (header.lootbox_info_2 > 0)
                {
                    input.Position = header.lootbox_info_2;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    lootboxInfo2 = new Box[info.count];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            lootboxInfo2[i] = reader.Read <Box>();
                        }
                    }
                }
                else
                {
                    lootboxInfo2 = new Box[0] {
                    };
                }

                if (header.offsetarray > 0)
                {
                    input.Position = header.offsetarray;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    generic      = new InventoryEntry[info.count];
                    genericItems = new OWRecord[info.count][];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            generic[i] = reader.Read <InventoryEntry>();
                            long old = input.Position;
                            if (generic[i].items > 0)
                            {
                                input.Position = generic[i].items;
                                STUDArrayInfo subinfo = reader.Read <STUDArrayInfo>();
                                if (subinfo.count > 0)
                                {
                                    input.Position  = (long)subinfo.offset;
                                    genericItems[i] = new OWRecord[subinfo.count];
                                    for (ulong j = 0; j < subinfo.count; ++j)
                                    {
                                        genericItems[i][j] = reader.Read <OWRecord>();
                                    }
                                }
                                else
                                {
                                    genericItems[i] = new OWRecord[0];
                                }
                            }
                            else
                            {
                                genericItems[i] = new OWRecord[0];
                            }
                            input.Position = old;
                        }
                    }
                }
                else
                {
                    generic      = new InventoryEntry[0] {
                    };
                    genericItems = new OWRecord[0][] { };
                }

                if (header.categories > 0)
                {
                    input.Position = header.categories;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    categories    = new Category[info.count];
                    categoryItems = new OWRecord[info.count][];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            categories[i] = reader.Read <Category>();
                            long old = input.Position;
                            if (categories[i].offset > 0)
                            {
                                input.Position = categories[i].offset;
                                STUDArrayInfo subinfo = reader.Read <STUDArrayInfo>();
                                if (subinfo.count > 0)
                                {
                                    input.Position   = (long)subinfo.offset;
                                    categoryItems[i] = new OWRecord[subinfo.count];
                                    for (ulong j = 0; j < subinfo.count; ++j)
                                    {
                                        categoryItems[i][j] = reader.Read <OWRecord>();
                                    }
                                }
                                else
                                {
                                    categoryItems[i] = new OWRecord[0];
                                }
                            }
                            else
                            {
                                categoryItems[i] = new OWRecord[0];
                            }
                            input.Position = old;
                        }
                    }
                }
                else
                {
                    categories    = new Category[0] {
                    };
                    categoryItems = new OWRecord[0][] { };
                }

                if (header.lootbox_exclusive > 0)
                {
                    input.Position = header.lootbox_exclusive;
                    STUDArrayInfo info = reader.Read <STUDArrayInfo>();
                    exclusiveOffsets = new long[info.count];
                    lootboxExclusive = new Reward[info.count][];
                    if (info.count > 0)
                    {
                        input.Position = (long)info.offset;
                        for (ulong i = 0; i < info.count; ++i)
                        {
                            exclusiveOffsets[i] = reader.ReadInt64();
                            long old = input.Position;
                            if (exclusiveOffsets[i] > 0)
                            {
                                input.Position = exclusiveOffsets[i];
                                STUDArrayInfo subinfo = reader.Read <STUDArrayInfo>();
                                if (subinfo.count > 0)
                                {
                                    input.Position      = (long)subinfo.offset;
                                    lootboxExclusive[i] = new Reward[subinfo.count];
                                    for (ulong j = 0; j < subinfo.count; ++j)
                                    {
                                        lootboxExclusive[i][j] = reader.Read <Reward>();
                                    }
                                }
                                else
                                {
                                    lootboxExclusive[i] = new Reward[0];
                                }
                            }
                            else
                            {
                                lootboxExclusive[i] = new Reward[0];
                            }
                            input.Position = old;
                        }
                    }
                }
                else
                {
                    exclusiveOffsets = new long[0] {
                    };
                    lootboxExclusive = new Reward[0][] { };
                }
            }
        }
Example #14
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <MaterialMasterHeader>();

                STUDArrayInfo ptr;
                if (header.materialOffset > 0)
                {
                    input.Position = (long)header.materialOffset;
                    ptr            = reader.Read <STUDArrayInfo>();
                    materials      = new MaterialMasterMaterial[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        materials[i] = reader.Read <MaterialMasterMaterial>();
                    }
                }
                else
                {
                    materials = new MaterialMasterMaterial[0];
                }

                if (header.unk1Offset > 0)
                {
                    input.Position = (long)header.unk1Offset;
                    ptr            = reader.Read <STUDArrayInfo>();
                    records1       = new OWRecord[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        records1[i] = reader.Read <OWRecord>();
                    }
                }

                if (header.bindOffset > 0)
                {
                    input.Position = (long)header.bindOffset;
                    ptr            = reader.Read <STUDArrayInfo>();
                    binds          = new OWRecord[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        binds[i] = reader.Read <OWRecord>();
                    }
                }

                if (header.dataOffset > 0)
                {
                    input.Position = (long)header.dataOffset;
                    ptr            = reader.Read <STUDArrayInfo>();
                    data           = new MaterialMasterData[ptr.count];
                    dataBinds      = new MaterialMasterMaterial[ptr.count][];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        data[i] = reader.Read <MaterialMasterData>();
                    }
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        if (data[i].offset == 0)
                        {
                            continue;
                        }
                        input.Position = (long)data[i].offset;
                        STUDArrayInfo ptr2 = reader.Read <STUDArrayInfo>();
                        dataBinds[i]   = new MaterialMasterMaterial[ptr2.count];
                        input.Position = (long)ptr2.offset;
                        for (ulong j = 0; j < ptr2.count; ++j)
                        {
                            dataBinds[i][j] = reader.Read <MaterialMasterMaterial>();
                        }
                    }
                }
            }
        }
Example #15
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                data = reader.Read <AnnouncerData>();

                if (data.offsetLists > 0)
                {
                    input.Position = data.offsetLists;
                    STUDArrayInfo array = reader.Read <STUDArrayInfo>();
                    entries        = new AnnouncerFXEntry[array.count];
                    primary        = new OWRecord[array.count][];
                    secondary      = new OWRecord[array.count][];
                    input.Position = (long)array.offset;
                    for (ulong i = 0; i < array.count; ++i)
                    {
                        entries[i] = reader.Read <AnnouncerFXEntry>();
                    }

                    for (ulong i = 0; i < array.count; ++i)
                    {
                        if (entries[i].primary > 0)
                        {
                            input.Position = entries[i].primary;
                            STUDArrayInfo innerArray = reader.Read <STUDArrayInfo>();
                            primary[i]     = new OWRecord[innerArray.count];
                            input.Position = (long)innerArray.offset;
                            for (ulong j = 0; j < innerArray.count; ++j)
                            {
                                primary[i][j] = reader.Read <OWRecord>();
                            }
                        }
                        else
                        {
                            primary[i] = new OWRecord[0];
                        }

                        if (entries[i].secondary > 0)
                        {
                            input.Position = entries[i].secondary;
                            STUDArrayInfo innerArray = reader.Read <STUDArrayInfo>();
                            secondary[i]   = new OWRecord[innerArray.count];
                            input.Position = (long)innerArray.offset;
                            for (ulong j = 0; j < innerArray.count; ++j)
                            {
                                secondary[i][j] = reader.Read <OWRecord>();
                            }
                        }
                        else
                        {
                            secondary[i] = new OWRecord[0];
                        }
                    }
                }
                else
                {
                    entries   = new AnnouncerFXEntry[0];
                    primary   = new OWRecord[0][];
                    secondary = new OWRecord[0][];
                }
            }
        }
Example #16
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <InventoryMasterHeader>();

                if (header.achievableOffset > 0)
                {
                    input.Position = (long)header.achievableOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    achievableItems = new OWRecord[ptr.count];
                    input.Position  = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        achievableItems[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    achievableItems = new OWRecord[0];
                }

                if (header.defaultOffset > 0)
                {
                    input.Position = (long)header.defaultOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    defaultGroups     = new InventoryMasterGroup[ptr.count];
                    defaultGroupItems = new OWRecord[ptr.count][];
                    input.Position    = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        defaultGroups[i] = reader.Read <InventoryMasterGroup>();
                    }

                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        input.Position = (long)defaultGroups[i].offset;
                        STUDArrayInfo ptr2 = reader.Read <STUDArrayInfo>();
                        defaultGroupItems[i] = new OWRecord[ptr2.count];
                        input.Position       = (long)ptr2.offset;
                        for (ulong j = 0; j < ptr2.count; ++j)
                        {
                            defaultGroupItems[i][j] = reader.Read <OWRecord>();
                        }
                    }
                }
                else
                {
                    defaultGroupItems = new OWRecord[0][];
                    defaultGroups     = new InventoryMasterGroup[0];
                }

                if (header.itemOffset > 0)
                {
                    input.Position = (long)header.itemOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    itemGroups     = new InventoryMasterGroup[ptr.count];
                    itemGroupItems = new OWRecord[ptr.count][];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        itemGroups[i] = reader.Read <InventoryMasterGroup>();
                    }

                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        if (itemGroups[i].offset > 0)
                        {
                            input.Position = (long)itemGroups[i].offset;
                            STUDArrayInfo ptr2 = reader.Read <STUDArrayInfo>();
                            itemGroupItems[i] = new OWRecord[ptr2.count];
                            input.Position    = (long)ptr2.offset;
                            for (ulong j = 0; j < ptr2.count; ++j)
                            {
                                itemGroupItems[i][j] = reader.Read <OWRecord>();
                            }
                        }
                        else
                        {
                            itemGroupItems[i] = new OWRecord[0];
                        }
                    }
                }
                else
                {
                    itemGroupItems = new OWRecord[0][];
                    itemGroups     = new InventoryMasterGroup[0];
                }
            }
        }
Example #17
0
        public void Read(Stream input, OWLib.STUD stud)
        {
            using (BinaryReader reader = new BinaryReader(input, System.Text.Encoding.Default, true)) {
                header = reader.Read <HeroMasterHeader>();
                long seekpos = input.Position;
#if OUTPUT_STUDHEROMASTER
                input.Seek(0, SeekOrigin.Begin);
                string outFilename = string.Format("./STUDs/HeroMaster/{0:X8}_{1}.stud", (0x00000000FFFFFFFF & header.name.key), header.id.ToString());
                string putPathname = outFilename.Substring(0, outFilename.LastIndexOf('/'));
                Directory.CreateDirectory(putPathname);
                Stream OutWriter = File.Create(outFilename);
                input.CopyTo(OutWriter);
                OutWriter.Close();
                input.Seek(seekpos, SeekOrigin.Begin);
#endif
                //Console.Out.WriteLine("Name: {8:X8}, ID: {0}, x: {1}, y: {2}, z: {3}, w: {4}, index: {5}, type: {6}, subtype: {7}, ItemKey: {9:X16}", header.id, header.x, header.y, header.z, header.w, header.index, header.type, header.subtype, (0x00000000FFFFFFFF & header.name.key), header.itemMaster.key);
                if ((long)header.virtualOffset > 0)
                {
                    input.Position = (long)header.virtualOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    virtualRecords = new OWRecord[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        virtualRecords[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    virtualRecords = new OWRecord[0] {
                    };
                }

                if ((long)header.bindsOffset > 0)
                {
                    input.Position = (long)header.bindsOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    r09ERecords    = new OWRecord[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        r09ERecords[i] = reader.Read <OWRecord>();
                    }
                }
                else
                {
                    r09ERecords = new OWRecord[0] {
                    };
                }

                if ((long)header.child1Offset > 0)
                {
                    input.Position = (long)header.child1Offset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    child1         = new HeroChild1[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        child1[i] = reader.Read <HeroChild1>();
                    }
                }
                else
                {
                    child1 = new HeroChild1[0] {
                    };
                }

                if ((long)header.child2Offset > 0)
                {
                    input.Position = (long)header.child2Offset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    child2         = new HeroChild2[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        child2[i] = reader.Read <HeroChild2>();
                    }
                }
                else
                {
                    child2 = new HeroChild2[0] {
                    };
                }

                if ((long)header.child3Offset > 0)
                {
                    input.Position = (long)header.child3Offset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    child3         = new HeroChild2[ptr.count];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        child3[i] = reader.Read <HeroChild2>();
                    }
                }
                else
                {
                    child3 = new HeroChild2[0] {
                    };
                }

                if ((long)header.directiveOffset > 0)
                {
                    input.Position = (long)header.directiveOffset;
                    STUDArrayInfo ptr = reader.Read <STUDArrayInfo>();
                    directives     = new HeroDirective[ptr.count];
                    directiveChild = new OWRecord[ptr.count][];
                    input.Position = (long)ptr.offset;
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        directives[i] = reader.Read <HeroDirective>();
                    }
                    for (ulong i = 0; i < ptr.count; ++i)
                    {
                        if ((long)directives[i].offsetSubs > 0)
                        {
                            STUDArrayInfo ptr2 = reader.Read <STUDArrayInfo>();
                            directiveChild[i] = new OWRecord[ptr2.count];
                            input.Position    = (long)ptr2.offset;
                            for (ulong j = 0; j < ptr2.count; ++j)
                            {
                                directiveChild[i][j] = reader.Read <OWRecord>();
                            }
                        }
                        else
                        {
                            directiveChild[i] = new OWRecord[0] {
                            };
                        }
                    }
                }
                else
                {
                    directives     = new HeroDirective[0] {
                    };
                    directiveChild = new OWRecord[0][] { };
                }
            }
        }