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.
This commit is contained in:
Pasi Kallinen
2022-08-24 21:30:42 +03:00
parent 48db75fabc
commit 2da4d92751

View File

@@ -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()) {