Exemple #1
0
        public static Mind Read(EndianBinaryReader reader, Pointer offset)
        {
            Mind m = new Mind(offset);

            m.off_AI_model            = Pointer.Read(reader);
            m.off_intelligence_normal = Pointer.Read(reader);
            m.off_intelligence_reflex = Pointer.Read(reader);
            m.off_dsgMem = Pointer.Read(reader);
            m.off_name   = Pointer.Read(reader);

            if (m.off_AI_model != null)
            {
                m.AI_model = AIModel.FromOffset(m.offset);
                if (m.AI_model == null)
                {
                    Pointer.Goto(ref reader, m.off_AI_model);
                    m.AI_model = AIModel.Read(reader, m.off_AI_model);
                }
            }

            if (MapLoader.Loader.mode == MapLoader.Mode.Rayman2PC && m.off_dsgMem != null)
            {
                Pointer.Goto(ref reader, m.off_dsgMem);
                m.dsgMem = DsgMem.Read(reader, m.off_dsgMem);
            }
            return(m);
        }
Exemple #2
0
        public void UpdateCurrentBehaviors(Reader reader)
        {
            off_AI_model            = Pointer.Read(reader);
            off_intelligence_normal = Pointer.Read(reader);
            off_intelligence_reflex = Pointer.Read(reader);
            off_dsgMem = Pointer.Read(reader);

            MapLoader l = MapLoader.Loader;

            if (dsgMem == null)
            {
                dsgMem = l.FromOffsetOrRead <DsgMem>(reader, off_dsgMem);
            }
            dsgMem?.Read(reader);

            if (intelligenceNormal == null)
            {
                intelligenceNormal = l.FromOffsetOrRead <Intelligence>(reader, off_intelligence_normal);
            }
            intelligenceNormal?.Read(reader);

            if (intelligenceReflex == null)
            {
                intelligenceReflex = l.FromOffsetOrRead <Intelligence>(reader, off_intelligence_reflex);
            }
            intelligenceReflex?.Read(reader);
        }
Exemple #3
0
        public void UpdateCurrentBehaviors(Reader reader)
        {
            off_AI_model            = Pointer.Read(reader);
            off_intelligence_normal = Pointer.Read(reader);
            off_intelligence_reflex = Pointer.Read(reader);
            off_dsgMem = Pointer.Read(reader);

            if (off_dsgMem != null)
            {
                Pointer.Goto(ref reader, off_dsgMem);
                dsgMem = DsgMem.Read(reader, off_dsgMem);
            }

            if (off_intelligence_normal != null)
            {
                Pointer.Goto(ref reader, off_intelligence_normal);
                intelligenceNormal = Intelligence.Read(reader, off_intelligence_normal);
            }

            if (off_intelligence_reflex != null)
            {
                Pointer.Goto(ref reader, off_intelligence_reflex);
                intelligenceReflex = Intelligence.Read(reader, off_intelligence_reflex);
            }
        }
Exemple #4
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);
        }
Exemple #5
0
        public static DsgMem Read(EndianBinaryReader reader, Pointer offset)
        {
            DsgMem dsgMem = new DsgMem(offset);

            Pointer dsgVarPointer = Pointer.Read(reader);
            Pointer original      = Pointer.Goto(ref reader, dsgVarPointer);

            dsgMem.off_dsgVar = Pointer.Read(reader);
            Pointer.Goto(ref reader, original);

            dsgMem.memBufferInitial = Pointer.Read(reader);
            dsgMem.memBuffer        = Pointer.Read(reader);

            if (dsgMem.off_dsgVar != null)
            {
                Pointer.Goto(ref reader, dsgMem.off_dsgVar);
                dsgMem.dsgVar = DsgVar.Read(reader, dsgMem.off_dsgVar, dsgMem);
            }
            return(dsgMem);
        }
Exemple #6
0
        public void RegisterReferences(DsgMem dsgMem)
        {
            switch (type)
            {
            case DsgVarInfoEntry.DsgVarType.SuperObject:    valueSuperObject?.References.referencedByDsgMems.Add(dsgMem); break;

            case DsgVarInfoEntry.DsgVarType.Perso:          valuePerso?.References.referencedByDsgMems.Add(dsgMem); break;

            case DsgVarInfoEntry.DsgVarType.WayPoint:       valueWayPoint?.References.referencedByDsgMems.Add(dsgMem); break;

            case DsgVarInfoEntry.DsgVarType.Graph:          valueGraph?.References.referencedByDsgMems.Add(dsgMem); break;

            // Arrays
            case DsgVarInfoEntry.DsgVarType.SuperObjectArray:
            case DsgVarInfoEntry.DsgVarType.PersoArray:
            case DsgVarInfoEntry.DsgVarType.WayPointArray:
            case DsgVarInfoEntry.DsgVarType.GraphArray:
                valueArray.ToList().ForEach(v => v.RegisterReferences(dsgMem)); break;

            default: return;
            }
        }
