Ejemplo n.º 1
0
        public virtual bool ParseCheckpointContent(ChunkArchive ar, string id, string group, string metadata, uint time1, uint time2)
        {
            if ((DemoHeader !.HeaderFlags & DemoHeader.ReplayHeaderFlags.HasStreamingFixes) > 0)
            {
                long packetOffset = ar.ReadInt64();
            }
            if (DemoHeader !.NetworkVersion >= NetworkVersionHistory.multipleLevels)
            {
                int levelForCheckpoint = ar.ReadInt32();
            }

            if (DemoHeader !.NetworkVersion >= NetworkVersionHistory.deletedStartupActors)
            {
                string[] deletedNetStartupActors = ar.ReadArray(ar.ReadString);
            }

            int valuesCount = ar.ReadInt32();

            for (int i = 0; i < valuesCount; i++)
            {
                uint   guid      = ar.ReadIntPacked();
                uint   outerGuid = ar.ReadIntPacked();
                string path      = ar.ReadString();
                uint   checksum  = ar.ReadUInt32();
                byte   flags     = ar.ReadByte();
            }
            NetFieldExportGroupMap(ar);
            ParsePlaybackPacket(ar);
            // File.WriteAllBytes( "dump.dump", binaryReader.DumpRemainingBytes() );
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// https://github.com/EpicGames/UnrealEngine/blob/70bc980c6361d9a7d23f6d23ffe322a2d6ef16fb/Engine/Source/Runtime/Engine/Private/PackageMapClient.cpp#L1579
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public virtual bool ParseNetExportGUIDs(ChunkArchive reader)
        {
            uint guidCount = reader.ReadIntPacked();

            for (int i = 0; i < guidCount; i++)
            {
                reader.ReadBytes(reader.ReadInt32());  //burn.
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Was writed to support how Fortnite store replays.
        /// This may need to be upgrade to support other games, or some future version of Fortnite.
        /// </summary>
        /// <param name="binaryReader"></param>
        /// <param name="replayDataInfo"></param>
        /// <returns></returns>
        public virtual bool ParsePlaybackPacket(ChunkArchive reader)
        {
            bool  appendPacket           = true;
            bool  hasLevelStreamingFixes = true;               //TODO: this method
            int   currentLevelIndex      = reader.ReadInt32(); //TODO: use replayVersion. HasLevelStreamingFixes
            float timeSeconds            = reader.ReadSingle();

            if (float.IsNaN(timeSeconds))
            {
                throw new InvalidDataException();
            }
            ParseExportData(reader);  //TODO: use replayVersion. HasLevelStreamingFixes
            if (HaveLevelStreamingFixes())
            {
                uint streamingLevelscount = reader.ReadIntPacked();
                for (int i = 0; i < streamingLevelscount; i++)
                {
                    string levelName = reader.ReadString();
                }
            }
            else
            {
                throw new NotSupportedException("TODO");
            }
            long skipExternalOffset = 0;

            if (HaveLevelStreamingFixes())
            {
                skipExternalOffset = reader.ReadInt64();
            }
            else
            {
                throw new NotImplementedException();
            }

            ParseExternalData(reader);
            uint seenLevelIndex = 0;

            //while( true )
            //{
            //    if( hasLevelStreamingFixes )
            //    {
            //        seenLevelIndex = reader.ReadIntPacked();
            //    }
            //    int amount = ParsePacket( reader );
            //    if( amount == 0 ) break;
            //    if( appendPacket ) continue;
            //}//There is more data ?
            return(true);
        }
Ejemplo n.º 4
0
        public virtual int ParsePacket(ChunkArchive reader)
        {
            const int MaxBufferSize = 2 * 1024;
            int       outBufferSize = reader.ReadInt32();

            if (outBufferSize > MaxBufferSize || outBufferSize < 0)
            {
                throw new InvalidDataException("Invalid packet size");
            }
            if (outBufferSize == 0)
            {
                return(outBufferSize);
            }
            var outBuffer = reader.ReadBytes(outBufferSize);

            ProcessRawPacket(new BitReader(outBuffer.ToArray()));     //TODO avoid array alloc
            return(outBufferSize);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Was writed to support how Fortnite store replays.
        /// This may need to be upgrade to support other games, or some future version of Fortnite.
        /// https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp#L2848
        /// </summary>
        /// <param name="binaryReader"></param>
        /// <param name="replayDataInfo"></param>
        /// <returns></returns>
        public virtual bool ParsePlaybackPacket(ChunkArchive reader)
        {
            if (DemoHeader !.NetworkVersion >= DemoHeader.NetworkVersionHistory.multipleLevels)
            {
                int currentLevelIndex = reader.ReadInt32();
            }
            float timeSeconds = reader.ReadSingle();

            if (float.IsNaN(timeSeconds))
            {
                throw new InvalidDataException();
            }
            if (DemoHeader !.NetworkVersion >= DemoHeader.NetworkVersionHistory.levelStreamingFixes)
            {
                ParseExportData(reader);
            }
            if (HasLevelStreamingFixes())
            {
                uint streamingLevelscount = reader.ReadIntPacked();
                for (int i = 0; i < streamingLevelscount; i++)
                {
                    string levelName = reader.ReadString();
                }
            }
            else
            {
                throw new NotSupportedException("TODO");
            }
            long skipExternalOffset = 0;

            if (HasLevelStreamingFixes())
            {
                skipExternalOffset = reader.ReadInt64();
            }
            else
            {
                throw new NotImplementedException();
            }

            ParseExternalData(reader);
            return(ReadPackets(reader));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp#L3220
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public virtual ReadPacketState ParsePacket(ChunkArchive reader)
        {
            const int MaxBufferSize = 2 * 1024;
            int       bufferSize    = reader.ReadInt32();

            if (bufferSize > MaxBufferSize || bufferSize < 0)
            {
                return(ReadPacketState.Error);
            }
            if (bufferSize == 0)
            {
                return(ReadPacketState.End);
            }
            var buffer = reader.HeapReadBytes(bufferSize);

            if (ProcessRawPacket(new BitArchive(buffer, DemoHeader !, ReplayHeader !)))
            {
                return(ReadPacketState.Success);
            }
            return(ReadPacketState.Error);
        }