コード例 #1
0
        protected override void ReadMembers(SR1_Reader reader, SR1_Structure parent)
        {
            name.SetReadMax(true).Read(reader, this, "name");
            intronum.Read(reader, this, "intronum");
            UniqueID.Read(reader, this, "UniqueID");
            link.Read(reader, this, "link", SR1_File.Version.Feb04, SR1_File.Version.Feb16);
            rotation.Read(reader, this, "rotation");
            position.Read(reader, this, "position");
            maxRad.Read(reader, this, "maxRad");
            maxRadSq.Read(reader, this, "maxRadSq");
            flags.Read(reader, this, "flags");
            data.Read(reader, this, "data");
            instance.Read(reader, this, "instance");
            multiSpline.Read(reader, this, "multiSpline");
            dsignal.Read(reader, this, "dsignal");
            specturalLightGroup.Read(reader, this, "specturalLightGroup");
            meshColor.Read(reader, this, "meshColor");
            spectralPosition.Read(reader, this, "spectralPosition");
            spad.Read(reader, this, "spad");

            if (!reader.File._IntroNames.Contains(name.ToString()))
            {
                reader.File._IntroNames.Add(name.ToString());
            }

            int uniqueID = UniqueID.Value;

            if (!reader.File._IntroIDs.Contains(uniqueID))
            {
                reader.File._IntroIDs.Add(uniqueID);
            }
        }
