예제 #1
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     _ = r.ReadInt32();
     _ = r.ReadIdent();
     _ = r.ReadInt32();
     _ = r.ReadInt32();
 }
예제 #2
0
    private NadeoPakFolder[] ReadFolders(GameBoxReader r)
    {
        var numFolders = r.ReadInt32();
        var folders    = new NadeoPakFolder[numFolders];

        for (var i = 0; i < numFolders; i++)
        {
            var parentFolderIndex = r.ReadInt32(); // index into folders; -1 if this is a root folder
            var name = r.ReadString();

            var folder = new NadeoPakFolder(name, parentFolderIndex == -1 ? null : folders[parentFolderIndex]);

            if (parentFolderIndex == -1)
            {
                Folders.Add(folder);
            }
            else
            {
                folders[parentFolderIndex].Folders.Add(folder);
            }

            folders[i] = folder;
        }

        if (folders.Length > 2 && folders[2].Name.Length > 4)
        {
            byte[] nameBytes = Encoding.Unicode.GetBytes(folders[2].Name);
            blowfish.Initialize(nameBytes, 4, 4);
        }

        return(folders);
    }
예제 #3
0
 public override void Read(CGameCtnCollection n, GameBoxReader r)
 {
     _ = r.ReadInt32();
     _ = r.ReadIdent();
     _ = r.ReadInt32();
     _ = r.ReadInt32();
 }
예제 #4
0
    private void ReadEncrypted(GameBoxReader r)
    {
        var headerMD5 = r.ReadBytes(16);

        MetadataStart = r.ReadInt32(); // offset to metadata section
        DataStart     = r.ReadInt32();

        if (Version >= 2)
        {
            var gbxHeadersSize      = r.ReadInt32();
            var gbxHeadersComprSize = r.ReadInt32();
        }

        if (Version >= 3)
        {
            r.ReadBytes(16); // unused
        }
        var flags = r.ReadInt32();

        var folders = ReadFolders(r);

        ReadFiles(r, folders);

        ReadMetadata();
    }
예제 #5
0
 public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
 {
     Version  = r.ReadInt32();
     n.ghosts = r.ReadArray(r1 => r1.ReadNodeRef <CGameCtnGhost>() !);
     U01      = r.ReadInt32();
     n.extras = r.ReadArray(r1 => r1.ReadInt64());
 }
예제 #6
0
            public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW)
            {
                n.Keys = r.ReadArray(i =>
                {
                    var time           = r.ReadSingle();
                    var position       = r.ReadVec3();
                    var pitchYawRoll   = r.ReadVec3(); // in radians
                    var fov            = r.ReadSingle();
                    var anchorRot      = r.ReadBoolean();
                    var anchor         = r.ReadInt32();
                    var anchorVis      = r.ReadBoolean();
                    var target         = r.ReadInt32();
                    var targetPosition = r.ReadVec3();
                    var a = r.ReadSingle(); // 1
                    var b = r.ReadSingle(); // -0.48
                    var c = r.ReadSingle(); // 0
                    var d = r.ReadSingle(); // 0
                    var e = r.ReadSingle();

                    return(new Key()
                    {
                        Time = time,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,
                        AnchorRot = anchorRot,
                        Anchor = anchor,
                        AnchorVis = anchorVis,
                        Target = target,
                        TargetPosition = targetPosition,
                        Unknown = new object[] { a, b, c, d, e }
                    });
                });
            }
예제 #7
0
            public override void Read(CGameCtnMediaClipGroup n, GameBoxReader r, GameBoxWriter unknownW)
            {
                Version = r.ReadInt32();

                var clips = r.ReadArray(i => r.ReadNodeRef<CGameCtnMediaClip>());
                var triggers = r.ReadArray(i =>
                {
                    var coords = r.ReadArray(j => r.ReadInt3());
                    var u01 = r.ReadInt32();
                    var u02 = r.ReadInt32();
                    var u03 = r.ReadInt32();
                    var u04 = r.ReadInt32();

                    return new Trigger()
                    {
                        Coords = coords,
                        U01 = u01,
                        U02 = u02,
                        U03 = u03,
                        U04 = u04
                    };
                });

                n.Clips = clips.Select((clip, index) =>
                    Tuple.Create(clip, triggers[index])
                ).ToList();
            }
예제 #8
0
 public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
 {
     n.game = r.ReadString();
     U01    = r.ReadInt32();
     U02    = r.ReadInt32();
     U03    = r.ReadInt32();
     U04    = r.ReadString();
 }
예제 #9
0
 public override void Read(CGameCtnCollection n, GameBoxReader r)
 {
     _         = r.ReadId();
     _         = r.ReadInt32();
     _         = r.ReadArray(r1 => r1.ReadInt32());
     _         = r.ReadInt32();
     _         = r.ReadArray <float>(3);
     n.Vehicle = r.ReadIdent();
 }
