Example #1
0
        public virtual bool ReadPackets(ChunkArchive reader)
        {
            uint seenLevelIndex = 0;

            while (true)
            {
                if (HasLevelStreamingFixes())
                {
                    seenLevelIndex = reader.ReadIntPacked();
                }
                var result = ParsePacket(reader);
                switch (result)
                {
                case ReadPacketState.Success:
                    return(true);   //TO REMOVE

                    continue;

                case ReadPacketState.End:
                    return(true);

                case ReadPacketState.Error:
                    return(false);

                default:
                    throw new InvalidOperationException();
                }
            }//There is more data ?
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
0
        public virtual bool NetFieldExportGroupMap(ChunkArchive binaryReader)
        {
            uint numNetFieldExportGroups = binaryReader.ReadUInt32();

            for (int i = 0; i < numNetFieldExportGroups; i++)
            {
                ParseNetFieldExportGroup(binaryReader);
            }
            return(true);
        }
Example #5
0
 public virtual bool ParseReplayData(ChunkArchive streamReader)
 {
     while (streamReader.Length > streamReader.Offset)
     {
         if (!ParsePlaybackPacket(streamReader))
         {
             return(false);
         }
     }
     return(true);
 }
Example #6
0
        public virtual bool ParseNetFieldExportGroup(ChunkArchive ar)
        {
            string a         = ar.ReadString();
            uint   packedInt = ar.ReadIntPacked();
            uint   count     = ar.ReadIntPacked();

            for (int i = 0; i < count; i++)
            {
                ar.ReadNetFieldExport();
            }
            return(true);
        }
Example #7
0
 /// <summary>
 /// https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp#L2106
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 public virtual bool ParseExternalData(ChunkArchive reader)
 {
     while (true)
     {
         uint externalDataBitsCount = reader.ReadIntPacked();
         if (externalDataBitsCount == 0)
         {
             return(true);
         }
         uint netGuid = reader.ReadIntPacked();
         reader.ReadBytes((int)(externalDataBitsCount + 7) >> 3);  //TODO: We dont do anything with it yet. We burn byte now.
     }
 }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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));
        }
Example #11
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);
        }
Example #12
0
        public virtual bool ParseNetFieldExports(ChunkArchive reader)
        {
            uint exportCount = reader.ReadIntPacked();

            for (int i = 0; i < exportCount; i++)
            {
                uint pathNameIndex = reader.ReadIntPacked();
                uint wasExported   = reader.ReadIntPacked();
                if (wasExported > 0)
                {
                    string pathName   = reader.ReadString();
                    uint   numExports = reader.ReadIntPacked();
                }
                else
                {
                    //We does nothing here but Unreal does something
                }
                var netExports = reader.ReadNetFieldExport();
            }
            return(true);
        }
Example #13
0
 /// <summary>
 /// https://github.com/EpicGames/UnrealEngine/blob/70bc980c6361d9a7d23f6d23ffe322a2d6ef16fb/Engine/Source/Runtime/Engine/Private/PackageMapClient.cpp#L1348
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 public virtual bool ParseExportData(ChunkArchive reader)
 {
     return(ParseNetFieldExports(reader) &&
            ParseNetExportGUIDs(reader));
 }