コード例 #2
0
        protected override void ReadReferences(SR1_Reader reader, SR1_Structure parent)
        {
            worldNameString.SetPadding(4).ReadFromPointer(reader, worldName);
            Name = worldNameString.ToString();

            new SR1_StructureSeries <MultiSignal>((int)(SignalListEnd.Offset - SignalListStart.Offset)).ReadFromPointer(reader, SignalListStart);
            SR1_Structure terrainStruct = new Terrain().ReadFromPointer(reader, terrain);

            lightListStruct0.ReadFromPointer(reader, lightList);
            if (reader.File._Version < SR1_File.Version.May12 &&
                lightListStruct0.End != 0 && lightListStruct0.End != depthQPTable.Offset)
            {
                if (Name == "push6")
                {
                    push6Padding.ReadOrphan(reader, lightListStruct0.End);
                }
                else
                {
                    // Got lucky with depthQPTable always being there. Could use a better solution.
                    lightListStruct1.SetSkipAmbient(true);
                    lightListStruct1.ReadOrphan(reader, lightListStruct0.End);
                }
            }

            new VMObjectList(numVMObjects.Value).ReadFromPointer(reader, vmobjectList);
            if (reader.File._Version <= SR1_File.Version.May12)
            {
                new SR1_StructureArray <SpotLight>(numSpotLights.Value).ReadFromPointer(reader, spotLightList);
            }
            new LightList().ReadFromPointer(reader, spectrallightList);

            if (reader.File._Version < SR1_File.Version.May12)
            {
                // depthQPTable is length 3464 discovered in function LIGHT_CalcDQPTable

                /*int iVar6 = -((int)(fogFar.Value * fogNear.Value) / (int)(fogFar.Value - fogNear.Value));
                 * if (0x9ffe < iVar6)
                 * {
                 * iVar6 = 0x9ffe;
                 * }
                 * if (iVar6 < -0x9ffe)
                 * {
                 * iVar6 = -0x9ffe;
                 * }
                 * int iVar8 = (int)((uint)fogFar.Value << 0xc) / (int)((uint)fogFar.Value - (uint)fogNear.Value);
                 * int iVar9 = (iVar6 * -0x1000) / iVar8;
                 * int iVar10 = (iVar6 * 0x1000) / (0x1000 - iVar8);
                 * int iVar11 = 0x3620;
                 * int iVar12 = iVar11 / 4;*/
                new SR1_PrimativeArray <short>(3464).ReadFromPointer(reader, depthQPTable);
            }

            new SR1_StructureArray <CameraKey>(numCameras.Value).ReadFromPointer(reader, cameraList);
            new SR1_StructureArray <VGroup>(numVGroups.Value).ReadFromPointer(reader, vGroupList);
            new SR1_StructureArray <Intro>(numIntros.Value).ReadFromPointer(reader, introList);
            SR1_Structure objectNameListStruct = new ObjectNameList().ReadFromPointer(reader, objectNameList);

            new SR1_StructureArray <PlanMkr>(NumberOfPlanMarkers.Value).SetPadding(4).ReadFromPointer(reader, PlanMarkerList);
            new SR1_StructureArray <SFXMkr>(NumberOfSFXMarkers.Value).ReadFromPointer(reader, SFXMarkerList);
            if (reader.File._Version >= SR1_File.Version.Jun01)
            {
                new SR1_String(4).SetPadding(4).ReadFromPointer(reader, dynamicMusicName);
            }
            else if (reader.File._Version < SR1_File.Version.May12 &&
                     dynamicMusicName.Offset != 0 && dynamicMusicName.Offset < cpad3.End)
            {
                uint adjustLength = cpad3.End - dynamicMusicName.Offset;
                new SR1_String(12 - (int)adjustLength).SetPadding(4).ReadOrphan(reader, cpad3.End);
            }
            else
            {
                new SR1_String(12).SetPadding(4).ReadFromPointer(reader, dynamicMusicName);
            }
            new LightGroup().ReadFromPointer(reader, razielLightGroup);
            new LightGroup().ReadFromPointer(reader, razielSpectralLightGroup);

            if (PuzzleInstances.Offset != 0)
            {
                reader.BaseStream.Position = PuzzleInstances.Offset;
                EventPointers tempEventPointers = new EventPointers();
                tempEventPointers.ReadTemp(reader);
                uint firstEvent = uint.MaxValue;
                foreach (SR1_PointerBase eventInstance in tempEventPointers.eventInstances)
                {
                    if (eventInstance.Offset != 0 && eventInstance.Offset < firstEvent)
                    {
                        firstEvent = eventInstance.Offset;
                    }
                }

                if (firstEvent != 0 && firstEvent != uint.MaxValue)
                {
                    reader.BaseStream.Position = firstEvent;
                    events = new Events(tempEventPointers.numPuzzles.Value);
                    events.Read(reader, null, "");
                    reader.Events = events;
                }
            }

            if (terrainStruct.End != 0)
            {
                foreach (SR1_Pointer <SFXFileData> pointer in reader.SFXDictionary.Values)
                {
                    SR1_Structure sfxFileDataList = new SFXFileDataList().ReadFromPointer(reader, pointer);
                    if (!reader.File._Structures.ContainsKey(sfxFileDataList.End))
                    {
                        reader.BaseStream.Position = sfxFileDataList.End;
                        new SR1_PrimativeArray <byte>((int)(terrainStruct.Start - sfxFileDataList.End)).Read(reader, null, "");
                    }
                    break;
                }
            }

            // 8 mystery bytes after events. Mirror?
            if (events != null && !reader.File._Structures.ContainsKey(events.End))
            {
                reader.BaseStream.Position = events.End;
                new Mirror().Read(reader, null, "");
            }

            reader.BaseStream.Position = objectNameListStruct.Start - 1;
            while (!reader.File._Structures.ContainsKey((uint)reader.BaseStream.Position))
            {
                reader.BaseStream.Position--;
            }
            if (!reader.File._Structures.ContainsKey(reader.File._Structures[(uint)reader.BaseStream.Position].End))
            {
                reader.BaseStream.Position = reader.File._Structures[(uint)reader.BaseStream.Position].End;
                int length = (int)objectNameListStruct.Start - (int)reader.BaseStream.Position;
                new SR1_PrimativeArray <byte>(length).Read(reader, null, "");
            }
        }
