Skip to content

Commit

Permalink
fix(rec): fix wrong buffer method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
hexjelly committed Jan 26, 2017
1 parent 3f9bf03 commit 20062cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/rec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Replay {
offset += 16 * numEvents
let expected = buffer.readInt32LE(offset)
if (expected !== EOR_MARKER) {
reject('End of replay marker mismatch')
reject('End of multi-replay marker mismatch')
return
}
}
Expand All @@ -103,7 +103,7 @@ class Replay {
static _parseFrames (buffer, numFrames) {
let frames = []
for (let i = 0; i < numFrames; i++) {
let data = buffer.readUint8(i + (numFrames * 23)) // read in data field first to process it
let data = buffer.readUInt8(i + (numFrames * 23)) // read in data field first to process it
let frame = {
bike_x: buffer.readFloatLE(i * 4),
bike_y: buffer.readFloatLE((i * 4) + (numFrames * 4)),
Expand All @@ -114,8 +114,8 @@ class Replay {
head_x: buffer.readInt16LE((i * 2) + (numFrames * 16)),
head_y: buffer.readInt16LE((i * 2) + (numFrames * 18)),
rotation: buffer.readInt16LE((i * 2) + (numFrames * 20)),
left_rotation: buffer.readUint8(i + (numFrames * 21)),
right_rotation: buffer.readUint8(i + (numFrames * 22)),
left_rotation: buffer.readUInt8(i + (numFrames * 21)),
right_rotation: buffer.readUInt8(i + (numFrames * 22)),
throttle: data & 1 !== 0,
right: data & (1 << 1) !== 0,
volume: buffer.readInt16LE((i * 2) + (numFrames * 25))
Expand All @@ -141,7 +141,7 @@ class Replay {
offset += 8
event.info = buffer.readInt16LE(offset)
offset += 2
let eventType = buffer.readUint8(offset)
let eventType = buffer.readUInt8(offset)
offset += 6 // 1 + 5 unknown bytes
switch (eventType) {
case 0:
Expand Down
2 changes: 0 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ test('Valid replay 3: load() parses level correctly', t => {
}).catch(error => t.fail(error.Error))
})

test.todo('read replay file')
test.todo('reject Across replays')
test.todo('check all replay attributes with 3+ replays')
test.todo('save replay and check against original')

Expand Down

0 comments on commit 20062cd

Please sign in to comment.