From f691e5f266a42aac8a14eb6c71e59111cc9fa16f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 30 Mar 2021 01:01:06 -0400 Subject: Revert "[WIP] map: Merge wall tiles into hor/vert lines" --- diff --git a/src/map.c b/src/map.c index 0a093ee..f33782f 100644 --- a/src/map.c +++ b/src/map.c @@ -32,11 +32,6 @@ #include "output.h" #include "xml.h" -struct db_wall { - SDL_Rect rect; - struct db_wall *next; -}; - struct db_map_layer { Uint32 *tiles; char *encoding; @@ -79,8 +74,7 @@ struct db_map { struct db_ball *ball_head; struct db_ball *ball_tail; Uint8 *p_col; - struct db_wall *wall_head; - struct db_wall *wall_tail; + Uint8 *b_col; }; static char * @@ -777,9 +771,6 @@ _db_map_set_collision_tiles(struct db_map *map) struct db_map_layer *layer; int i; int gid; - Uint8 *b_col; - int x; - int y; db_dbg("Allocating %d bit field elements", (map->w * map->h + 7) / 8); map->p_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col)); @@ -787,8 +778,8 @@ _db_map_set_collision_tiles(struct db_map *map) db_err("Failed to allocate memory"); return; } - b_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col)); - if (b_col == NULL) { + map->b_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col)); + if (map->b_col == NULL) { db_err("Failed to allocate memory"); free(map->p_col); return; @@ -807,31 +798,7 @@ _db_map_set_collision_tiles(struct db_map *map) map->p_col[i / 8] |= 1 << (i % 8); } if (db_tile_ball_collides(map->tileset_head, gid)) { - b_col[i / 8] |= 1 << (i % 8); - } - } - } - - for (y = 0; y < map->h; ++y) { - for (x = 0; x < map->w; ++x) { - i = y * map->w + x; - if ((b_col[i / 8] & (1 << (i % 8))) != 0) { - if (x > 0 && map->walls[i] != NULL) { - ++map->walls[i - 1].rect.w; - map->walls[i] = map->walls[i - 1]; - continue; - } - map->wall_tail = calloc(1, - sizeof(*map->wall_tail)); - if (map->wall_tail == NULL) { - db_err("Failed to allocate memory"); - free(map->p_col); - free(b_col); - return; - } - if (map->wall_head == NULL) { - map->wall_head = map->wall_tail; - } + map->b_col[i / 8] |= 1 << (i % 8); } } } -- cgit v0.9.1