diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/map.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/resources/map.c b/src/resources/map.c index 2cc2f2a..514129d 100644 --- a/src/resources/map.c +++ b/src/resources/map.c @@ -623,6 +623,7 @@ tmx_data_end(void *pv, const char *name) size_t decomp_len; char *decoded_buf; char *decomp_buf; + size_t i; debug("</%s> (data)", name); @@ -671,7 +672,16 @@ tmx_data_end(void *pv, const char *name) return; } free(ly->raw_data); - ly->tiles = (Uint32 *) decomp_buf; + ly->tiles = malloc(decomp_len); + for (i = 0; i < decomp_len / 4; ++i) { + /* Convert each tile GID to the system's byte order. */ + ly->tiles[i] = + (decomp_buf[i * 4 + 0] & 0xFF << 000) | + (decomp_buf[i * 4 + 1] & 0xFF << 010) | + (decomp_buf[i * 4 + 2] & 0xFF << 020) | + (decomp_buf[i * 4 + 3] & 0xFF << 030); + } + free(decomp_buf); xml_node_pop(p); } else { xml_unexpected_end_tag(p, name, "data"); |