From 2da4d927516cf4f40010e74f94e8e600922cc0e2 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 24 Aug 2022 21:30:42 +0300 Subject: [PATCH] Fix room array overflowing into subrooms If the map is big enough so that makerooms generates the maximum allowed number of rooms for the level, the last room will "overflow" into the subrooms array. The rooms array assumes the last entry has hx = -1, and add_room changes the next room hx to -1 but because the subrooms array is right after the rooms array, this change actually touches the first subroom on the level. This has been present since who knows how long, but because the levels are normally small enough, the room limit is never hit. --- src/mklev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mklev.c b/src/mklev.c index 17db087e5..2316f4521 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -292,7 +292,7 @@ makerooms(void) /* make rooms until satisfied */ /* rnd_rect() will returns 0 if no more rects are available... */ - while (g.nroom < MAXNROFROOMS && rnd_rect()) { + while (g.nroom < (MAXNROFROOMS-1) && rnd_rect()) { if (g.nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { tried_vault = TRUE; if (create_vault()) {