Esempio n. 1
0
        public static ReplayHeader FromStream(ReplayReader stream)
        {
            var header = new ReplayHeader
            {
                Version      = stream.ReadLuaString(),
                Unknown      = stream.ReadLuaString(),
                Map          = stream.ReadLuaString(),
                Unknown2     = stream.ReadLuaString(),
                NumMods      = stream.ReadUInt32(),
                Mods         = stream.ReadLua(),
                ScenarioSize = stream.ReadUInt32(),
                Scenario     = stream.ReadLua(),
                NumSources   = stream.ReadByte()
            };

            for (var i = 0; i < header.NumSources; i++)
            {
                var name = stream.ReadLuaString();
                header.Timeouts[name] = stream.ReadInt32();
            }
            header.Cheats    = stream.ReadByte() != 0;
            header.NumArmies = stream.ReadByte();

            for (var i = 0; i < header.NumArmies; i++)
            {
                var     n    = stream.ReadUInt32();
                dynamic data = stream.ReadLua();
                data["SourceId"] = stream.ReadByte();
                header.Armies.Add(data);
                header.CommandSources.Add(data["SourceId"]);
                if (stream.PeekByte() == 0xff) // some unknown weirdness in format
                {
                    stream.ReadByte();
                }
            }

            header.Random = stream.ReadUInt32();

            return(header);
        }
Esempio n. 2
0
 private ReplayHeader parseHeader()
 {
     return(ReplayHeader.FromStream(_stream));
 }