예제 #10
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     _         = r.ReadId();
     _         = r.ReadInt32();
     _         = r.ReadArray(x => r.ReadInt32());
     _         = r.ReadInt32();
     _         = r.ReadArray <float>(3);
     n.Vehicle = r.ReadIdent();
 }
예제 #11
0
 public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
 {
     Version           = r.ReadInt32();
     n.authorVersion   = r.ReadInt32();
     n.authorLogin     = r.ReadString();
     n.authorNickname  = r.ReadString();
     n.authorZone      = r.ReadString();
     n.authorExtraInfo = r.ReadString();
 }
예제 #12
0
    /// <exception cref="TextFormatNotSupportedException">Text-formatted GBX files are not supported.</exception>
    internal bool Read(GameBoxReader reader)
    {
        if (!reader.HasMagic(GameBox.Magic))
        {
            Log.Write("GBX magic missing! Corrupted file or not a GBX file.", ConsoleColor.Red);
            return(false);
        }

        Log.Write("GBX recognized!", ConsoleColor.Green);

        Version = reader.ReadInt16();
        Log.Write("- Version: " + Version.ToString());

        if (Version >= 3)
        {
            ByteFormat = (GameBoxByteFormat)reader.ReadByte();
            Log.Write("- Byte format: " + ByteFormat.ToString());

            if (ByteFormat == GameBoxByteFormat.Text)
            {
                throw new TextFormatNotSupportedException();
            }

            CompressionOfRefTable = (GameBoxCompression)reader.ReadByte();
            Log.Write("- Ref. table compression: " + CompressionOfRefTable.ToString());

            CompressionOfBody = (GameBoxCompression)reader.ReadByte();
            Log.Write("- Body compression: " + CompressionOfBody.ToString());

            if (Version >= 4)
            {
                UnknownByte = (char)reader.ReadByte();
                Log.Write("- Unknown byte: " + UnknownByte.ToString());
            }

            ID = CMwNod.Remap(reader.ReadUInt32());
            Log.Write("- Class ID: 0x" + ID.Value.ToString("X8"));

            if (Version >= 6)
            {
                var userDataSize = reader.ReadInt32();
                Log.Write($"- User data size: {(userDataSize / 1024f).ToString()} kB");

                if (userDataSize > 0)
                {
                    UserData = reader.ReadBytes(userDataSize);
                }
            }

            NumNodes = reader.ReadInt32();
            Log.Write("- Number of nodes: " + NumNodes.ToString());
        }

        Log.Write("Header completed!", ConsoleColor.Green);

        return(true);
    }
예제 #13
0
        public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
        {
            Version = r.ReadInt32();
            var u02 = r.ReadInt32();

            n.ghosts = r.ReadArray(r1 => r1.ReadNodeRef <CGameCtnGhost>() !);

            var u03 = r.ReadInt32(); // millisecond length of something (usually record time + 0.5s)
            var u04 = r.ReadInt32();
        }
예제 #14
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var unknown = r.ReadArray(i =>
                {
                    return(new object[]
                    {
                        r.ReadInt32(),
                        r.ReadArray(j => r.ReadIdent()),

                        r.ReadInt32(),
                        r.ReadInt32(),
                        r.ReadInt32()
                    });
                });
            }
예제 #15
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r)
            {
                var version = r.ReadInt32();
                var nodrefs = r.ReadArray(r1 => r1.ReadNodeRef());

                r.ReadArray <int>(2);
            }
예제 #16
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var version = r.ReadInt32();
                var nodrefs = r.ReadArray(i => r.ReadNodeRef());

                r.ReadArray <int>(2);
            }
예제 #17
0
            public override void Read(CGameCtnReplayRecord n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var size = r.ReadInt32();

                if (size > 0)
                {
                    var trackGbx = r.ReadBytes(size);

                    n.Challenge = Task.Run(() =>
                    {
                        using (var ms = new MemoryStream(trackGbx))
                            return(GameBox.Parse <CGameCtnChallenge>(ms));
                    });

                    n.Challenge.ContinueWith(x =>
                    {
#if DEBUG
                        if (x.IsFaulted)
                        {
                            var e = x.Exception.InnerException;
                            Debug.WriteLine(e.Message);
                            Debug.WriteLine(e.StackTrace);
                        }
#endif
                    });
                }
            }
