Skip to content

Commit

Permalink
fix: remove observers array from teams property
Browse files Browse the repository at this point in the history
  • Loading branch information
PBug90 committed Jun 2, 2018
1 parent fdb82fa commit 6d4e040
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/W3GReplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ W3GReplay.prototype.cleanup = function () {
delete this.players[p.id]
}
})
if (this.header.version >= 29 && this.teams.hasOwnProperty('24')) {
delete this.teams['24']
} else if (this.teams.hasOwnProperty('12')) {
delete this.teams['12']
}
delete this.slots
delete this.playerList
delete this.buffer
Expand Down
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ describe('Replay parsing tests', () => {
const test = Parser.parse(`./replays/standard_129_obs.w3g`)
expect(test.header.magic).to.equal('Warcraft III recorded game\u001a')
expect(test.header.version).to.equal(29)
expect(test.teams['24']).to.be.an('array')
expect(test.teams['24']).to.have.lengthOf(4)
expect(test.players['4'].name).to.equal('S.o.K.o.L')
expect(test.players['4'].detectedRace).to.equal('O')
expect(test.players['4'].color).to.equal('#50c878')
expect(test.players['6'].name).to.equal('Stormhoof')
expect(test.players['6'].detectedRace).to.equal('O')
expect(test.players['6'].color).to.equal('#800000')
expect(test.observers).to.have.lengthOf(4)
expect(test.teams['24']).to.equal(undefined)
expect(Object.keys(test.players)).to.have.lengthOf(2)
})

Expand All @@ -32,17 +31,19 @@ describe('Replay parsing tests', () => {
expect(test.players['10'].name).to.equal('u2.sok')
expect(test.players['10'].detectedRace).to.equal('H')
expect(test.players['10'].color).to.equal('#ff0000')
expect(test.teams['12']).to.equal(undefined)
expect(Object.keys(test.players)).to.have.lengthOf(2)
})

it('parses a netease 1.29 replay properly', () => {
const test = Parser.parse(`./replays/netease_129_obs.nwg`)
expect(test.header.magic).to.equal('Warcraft III recorded game\u001a')
expect(test.header.version).to.equal(29)
expect(test.teams['24']).to.be.an('array')

expect(test.players['3'].name).to.equal('rudan')
expect(test.players['3'].color).to.equal('#3eb489')
expect(test.observers).to.have.lengthOf(1)
expect(test.teams['24']).to.equal(undefined)
expect(Object.keys(test.players)).to.have.lengthOf(2)
})
})

0 comments on commit 6d4e040

Please sign in to comment.