Replay reader reads the hardcoded struct layout and assumes that the startscript is directly behind it:
|
var header = br.ReadStruct<DemoFileHeader>(); |
|
|
|
var script = Encoding.UTF8.GetString(br.ReadBytes(header.scriptSize)); |
If engine adds new members to the struct (planned in the near-ish future) then this will break. The header contains a headerSize member to solve this though (and a version member in the stronger case when members get added anywhere else than at the end):
|
public int headerSize; // Size of the DemoFileHeader, minor version number. |
So there should be something like
var header = br.ReadStruct<DemoFileHeader>();
+if (header.version != 5)
+ throw new NotSupportedException();
+
+const var expectedSize = Marshal.SizeOf(header);
+if (header.headerSize > expectedSize)
+ br.ReadBytes(header.headerSize - expectedSize);
var script = Encoding.UTF8.GetString(br.ReadBytes(header.scriptSize));
Replay reader reads the hardcoded struct layout and assumes that the startscript is directly behind it:
Zero-K-Infrastructure/Shared/PlasmaShared/ReplayReader.cs
Lines 79 to 81 in 2b842c3
If engine adds new members to the struct (planned in the near-ish future) then this will break. The header contains a
headerSizemember to solve this though (and aversionmember in the stronger case when members get added anywhere else than at the end):Zero-K-Infrastructure/Shared/PlasmaShared/ReplayReader.cs
Line 49 in 2b842c3
So there should be something like