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.
This commit is contained in:
committed by
Pasi Kallinen
parent
0fef8fce9f
commit
f8ff58ed7e
15
src/sp_lev.c
15
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;
|
||||
|
||||
Reference in New Issue
Block a user