Skip to content

Commit

Permalink
Fix TMUnlimiter 2 block parse issue with v2+
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Jul 3, 2024
1 parent ca7b4c6 commit a9eea4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
5 changes: 3 additions & 2 deletions Src/GBX.NET/Engines/Game/CGameCtnBlock.chunkl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ archive
short Flags
v1+
int Flags
if Flags == -1
return
v2+
if Flags == -1
return
if (Flags & (1 << 15)) != 0
id Author
CGameCtnBlockSkin Skin
Expand Down
28 changes: 1 addition & 27 deletions Src/GBX.NET/Engines/Game/CGameCtnChallenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,6 @@ public partial class Chunk0304301F : IVersionable
public bool U01;
public ulong? U02;

public bool IsUnlimiter2 { get; set; }

public override void Read(CGameCtnChallenge n, GbxReader r)
{
n.mapInfo = r.ReadIdent();
Expand All @@ -752,36 +750,17 @@ public override void Read(CGameCtnChallenge n, GbxReader r)
var nbBlocks = r.ReadInt32();
n.blocks = new List<CGameCtnBlock>(nbBlocks);

var isUnlimiter = default(bool?);

for (var i = 0; i < nbBlocks; i++)
{
var block = r.ReadReadable<CGameCtnBlock>(Version);
n.blocks.Add(block);

if (block.Flags != -1)
{
continue;
}

isUnlimiter ??= block.Name.StartsWith("TMUnlimiter 2");

if (isUnlimiter.Value)
{
IsUnlimiter2 = isUnlimiter.Value;
}
else
if (block.Flags == -1)
{
i--;
}
}

if (IsUnlimiter2)
{
U02 = r.ReadUInt64();
return;
}

while ((r.PeekUInt32() & 0xC0000000) > 0)
{
n.blocks.Add(r.ReadReadable<CGameCtnBlock>(Version));
Expand All @@ -808,11 +787,6 @@ public override void Write(CGameCtnChallenge n, GbxWriter w)
{
w.WriteWritable(block, Version);
}

if (IsUnlimiter2)
{
w.Write(U02.GetValueOrDefault());
}
}
}

Expand Down

0 comments on commit a9eea4d

Please sign in to comment.