コード例 #3
0
        protected override void ReadReferences(SR1_Reader reader, SR1_Structure parent)
        {
            nameString.SetPadding(4).ReadFromPointer(reader, name);
            scriptString.SetPadding(4).ReadFromPointer(reader, script);

            Name = scriptString.ToString();

            bool useFlameGSHack = false;

            if (reader.File._Version == SR1_File.Version.Feb16 && Name == "flamegs_")
            {
                new SR1_String(12).SetPadding(4).ReadOrphan(reader, 0x44);
                useFlameGSHack = true;
            }

            SR1_Structure modelListStruct   = new SR1_PointerArray <Model>(System.Math.Max(1, (int)numModels.Value), true).ReadFromPointer(reader, modelList);
            SR1_Structure animListStruct    = new SR1_PointerArray <G2AnimKeylist_Type>(numAnims.Value, false).ReadFromPointer(reader, animList);
            SR1_Structure effectListStruct  = new SR1_StructureArray <ObjectEffect>(numberOfEffects.Value).ReadFromPointer(reader, effectList);
            SR1_Structure soundDataStruct   = new SFXFileData().SetPadding(4).ReadFromPointer(reader, soundData);
            SR1_Structure relocListStruct   = new RelocateList().ReadFromPointer(reader, relocList);
            SR1_Structure relocModuleStruct =
                (Name == "cinemax_") ? new CinemaFnTableT().ReadFromPointer(reader, relocModule) :
                (Name == "mcardx__") ? new MCardMTableT().ReadFromPointer(reader, relocModule) :
                new MonsterFunctionTable().ReadFromPointer(reader, relocModule);

            PhysObProperties     physObBase    = null;
            PhysObPropertiesBase physOb        = null;
            MonsterAttributes    monAttributes = null;

            if (data.Offset != 0)
            {
                if (Name == "pshblkb_" || Name == "urn_____")
                {
                    new PhysObGenericProperties(0).ReadFromPointer(reader, data);
                }
                else if ((oflags2.Value & 0x00040000) != 0 ||
                         Name == "catdora_" ||
                         Name == "walbosc_" ||
                         Name == "flamesk_" ||
                         Name == "flamesl_")
                {
                    // new PhysObProperties().ReadFromPointer(reader, data);

                    reader.BaseStream.Position = (long)data.Offset;
                    physObBase = new PhysObProperties();
                    physObBase.ReadTemp(reader);
                    reader.BaseStream.Position = (long)data.Offset;
                    physOb = (PhysObPropertiesBase)physObBase.CreateReplacementObject();
                    physOb.ReadFromPointer(reader, data);
                    reader.PhysObProperties = physOb;
                }
                else if ((oflags2.Value & 0x00080000) != 0)
                {
                    //_MonsterAttributes
                    // monsterAttributes->magic number: -0x531fff9b
                    // MONTABLE_SetupTablePointer whatAmI

                    monAttributes = new MonsterAttributes();
                    monAttributes.ReadFromPointer(reader, data);

                    if (Name == "aluka___")
                    {
                        new AlukaTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "alukabss")
                    {
                        new AlukaBssTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "hunter__")
                    {
                        new HunterTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "kain____")
                    {
                        KainTuneData kainData = new KainTuneData();
                        kainData.SetPadding(soundData.Offset != 0 ? 0 : 4);
                        kainData.ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "roninbss")
                    {
                        new RoninBssTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "skinbos_")
                    {
                        new SkinBosTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "walboss_")
                    {
                        new WalBosTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "walbosb_")
                    {
                        new WalBosBTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "wallcr__")
                    {
                        new WallcrData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "vwraith_")
                    {
                        new VWraithTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                    else if (Name == "priests_")
                    {
                        new PriestsTuneData().ReadFromPointer(reader, monAttributes.tunData);
                    }
                }
                else if (Name == "raziel__")
                {
                    new RazielData().ReadFromPointer(reader, data);
                }
                else if (Name == "sreavr__")
                {
                    new ReaverTuneData().ReadFromPointer(reader, data);
                }
                else if (Name == "glphicon")
                {
                    new GlyphTuneData().ReadFromPointer(reader, data);
                }
                else if (Name == "monster_")
                {
                    new MonsterAttributes().ReadFromPointer(reader, data);
                }
                else if (Name == "particle")
                {
                    // GenericFXObject?
                    // See FX_RelocateGeneric?
                    new GenericFXObject().ReadFromPointer(reader, data);
                }
                else if (Name == "litshaft")
                {
                    new LitShaftProperties().ReadFromPointer(reader, data);
                }
                else if (Name == "waterfx_")
                {
                    new WaterFXProperties().ReadFromPointer(reader, data);
                }
                else if ((oflags2.Value & 0x00040000) == 0)
                {
                    new GenericTune().ReadFromPointer(reader, data);
                }
            }

            if (numAnims.Value > 0)
            {
                SR1_StructureArray <G2AnimKeylist_Type> keyLists = new SR1_StructureArray <G2AnimKeylist_Type>(numAnims.Value);
                if (reader.File._Version >= SR1_File.Version.Feb16 && reader.File._Version < SR1_File.Version.May12 &&
                    Name == "wrshp___")
                {
                    ((G2AnimKeylist_Type)keyLists[14]).OverridePadLength(8);
                }
                if (reader.File._Version >= SR1_File.Version.May12 && reader.File._Version < SR1_File.Version.Jun01 &&
                    Name == "wrshp___")
                {
                    ((G2AnimKeylist_Type)keyLists[15]).OverridePadLength(8);
                }
                else if (reader.File._Version >= SR1_File.Version.Jun01 && reader.File._Version < SR1_File.Version.Next &&
                         Name == "wrshp___")
                {
                    ((G2AnimKeylist_Type)keyLists[13]).OverridePadLength(8);
                }

                keyLists.ReadFromPointer(reader, ((SR1_PointerArray <G2AnimKeylist_Type>)animListStruct)[0]);
                AnimKeyListStart = keyLists.Start;

                bool readUnusedAnimFX = false;

                if (reader.File._Version >= SR1_File.Version.May12 && reader.File._Version < SR1_File.Version.Jul14 &&
                    (Name == "hunter__" || Name == "wrshp___" ||
                     Name == "vlgra___" || Name == "vlgrb___" || Name == "vlgrc___"))
                {
                    readUnusedAnimFX = true;
                }
                else if (reader.File._Version == SR1_File.Version.Feb16)
                {
                    readUnusedAnimFX = true;
                }

                if (readUnusedAnimFX)
                {
                    reader.BaseStream.Position = keyLists.Start - 1;
                    while (!reader.File._Structures.ContainsKey((uint)reader.BaseStream.Position))
                    {
                        reader.BaseStream.Position--;
                    }
                    reader.BaseStream.Position = reader.File._Structures[(uint)reader.BaseStream.Position].End;
                    uint length = keyLists.Start - (uint)reader.BaseStream.Position;
                    if (length > 0)
                    {
                        new SR1_StructureSeries <G2AnimFXList>((int)length).SetPadding(4).Read(reader, null, "");
                    }
                }
                else if (reader.AnimFXDictionary.Count > 0)
                {
                    // Superceeded by code above?
                    int numEffects = reader.AnimFXDictionary.Count;
                    if (reader.Object.Name == "wrshp___")
                    {
                        if (reader.File._Version >= SR1_File.Version.Jul14)
                        {
                            numEffects = 11;
                        }
                        else if (reader.File._Version >= SR1_File.Version.Jun18)
                        {
                            numEffects = 28;
                        }
                    }

                    SR1_StructureArray <G2AnimFXList> fxLists = new SR1_StructureArray <G2AnimFXList>(numEffects);
                    fxLists.SetPadding(4).ReadFromPointer(reader, reader.AnimFXDictionary.Values[0]);
                }
            }

            uint padAdress = End;

            if (nameString.End > padAdress)
            {
                padAdress = nameString.End;
            }
            if (scriptString.End > padAdress)
            {
                padAdress = scriptString.End;
            }
            if (modelListStruct.End > padAdress)
            {
                padAdress = modelListStruct.End;
            }
            if (animListStruct.End > padAdress)
            {
                padAdress = animListStruct.End;
            }
            if (effectListStruct.End > padAdress)
            {
                padAdress = effectListStruct.End;
            }

            // 8 mystery bytes after effectList. THIS APPEARS TO BE A PHYSOBLIGHT. REMOVE THIS?
            if (physObBase != null && !reader.File._Structures.ContainsKey(padAdress))
            {
                reader.BaseStream.Position = padAdress;
                new SR1_PrimativeArray <byte>(useFlameGSHack ? 4 : 8).Read(reader, null, "");
            }
        }