Skip to content

Commit f52ca58

Browse files
committed
Correctly interpret binaryString as a sequence of uint32-le values
The previous implementation was ignoring the 3 most significant bytes of each value and would result on improper parsing of any map with tile ids higher than 255
1 parent a8e972b commit f52ca58

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/tilemap/TilemapParser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ Phaser.TilemapParser = {
239239
var binaryString = window.atob(curl.data);
240240
var len = binaryString.length;
241241
var bytes = new Array( len );
242+
// Interpret binaryString as an array of bytes representing
243+
// little-endian encoded uint32 values.
242244
for (var i = 0; i < len; i+=4) {
243-
bytes[i/4] = binaryString.charCodeAt(i);
245+
bytes[i/4] = binaryString.charCodeAt(i) |
246+
binaryString.charCodeAt(i+1) << 8 |
247+
binaryString.charCodeAt(i+2) << 16 |
248+
binaryString.charCodeAt(i+3) << 24;
244249
}
245250
curl.data = bytes;
246251
}

0 commit comments

Comments
 (0)