示例#1
0
        public static DsgVar Read(EndianBinaryReader reader, Pointer offset, DsgMem dsgMem = null)
        {
            DsgVar dsgVar = new DsgVar(offset);

            dsgVar.off_dsgMemBuffer = Pointer.Read(reader);
            dsgVar.off_dsgVarInfo   = Pointer.Read(reader);

            // Unknown stuff
            if (dsgMem == null)
            {
                dsgVar.something3 = reader.ReadUInt32();
            }

            if (dsgMem == null)
            {
                dsgVar.amountOfInfos      = reader.ReadUInt32();
                dsgVar.dsgMemBufferLength = reader.ReadUInt32() * 4;
            }
            else
            {
                dsgVar.dsgMemBufferLength = reader.ReadUInt32();
                dsgVar.amountOfInfos      = reader.ReadUInt32();
            }

            dsgVar.dsgVarInfos = new DsgVarInfoEntry[dsgVar.amountOfInfos];

            if (dsgVar.off_dsgVarInfo != null && dsgVar.amountOfInfos > 0)
            {
                Pointer off_current = Pointer.Goto(ref reader, dsgVar.off_dsgVarInfo);
                for (int i = 0; i < dsgVar.amountOfInfos; i++)
                {
                    DsgVarInfoEntry infoEntry = DsgVarInfoEntry.Read(reader, Pointer.Current(reader));

                    if (dsgMem != null)
                    {
                        infoEntry.value = dsgVar.ReadValueFromDsgMemBuffer(reader, infoEntry, dsgMem);
                    }
                    else
                    {
                        infoEntry.value = dsgVar.ReadValueFromDsgVarBuffer(reader, infoEntry, dsgVar);
                    }
                    dsgVar.dsgVarInfos[i] = infoEntry;
                }
                Pointer.Goto(ref reader, off_current); // Move the reader back to where it was
            }

            /*if (d.off_AI_model != null) {
             *  Pointer.Goto(ref reader, d.off_AI_model);
             *  d.AI_model = AIModel.Read(reader, d.off_AI_model);
             * }*/
            return(dsgVar);
        }
示例#2
0
文件: DsgVar.cs 项目: Zax37/raymap
        public static DsgVar Read(Reader reader, Pointer offset, DsgMem dsgMem = null)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("DsgVar " + offset);
            DsgVar dsgVar = new DsgVar(offset);

            dsgVar.off_dsgMemBuffer = Pointer.Read(reader);
            dsgVar.off_dsgVarInfo   = Pointer.Read(reader);

            /*if (dsgMem != null) {
             *  l.print(offset + " - " + dsgVar.off_dsgMemBuffer + " - " + dsgVar.off_dsgVarInfo);
             *  l.print("DsgMem initial: " + dsgMem.memBufferInitial + " - cur: " + dsgMem.memBuffer);
             * }*/

            // Unknown stuff
            if (dsgMem == null &&
                Settings.s.platform != Settings.Platform.GC &&
                Settings.s.platform != Settings.Platform.DC &&
                Settings.s.platform != Settings.Platform.Xbox360 &&
                Settings.s.game != Settings.Game.R2Revolution &&
                Settings.s.game != Settings.Game.LargoWinch &&
                Settings.s.engineVersion >= Settings.EngineVersion.R2)
            {
                dsgVar.something3 = reader.ReadUInt32();
            }

            if (Settings.s.game == Settings.Game.R2Revolution)
            {
                dsgVar.dsgMemBufferLength = reader.ReadUInt16();
                dsgVar.amountOfInfos      = reader.ReadUInt16();
            }
            else if (Settings.s.platform == Settings.Platform.GC ||
                     Settings.s.platform == Settings.Platform.DC ||
                     Settings.s.platform == Settings.Platform.Xbox360 ||
                     Settings.s.engineVersion < Settings.EngineVersion.R2 ||
                     Settings.s.game == Settings.Game.LargoWinch)
            {
                dsgVar.dsgMemBufferLength = reader.ReadUInt32();
                dsgVar.amountOfInfos      = reader.ReadByte();
            }
            else if (dsgMem == null)
            {
                dsgVar.amountOfInfos      = reader.ReadUInt32();
                dsgVar.dsgMemBufferLength = reader.ReadUInt32() * 4;
            }
            else
            {
                dsgVar.dsgMemBufferLength = reader.ReadUInt32();
                dsgVar.amountOfInfos      = reader.ReadUInt32();
            }

            if (dsgMem != null && dsgMem.memBufferInitial == null)
            {
                dsgMem.memBufferInitial = dsgVar.off_dsgMemBuffer;
            }

            dsgVar.dsgVarInfos = new DsgVarInfoEntry[dsgVar.amountOfInfos];

            if (dsgVar.amountOfInfos > 0)
            {
                Pointer.DoAt(ref reader, dsgVar.off_dsgVarInfo, () => {
                    //l.print(dsgVar.amountOfInfos);
                    for (uint i = 0; i < dsgVar.amountOfInfos; i++)
                    {
                        DsgVarInfoEntry infoEntry = DsgVarInfoEntry.Read(reader, Pointer.Current(reader), i);
                        //l.print(infoEntry.offset + " - " + infoEntry.typeNumber + " - " + infoEntry.type + " - " + infoEntry.offsetInBuffer);

                        if (dsgMem != null)
                        {
                            if (Settings.s.platform != Settings.Platform.DC)
                            {
                                infoEntry.value = dsgVar.ReadValueFromDsgMemBuffer(reader, infoEntry, dsgMem);
                            }
                            if (dsgMem.memBufferInitial != null)
                            {
                                infoEntry.initialValue = dsgVar.ReadInitialValueFromDsgMemBuffer(reader, infoEntry, dsgMem);
                                if (Settings.s.platform == Settings.Platform.DC)
                                {
                                    infoEntry.value = infoEntry.initialValue;
                                }
                            }
                        }
                        else
                        {
                            infoEntry.value = dsgVar.ReadValueFromDsgVarBuffer(reader, infoEntry, dsgVar);
                        }
                        dsgVar.dsgVarInfos[i] = infoEntry;
                    }
                });
            }

            /*if (d.off_AI_model != null) {
             *  Pointer.Goto(ref reader, d.off_AI_model);
             *  d.AI_model = AIModel.Read(reader, d.off_AI_model);
             * }*/
            return(dsgVar);
        }