Skip to content

Commit

Permalink
Merge pull request #110 from koliva8245/battlelobby-parse-ai
Browse files Browse the repository at this point in the history
Battelobby will now parse AI games
  • Loading branch information
barrett777 authored Jun 17, 2020
2 parents 83638ae + 447e1f5 commit 8acd023
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Heroes.ReplayParser/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static void ParseReplayArchive(Replay replay, MpqArchive archive, ParseO
player.Talents = talentGameEventsDictionary[player];
}
// Replay Server Battlelobby
if (!parseOptions.IgnoreErrors && archive.Any(i => i.Filename == ReplayServerBattlelobby.FileName))
if (archive.Any(i => i.Filename == ReplayServerBattlelobby.FileName))
{
if (parseOptions.ShouldParseDetailedBattleLobby)
ReplayServerBattlelobby.Parse(replay, GetMpqFile(archive, ReplayServerBattlelobby.FileName));
Expand Down
12 changes: 8 additions & 4 deletions Heroes.ReplayParser/MPQFiles/ReplayInitData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,22 @@ public static void Parse(Replay replay, byte[] buffer)
if (replay.ReplayBuild >= 43905 && reader.ReadBoolean())
switch (reader.ReadInt32())
{
case 50021: // Versus AI (Cooperative)
case 50041: // Practice
break;

case 50001:
replay.GameMode = GameMode.QuickMatch;
break;

case 50021:
replay.GameMode = GameMode.Cooperative;
break;

case 50031:
replay.GameMode = GameMode.Brawl;
break;

case 50041:
replay.GameMode = GameMode.TryMe;
break;

case 50051:
replay.GameMode = GameMode.UnrankedDraft;
break;
Expand Down
26 changes: 11 additions & 15 deletions Heroes.ReplayParser/MPQFiles/ReplayServerBattlelobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ private static void DetailedParse(BitReader bitReader, Replay replay, uint s2maC
bitReader.ReadBytes(25);
bitReader.Read(24);

// bitReader.ReadBytes(8); ai games have 8 more bytes somewhere around here
if (replay.GameMode == GameMode.Cooperative)
bitReader.ReadBytes(8); // ai games have 8 more bytes somewhere around here

bitReader.Read(7);

Expand All @@ -190,24 +191,19 @@ private static void DetailedParse(BitReader bitReader, Replay replay, uint s2maC
// repeat of the collection section above
if (replay.ReplayBuild >= 51609 || replay.ReplayBuild == 47903 || replay.ReplayBuild == 47479)
{
uint size = bitReader.Read(12);

int bytesSize = (int)(size / 8);
int bitsSize = (int)(size % 8);

bitReader.ReadBytes(bytesSize);
bitReader.Read(bitsSize);

bitReader.ReadBoolean();
bitReader.ReadBitArray(bitReader.Read(12));
}
else
else if (replay.ReplayBuild > 47219)
{
bitReader.Read(1);
uint size = bitReader.Read(15);

// each byte has a max value of 0x7F (127)
bitReader.ReadBytes((int)size * 2);
bitReader.ReadBytes((int)bitReader.Read(15) * 2);
}
else
{
bitReader.ReadBitArray(bitReader.Read(9));
}

bitReader.ReadBoolean();
}

bitReader.ReadBoolean(); // m_hasSilencePenalty
Expand Down

0 comments on commit 8acd023

Please sign in to comment.