Skip to content

Commit

Permalink
Merge pull request #118 from koliva8245/disabledheroes
Browse files Browse the repository at this point in the history
Updated for disabled heroes
  • Loading branch information
barrett777 authored Jun 20, 2021
2 parents 1ceb8fd + a8937f8 commit 99ef994
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Heroes.ReplayParser/MPQFiles/ReplayInitData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,9 @@ public static void Parse(Replay replay, byte[] buffer)
// m_disabledHeroList
var disabledHeroListLength = reader.Read(10);

// TODO: This has been '0' in all my games, so nothing to see here
// I'm not sure what it is for. Maybe it is just for ranked games, or something yet to be implemented in the game client
for (var i = 0; i < disabledHeroListLength; i++)
{
var disabledHero = new string(BitConverter.GetBytes(reader.Read(32)).Select(k => (char)k).Reverse().ToArray());
replay.DisabledHeroes.Add(reader.ReadStringFromBits(32, true));
}
}

Expand Down
13 changes: 12 additions & 1 deletion Heroes.ReplayParser/MPQFiles/ReplayServerBattlelobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ private static void DetailedParse(BitReader bitReader, Replay replay, uint s2maC
}

if (replay.ReplayBuild >= 85027)
bitReader.ReadByte(); // could contain m_disabledHeroList
{
// m_disabledHeroList
uint disabledHeroListLength = bitReader.Read(8);

for (int i = 0; i < disabledHeroListLength; i++)
{
string disabledHeroAttributeId = bitReader.ReadStringFromBits(32, true);

if (replay.DisabledHeroes.Count == 0)
replay.DisabledHeroes.Add(disabledHeroAttributeId);
}
}

// Player info
// ------------------------
Expand Down
3 changes: 3 additions & 0 deletions Heroes.ReplayParser/Replay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public class Replay
/// <summary> Gets the draft order. Picks, bans, and swaps. </summary>
public List<DraftPick> DraftOrder { get; set; } = new List<DraftPick>();

/// <summary> Gets the disabled heroes as attributeIds. </summary>
public List<string> DisabledHeroes { get; set; } = new List<string>();

public bool IsGameEventsParsedSuccessfully { get; set; } = false;
public bool? IsStatisticsParsedSuccessfully { get; set; } = null;
}
Expand Down

0 comments on commit 99ef994

Please sign in to comment.