diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/resources/map.c | 12 |
2 files changed, 15 insertions, 1 deletions
@@ -11,6 +11,7 @@ main(void) struct image *img; struct map_tileset *ts; struct map_exit *e; + int i; SDL_Rect imgrect, surfacerect; init(); @@ -30,6 +31,9 @@ main(void) e->target_map->width, e->target_map->height, e->target_x_coord, e->target_y_coord); } + for (i = 0; i < map->width * map->height; ++i) { + debug("%x", map->layers[LAYER_CHAR_BOT].tiles[i]); + } img = img_png_get("../forest-6-layer-test_ground.png"); img_png_free(img); 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"); |