Exemple #7
0
        protected override void ReadInternal(Reader reader)
        {
            off_AI_model            = Pointer.Read(reader);
            off_intelligence_normal = Pointer.Read(reader);
            if (Settings.s.game == Settings.Game.R2Demo)
            {
                off_dsgMem = Pointer.Read(reader);
                off_intelligence_reflex = Pointer.Read(reader);
            }
            else
            {
                off_intelligence_reflex = Pointer.Read(reader);
                off_dsgMem = Pointer.Read(reader);
            }
            if (Settings.s.hasNames)
            {
                off_name = Pointer.Read(reader);
            }
            byte0 = reader.ReadByte();
            byte1 = reader.ReadByte();
            byte2 = reader.ReadByte();
            byte3 = reader.ReadByte();

            if (Settings.s.game == Settings.Game.R2Demo)
            {
                // null
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
            }

            MapLoader l = MapLoader.Loader;

            AI_model           = l.FromOffsetOrRead <AIModel>(reader, off_AI_model);
            dsgMem             = l.FromOffsetOrRead <DsgMem>(reader, off_dsgMem);
            intelligenceNormal = l.FromOffsetOrRead <Intelligence>(reader, off_intelligence_normal);
            intelligenceReflex = l.FromOffsetOrRead <Intelligence>(reader, off_intelligence_reflex);
        }
Exemple #8
0
        public static DsgMem Read(Reader reader, Pointer offset)
        {
            DsgMem dsgMem = new DsgMem(offset);
            //MapLoader.Loader.print("DsgMem " + offset);
            Pointer dsgVarPointer = Pointer.Read(reader);

            Pointer.DoAt(ref reader, dsgVarPointer, () => {
                if (Settings.s.game == Settings.Game.R2Demo)
                {
                    Pointer.Read(reader);
                }
                dsgMem.off_dsgVar = Pointer.Read(reader);
            });

            dsgMem.memBufferInitial = Pointer.Read(reader);
            dsgMem.memBuffer        = Pointer.Read(reader);

            Pointer.DoAt(ref reader, dsgMem.off_dsgVar, () => {
                dsgMem.dsgVar = DsgVar.Read(reader, dsgMem.off_dsgVar, dsgMem);
            });
            return(dsgMem);
        }
Exemple #9
0
        public static Mind Read(Reader reader, Pointer offset)
        {
            Mind m = new Mind(offset);

            m.off_AI_model            = Pointer.Read(reader);
            m.off_intelligence_normal = Pointer.Read(reader);
            //if (m.off_intelligence_normal != null) MapLoader.Loader.print(m.off_intelligence_normal);
            m.off_intelligence_reflex = Pointer.Read(reader);
            m.off_dsgMem = Pointer.Read(reader);
            if (Settings.s.hasNames)
            {
                m.off_name = Pointer.Read(reader);
            }
            m.byte0 = reader.ReadByte();
            m.byte1 = reader.ReadByte();
            m.byte2 = reader.ReadByte();
            m.byte3 = reader.ReadByte();

            m.AI_model = AIModel.FromOffsetOrRead(m.off_AI_model, reader);

            if (m.off_dsgMem != null)
            {
                Pointer.Goto(ref reader, m.off_dsgMem);
                m.dsgMem = DsgMem.Read(reader, m.off_dsgMem);
            }

            if (m.off_intelligence_normal != null)
            {
                Pointer.Goto(ref reader, m.off_intelligence_normal);
                m.intelligenceNormal = Intelligence.Read(reader, m.off_intelligence_normal);
            }

            if (m.off_intelligence_reflex != null)
            {
                Pointer.Goto(ref reader, m.off_intelligence_reflex);
                m.intelligenceReflex = Intelligence.Read(reader, m.off_intelligence_reflex);
            }
            return(m);
        }
Exemple #10
0
 public void ReadFromDsgMemBufferInitial(Reader reader, DsgVarInfoEntry infoEntry, DsgMem dsgMem)
 {
     currentbuf = "dsgmem_initial";
     ReadFromBuffer(reader, infoEntry, dsgMem.memBufferInitial);
 }
Exemple #11
0
 public DsgVarValue(DsgVarInfoEntry.DsgVarType type, DsgMem dsgMem)
 {
     this.type   = type;
     this.dsgMem = dsgMem;
 }
Exemple #12
0
        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);
        }
Exemple #13
0
 public object ReadInitialValueFromDsgMemBuffer(Reader reader, DsgVarInfoEntry infoEntry, DsgMem dsgMem)
 {
     return(ReadValueFromBuffer(reader, infoEntry, dsgMem.memBufferInitial));
 }
Exemple #14
0
 public object ReadValueFromDsgMemBuffer(EndianBinaryReader reader, DsgVarInfoEntry infoEntry, DsgMem dsgMem)
 {
     return(ReadValueFromBuffer(reader, infoEntry, dsgMem.memBuffer));
 }