예제 #18
0
        public override void Read(CGameCtnMediaClipGroup n, GameBoxReader r)
        {
            n.ClipsVersion = r.ReadInt32();

            var clips    = r.ReadArray(r1 => r1.ReadNodeRef <CGameCtnMediaClip>() !);
            var triggers = r.ReadArray(r1 =>
            {
                var u01            = r1.ReadInt32();
                var u02            = r1.ReadInt32();
                var u03            = r1.ReadInt32();
                var u04            = r1.ReadInt32();
                var condition      = (ECondition)r1.ReadInt32();
                var conditionValue = r1.ReadSingle();
                var coords         = r1.ReadArray(r2 => r2.ReadInt3());

                return(new Trigger()
                {
                    Coords = coords,
                    U01 = u01,
                    U02 = u02,
                    U03 = u03,
                    U04 = u04,
                    Condition = condition,
                    ConditionValue = conditionValue
                });
            });

            n.Clips = clips.Select((clip, index) =>
                                   new ClipTrigger(clip, triggers[index])
                                   ).ToList();
        }
예제 #19
0
            public override void Read(CGameCtnReplayRecord n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var v = r.ReadInt32();

                if (v != 0)
                {
                    r.ReadInt32();
                    var controlNames = r.ReadArray(i =>
                    {
                        r.ReadInt32();
                        r.ReadInt32();
                        return(r.ReadString());
                    });

                    var numControlEntries = r.ReadInt32() - 1;
                    var controlEntries    = new (int, int, int)[numControlEntries];
예제 #20
0
        public override void Read(CGameCtnBlockInfoMobil n, GameBoxReader r)
        {
            U01 = r.ReadInt32();
            U02 = r.ReadInt32();

            n.DynaLinks = r.ReadArray(r =>
            {
                var u01      = r.ReadInt32();
                var u02      = r.ReadInt32();
                var u03      = r.ReadInt32();
                var socketID = r.ReadId();
                var model    = r.ReadNodeRef <CGameObjectModel>();

                return(new CGameCtnBlockInfoMobilLink(socketID, model));
            });
        }
예제 #21
0
        public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
        {
            var size = r.ReadInt32();

            if (size <= 0)
            {
                throw new Exception();
            }

            var trackGbx = r.ReadBytes(size);

            n.challenge = Task.Run(() =>
            {
                using var ms = new MemoryStream(trackGbx);
                return(GameBox.ParseNode <CGameCtnChallenge>(ms));
            });

#if DEBUG
            n.challenge.ContinueWith(x =>
            {
                if (!x.IsFaulted)
                {
                    return;
                }

                var e = x.Exception?.InnerException;
                Debug.WriteLine(e?.Message);
                Debug.WriteLine(e?.StackTrace);
            });
#endif
        }
예제 #22
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     _ = r.ReadByte();
     _ = r.ReadString();
     _ = r.ReadInt32();
     _ = r.ReadString();
     _ = r.ReadArray <int>(3);
 }
            public override void Read(CGameCtnMediaBlockCameraCustom n, GameBoxReader r, GameBoxWriter unknownW)
            {
                n.Keys = r.ReadArray(i =>
                {
                    var time         = r.ReadSingle();
                    var u01          = r.ReadInt32(); // 1
                    var u02          = r.ReadInt32(); // 0
                    var u03          = r.ReadInt32(); // 0
                    var position     = r.ReadVec3();
                    var pitchYawRoll = r.ReadVec3();  // in radians
                    var fov          = r.ReadSingle();
                    var u04          = r.ReadInt32(); // 0
                    var u05          = r.ReadInt32(); // -1
                    var u06          = r.ReadInt32(); // 1
                    var u07          = r.ReadInt32(); // -1
                    var u08          = r.ReadSingle();
                    var u09          = r.ReadSingle();
                    var u10          = r.ReadSingle();
                    var u11          = r.ReadSingle();
                    var u12          = r.ReadSingle();

                    return(new Key()
                    {
                        Time = time,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,

                        Unknown = new object[]
                        {
                            u01, u02, u03, u04, u05, u06, u07, u08, u09, u10, u11, u12
                        }
                    });
                }).ToList();
            }
예제 #24
0
            public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
            {
                n.eventsDuration = r.ReadInt32();

                if (n.eventsDuration != 0)
                {
                    U01 = r.ReadInt32();

                    var controlNames = r.ReadArray(r1 => r1.ReadId());

                    var numEntries = r.ReadInt32();
                    U02 = r.ReadInt32();

                    n.controlEntries = new ControlEntry[numEntries];

                    for (var i = 0; i < numEntries; i++)
                    {
                        var time             = TimeSpan.FromMilliseconds(r.ReadInt32() - 100000);
                        var controlNameIndex = r.ReadByte();
                        var data             = r.ReadUInt32();

                        var name = controlNames[controlNameIndex];

                        switch (name)
                        {
                        case "Steer":
                        case "Gas":
                        case "AccelerateReal":
                        case "BrakeReal":
                            n.controlEntries[i] = new ControlEntryAnalog()
                            {
                                Name = name, Time = time, Data = data
                            };
                            break;

                        default:
                            n.controlEntries[i] = new ControlEntry()
                            {
                                Name = name, Time = time, Data = data
                            };
                            break;
                        }
                    }
                }
            }
예제 #25
0
            public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW)
            {
                Version = r.ReadInt32();

                n.Keys = r.ReadArray(i =>
                {
                    var time         = r.ReadSingle();
                    var position     = r.ReadVec3();
                    var pitchYawRoll = r.ReadVec3(); // in radians
                    var fov          = r.ReadSingle();

                    float?nearZ = null;
                    if (Version >= 3)
                    {
                        nearZ = r.ReadSingle();
                    }
                    var anchorRot      = r.ReadBoolean();
                    var anchor         = r.ReadInt32();
                    var anchorVis      = r.ReadBoolean();
                    var target         = r.ReadInt32();
                    var targetPosition = r.ReadVec3();

                    var unknown = r.ReadArray <float>(5).Cast <object>().ToList();

                    if (Version >= 4)
                    {
                        unknown.AddRange(r.ReadArray <int>(2).Cast <object>());
                    }

                    return(new Key()
                    {
                        Time = time,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,
                        NearZ = nearZ,
                        AnchorRot = anchorRot,
                        Anchor = anchor,
                        AnchorVis = anchorVis,
                        Target = target,
                        TargetPosition = targetPosition,
                        Unknown = unknown.Cast <object>().ToArray()
                    });
                });
            }
