From: Elias Fleckenstein Date: Thu, 10 Jun 2021 19:30:28 +0000 (+0200) Subject: Cleanup Mapgen code X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2308ed66087a16b542e9c1a24ea91d8502af463b;p=dungeon_game.git Cleanup Mapgen code --- diff --git a/plugins/game/game.c b/plugins/game/game.c index ad283c8..bd93419 100644 --- a/plugins/game/game.c +++ b/plugins/game/game.c @@ -258,16 +258,11 @@ static bool check_direction(int x, int y, enum direction dir) return is_solid(x, y + 1) && is_solid(x, y - 1) && (is_solid(x + 1, y) || rand() % 3 > 1) && (is_solid(x - 1, y) || rand() % 3 > 1); } -static void generate_corridor(int lx, int ly, enum direction ldir, bool off) +static void generate_corridor(int lx, int ly, enum direction ldir) { if (is_outside(lx, ly)) return; - /* - if (off && rand() % 100 == 0) - return; - */ - map[lx][ly] = (struct node) {&air}; for (struct list *ptr = air_functions; ptr != NULL; ptr = ptr->next) { @@ -298,18 +293,18 @@ static void generate_corridor(int lx, int ly, enum direction ldir, bool off) } while (dir == ret || (! check_direction(x, y, dir) && --limit)); if (limit) - generate_corridor(x, y, dir, off); + generate_corridor(x, y, dir); if (rand() % 20 == 0) - generate_corridor(lx, ly, ldir, true); + generate_corridor(lx, ly, ldir); } static void generate_corridor_random(int x, int y) { enum direction dir = rand() % 4; - generate_corridor(x, y, dir, false); - generate_corridor(x, y, (dir + 2) % 4, false); + generate_corridor(x, y, dir); + generate_corridor(x, y, (dir + 2) % 4); } /* Rendering */