Skip to content

Commit

Permalink
hotfix for pre-2.0 replays causing a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ebshimizu committed Feb 25, 2018
1 parent 9f7f6e0 commit b938d6a
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ player presence, or team.
Standard End of Match statistics, bans, award details, and talents.

![Full Draft]({{ "/images/match-details-10.png" | absolute_url }})
Full match draft, not just bans.
Full match draft, not just bans. Available for replays from HotS 2.0 or newer (v2.25.0).

![Stat Graphs]({{ "/images/match-details-02.png" | absolute_url }})
Interactive charts for overall team damage/healing, teamfight damage/healing, and CC time
Expand Down
14 changes: 10 additions & 4 deletions js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,17 @@ class Database {
}

if ('picks' in match) {
for (let p = 0; p < match.picks[t].length; p++) {
data[match.picks[t][p]].picks['p' + (p + 1)].count += 1;
if (match.picks[t].length !== 5) {
// some older replays do not have draft data, so we just skip
//console.log('Pick data missing, continuing...');
}
else {
for (let p = 0; p < match.picks[t].length; p++) {
data[match.picks[t][p]].picks['p' + (p + 1)].count += 1;

if (parseInt(t) === winner) {
data[match.picks[t][p]].picks['p' + (p + 1)].wins += 1;
if (parseInt(t) === winner) {
data[match.picks[t][p]].picks['p' + (p + 1)].wins += 1;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function removeLoader() {
$('#main-app-loader').dimmer('hide');
}

function showMessage(title, text, opts) {
function showMessage(title, text, opts = {}) {
let elem = '<div class="ui message transition hidden">'
elem += '<div class="header">' + title + '</div>';
elem += '<p>' + text + '</p>';
Expand Down Expand Up @@ -632,7 +632,7 @@ function showMessage(title, text, opts) {
elem.remove();
}
});
}, 3000)
}, 4000)
}
});
}
Expand Down
6 changes: 5 additions & 1 deletion js/match-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ function updateBasicInfo() {
}
}

if ('picks' in matchDetailMatch) {
if ('picks' in matchDetailMatch && matchDetailMatch.picks[0].length === 5 && matchDetailMatch.picks[1].length === 5) {
for (let t in [0, 1]) {
let picks = matchDetailMatch.picks[t];
for (let p = 0; p < picks.length; p++) {
Expand All @@ -400,6 +400,10 @@ function updateBasicInfo() {
else {
$('div[pick-slot^="first"] img').attr('src', '');
$('div[pick-slot^="second"] img').attr('src', '');

if ('picks' in matchDetailMatch) {
showMessage('Older Replays Missing Draft Data', 'Earlier versions of the replay files didn\'t store draft picks, so no draft data is available');
}
}

let firstClass = first === 0 ? 'blue' : 'red';
Expand Down
4 changes: 2 additions & 2 deletions js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function renderPlayerSummary() {
continue;

// more than 1 game, filters out a lot of useless data
if (playerDetailStats.withPlayer[d].games === 1)
if (playerDetailStats.withPlayer[d].games < settings.get('playerThreshold'))
continue;

let context = playerDetailStats.withPlayer[d];
Expand All @@ -564,7 +564,7 @@ function renderPlayerSummary() {
}

for (let d in playerDetailStats.againstPlayer) {
if (playerDetailStats.againstPlayer[d].games === 1)
if (playerDetailStats.againstPlayer[d].games < settings.get('playerThreshold'))
continue;

// can't really be vs yourself huh
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stats-of-the-storm",
"version": "0.2.0",
"version": "0.2.1",
"main": "main.js",
"description": "A Heroes of the Storm stat tracking application.",
"bugs": "[email protected]",
Expand Down
11 changes: 8 additions & 3 deletions parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function parse(file, requestedData, opts) {
console.log("Retrieving " + requestedData[i]);

// debug version for independent testing
//const script = cp.spawnSync(path.join(__dirname, 'heroprotocol/dist/heroprotocol/heroprotocol.exe'), ['--json', '--' + requestedData[i], file], {
const script = cp.spawnSync(fixPathForAsarUnpack(path.join(__dirname, 'heroprotocol/dist/heroprotocol/heroprotocol.exe')), ['--json', '--' + requestedData[i], file], {
const script = cp.spawnSync(path.join(__dirname, 'heroprotocol/dist/heroprotocol/heroprotocol.exe'), ['--json', '--' + requestedData[i], file], {
//const script = cp.spawnSync(fixPathForAsarUnpack(path.join(__dirname, 'heroprotocol/dist/heroprotocol/heroprotocol.exe')), ['--json', '--' + requestedData[i], file], {
maxBuffer: 300000*1024 // if anyone asks why it's 300MB it's because gameevents is huge
});

Expand Down Expand Up @@ -301,7 +301,12 @@ function processReplay(file, opts = {}) {
match.picks.first = player.team;

// conveniently we just need which player picks and then we have the hero name yay
match.picks[player.team].push(player.hero);
if (match.picks[player.team].indexOf(player.hero) < 0) {
match.picks[player.team].push(player.hero);
}
else {
console.log("[PARSER WARNING] Match has invalid pick data, recovering as much data as possible.");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions parser/players.db~
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$$indexCreated":{"fieldName":"hero","unique":false,"sparse":false}}
3 changes: 3 additions & 0 deletions templates/about-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ <h2 class="ui inverted header">Stats of the Storm - Version <span class="app-ver
gets talent and hero information and images from <a href="https://github.com/heroespatchnotes/heroes-talents">heroes-talents</a>.
</p>
<div class="ui inverted horizontal divider">Change Log</div>
<h3 class="ui inverted dividing header">Version 0.2.1</h3>
<p>Draft Stats: hotfix for pre-2.0 (client version 2.25.0) replays missing draft pick and ban data.</p>
<p>Correctly applied player game threshold to Player Details with/against player tables.</p>
<h3 class="ui inverted dividing header">Version 0.2.0</h3>
<p>
Version 0.2.0 brings talent builds and the full draft data to Stats of the Storm, along
Expand Down

0 comments on commit b938d6a

Please sign in to comment.