From f52ca58d7d3d5d1c91d85d39ffc821a42d92ad83 Mon Sep 17 00:00:00 2001 From: Lisandro Lorea Date: Mon, 14 Sep 2015 20:38:58 -0300 Subject: [PATCH] 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 --- src/tilemap/TilemapParser.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index b47b380be..0169fd54c 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -239,8 +239,13 @@ Phaser.TilemapParser = { var binaryString = window.atob(curl.data); var len = binaryString.length; var bytes = new Array( len ); + // Interpret binaryString as an array of bytes representing + // little-endian encoded uint32 values. for (var i = 0; i < len; i+=4) { - bytes[i/4] = binaryString.charCodeAt(i); + bytes[i/4] = binaryString.charCodeAt(i) | + binaryString.charCodeAt(i+1) << 8 | + binaryString.charCodeAt(i+2) << 16 | + binaryString.charCodeAt(i+3) << 24; } curl.data = bytes; }