From d3798cc99f7232e377d7aae2981d30778175a83e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 3 Apr 2026 13:59:51 +0300 Subject: [PATCH] map: add `is_floor()` helper to check walkable tiles Signed-off-by: NotAShelf Change-Id: I7368f74d1cbcf5913e5d8e9331cfa4326a6a6964 --- src/map.c | 6 +++--- src/map.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/map.c b/src/map.c index e3559ec..24016c9 100644 --- a/src/map.c +++ b/src/map.c @@ -13,7 +13,7 @@ void map_init(Map *map) { map->room_count = 0; } -int is_floor(Map *map, int x, int y) { +int is_floor(const Map *map, int x, int y) { if (!in_bounds(x, y, MAP_WIDTH, MAP_HEIGHT)) return 0; return map->tiles[y][x] == TILE_FLOOR || map->tiles[y][x] == TILE_STAIRS; @@ -62,8 +62,8 @@ static int room_overlaps(Room *rooms, int count, Room *new_room) { // Add padding to prevent rooms from touching for (int i = 0; i < count; i++) { Room *r = &rooms[i]; - if (!(new_room->x > r->x + r->w || new_room->x + new_room->w < r->x || - new_room->y > r->y + r->h || new_room->y + new_room->h < r->y)) { + if (!(new_room->x > r->x + r->w || new_room->x + new_room->w < r->x || new_room->y > r->y + r->h || + new_room->y + new_room->h < r->y)) { return 1; } } diff --git a/src/map.h b/src/map.h index 4280e2b..3cf6337 100644 --- a/src/map.h +++ b/src/map.h @@ -4,7 +4,7 @@ #include "common.h" // Check if a tile is walkable floor -int is_floor(Map *map, int x, int y); +int is_floor(const Map *map, int x, int y); // Get room center coordinates void get_room_center(Room *room, int *cx, int *cy); @@ -18,4 +18,4 @@ void map_init(Map *map); // Get a random floor tile position void get_random_floor_tile(Map *map, int *x, int *y, int attempts); -#endif // MAP_H +#endif // MAP_H