From 14716f2830387ff70017735b784e9904bd065055 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 25 Mar 2021 15:08:04 -0400 Subject: map: Set layer rect in outer loop --- diff --git a/src/map.c b/src/map.c index 84b6194..2ac3ebd 100644 --- a/src/map.c +++ b/src/map.c @@ -525,6 +525,12 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer, continue; } tile_found = SDL_FALSE; + layer_rect.x = i % map->w; + layer_rect.y = i / map->w; + layer_rect.w = map->tw; + layer_rect.h = map->th; + layer_rect.x *= layer_rect.w; + layer_rect.y *= layer_rect.h; for (tileset = map->tileset_head; tileset != NULL; tileset = db_tileset_next(tileset)) { firstgid = db_tileset_firstgid(tileset); @@ -532,18 +538,12 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer, if (gid >= firstgid && gid < lastgid) { columns = db_tileset_columns(tileset); gid -= firstgid; - tile_rect.x = gid % columns; - tile_rect.y = gid / columns; - tile_rect.w = map->tw; - tile_rect.h = map->th; - tile_rect.x *= tile_rect.w; - tile_rect.y *= tile_rect.h; - layer_rect.x = i % map->w; - layer_rect.y = i / map->w; - layer_rect.w = map->tw; - layer_rect.h = map->th; - layer_rect.x *= layer_rect.w; - layer_rect.y *= layer_rect.h; + tile_rect.x = gid % columns; + tile_rect.y = gid / columns; + tile_rect.w = map->tw; + tile_rect.h = map->th; + tile_rect.x *= tile_rect.w; + tile_rect.y *= tile_rect.h; db_dbg("Blitting %dx%d tile at (%d,%d) " "onto %dx%d area of layer at " "(%d,%d)...", -- cgit v0.9.1