예제 #26
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     Version        = r.ReadByte();
     n.CollectionID = r.ReadByte();
     _ = r.ReadBytes(6);
     n.CollectionPackMask = r.ReadByte();
     n.DisplayName        = r.ReadString();
     _ = r.ReadInt32();
     n.CollectionIcon = r.ReadString();
     _ = r.ReadArray <int>(2);
     n.BlockInfoFlat = r.ReadId(this);
     n.Vehicle       = r.ReadIdent(this);
     _ = r.ReadInt32();
     _ = r.ReadArray <float>(4);
     n.LoadingScreen = r.ReadString();
     _ = r.ReadArray <int>(7);
     _ = r.ReadString();
     _ = r.ReadInt32();
 }
예제 #27
0
        public override void Read(CGameNetOnlineMessage n, GameBoxReader r)
        {
            n.ReceiverLogin = r.ReadString();
            n.SenderLogin   = r.ReadString();
            n.Subject       = r.ReadString();
            n.Message       = r.ReadString();
            n.Donation      = r.ReadInt32();
            U01             = r.ReadInt32();

            var date   = r.ReadInt64();
            var year   = (int)(date & 0xFFFF);
            var month  = (int)((date >> 16) & 0xF);
            var day    = (int)((date >> 23) & 0xF);
            var hour   = (int)((date >> 32) & 0x1F);
            var minute = (int)((date >> 37) & 0x3F);
            var second = (int)((date >> 43) & 0x3F);

            n.Date = new DateTime(year, month, day, hour, minute, second);
        }
예제 #28
0
        public override void Read(CGameCtnReplayRecord n, GameBoxReader r)
        {
            n.eventsDuration = r.ReadInt32();

            if (n.eventsDuration == 0)
            {
                return;
            }

            U01 = r.ReadInt32();

            var controlNames = r.ReadArray(r1 => r1.ReadId());

            var numEntries = r.ReadInt32();

            U02 = r.ReadInt32();

            n.controlEntries = new ControlEntry[numEntries];

            for (var i = 0; i < numEntries; i++)
            {
                var time             = TimeSpan.FromMilliseconds(r.ReadInt32() - 100000);
                var controlNameIndex = r.ReadByte();
                var data             = r.ReadUInt32();

                var name = controlNames[controlNameIndex];

                n.controlEntries[i] = (string)name switch
                {
                    "Steer" or "Gas" or "AccelerateReal" or "BrakeReal"
                    => new ControlEntryAnalog(name)
                    {
                        Time = time, Data = data
                    },
                    _ => new ControlEntry(name)
                    {
                        Time = time, Data = data
                    },
                };
            }
        }
예제 #29
0
    internal static T?[] ParseArray <T>(GameBoxReader r) where T : CMwNod
    {
        var count = r.ReadInt32();
        var array = new T?[count];

        for (var i = 0; i < count; i++)
        {
            array[i] = Parse <T>(r);
        }

        return(array);
    }
예제 #30
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var unknown = r.ReadArray(i =>
                {
                    var version = r.ReadInt32();
                    if (r.ReadNodeRef() != null)
                    {
                        throw new NotImplementedException();
                    }

                    if (version == 0)
                    {
                        r.ReadInt32();
                        r.ReadInt32();
                        r.ReadInt32();
                    }

                    r.ReadInt32();

                    return(new object());
                });
            }