From f8ff58ed7ebc46a565a9a2fa8fd4c52a73619392 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 21 May 2020 08:48:24 -0400 Subject: [PATCH] Fill special rooms recursively rather than only at top level The fill_special_rooms function was only stocking two types of rooms: top-level rooms in g.rooms, and their immediate subrooms. If there were a special room 2 or more levels down, it would not get filled. (No special levels currently define such a special room, so this bug is latent.) To address this, I changed fill_special_rooms to iterate only through the top level rooms, and fill_special_room to recurse through all of its subrooms (if any) before filling itself. --- src/sp_lev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sp_lev.c b/src/sp_lev.c index 258fa8f66..39e2e037d 100755 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1041,11 +1041,7 @@ fill_special_rooms() int tmpi, m; for (tmpi = 0; tmpi < g.nroom; tmpi++) { - if (g.rooms[tmpi].needfill) - fill_special_room(&g.rooms[tmpi]); - for (m = 0; m < g.rooms[tmpi].nsubrooms; m++) - if (g.rooms[tmpi].sbrooms[m]->needfill) - fill_special_room(g.rooms[tmpi].sbrooms[m]); + fill_special_room(&g.rooms[tmpi]); } } @@ -2685,6 +2681,15 @@ void fill_special_room(croom) struct mkroom *croom; { + int i; + + /* First recurse into subrooms. We don't want to block an ordinary room with + * a special subroom from having the subroom filled, or an unfilled outer + * room preventing a special subroom from being filled. */ + for (i = 0; i < croom->nsubrooms; ++i) { + fill_special_room(croom->sbrooms[i]); + } + if (!croom || croom->rtype == OROOM || croom->rtype == THEMEROOM || croom->needfill == FILL_NONE) return;