Keep swamp within the room boundaries
If a swamp special room was generated in an irregular room, it could go outside the boundaries of that room. Fixes #546
This commit is contained in:
@@ -512,6 +512,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
||||
{
|
||||
register struct mkroom *sroom;
|
||||
register int sx, sy, i, eelct = 0;
|
||||
int rmno;
|
||||
|
||||
for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */
|
||||
sroom = &g.rooms[rn2(g.nroom)];
|
||||
@@ -519,10 +520,14 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
||||
|| has_dnstairs(sroom))
|
||||
continue;
|
||||
|
||||
rmno = (sroom - g.rooms) + ROOMOFFSET;
|
||||
|
||||
/* satisfied; make a swamp */
|
||||
sroom->rtype = SWAMP;
|
||||
for (sx = sroom->lx; sx <= sroom->hx; sx++)
|
||||
for (sy = sroom->ly; sy <= sroom->hy; sy++)
|
||||
for (sy = sroom->ly; sy <= sroom->hy; sy++) {
|
||||
if (!IS_ROOM(levl[sx][sy].typ) || levl[sx][sy].roomno != rmno)
|
||||
continue;
|
||||
if (!OBJ_AT(sx, sy) && !MON_AT(sx, sy) && !t_at(sx, sy)
|
||||
&& !nexttodoor(sx, sy)) {
|
||||
if ((sx + sy) % 2) {
|
||||
@@ -541,6 +546,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
||||
(void) makemon(mkclass(S_FUNGUS, 0), sx, sy,
|
||||
NO_MM_FLAGS);
|
||||
}
|
||||
}
|
||||
g.level.flags.has_swamp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user