Skip to content

Commit

Permalink
Fix reading pre-game lobby chat in HD Edition. Fixes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Dec 8, 2016
1 parent 5035738 commit 2621ef9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Analyzers/HeaderAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ protected function run()
$this->position += 1;
}

if ($version->isHDEdition) {
$this->position += 4;
}

$pregameChat = [];
if ($version->isMgx) {
$pregameChat = $this->readChat($playersByIndex);
Expand Down
18 changes: 18 additions & 0 deletions test/HeaderAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ public function testAoe2RecordVictorySettings()
$this->assertAttributeEquals(9000, 'timeLimit', $analysis->victory);
}

/**
* @dataProvider chatCountsProvider
*/
public function testChat($file, $expectedCount)
{
$rec = $this->load($file);
$analysis = $rec->runAnalyzer(new HeaderAnalyzer);
$this->assertCount($expectedCount, $analysis->pregameChat);
}

public function playersProvider()
{
return [
Expand Down Expand Up @@ -160,4 +170,12 @@ public function playersProvider()
], 2],
];
}

public function chatCountsProvider()
{
return [
['recs/versions/HD Tourney r1 robo_boro vs Dutch Class g1.aoe2record', 13],
['recs/versions/HD_test.mgx', 50],
];
}
}

0 comments on commit 2621ef9

Please sign in to comment.