Make sure random doors don't open into solid wall

When making a random door into a random wall or random position
in a room, keep trying harder to find a location that doesn't
have solid wall behind it.

Fixes the Wizard tower door.
This commit is contained in:
Pasi Kallinen
2020-03-10 18:08:40 +02:00
parent 67d3cd31f8
commit ae471e71b2
2 changed files with 5 additions and 4 deletions

View File

@@ -1503,7 +1503,7 @@ struct mkroom *broom;
y = broom->ly - 1;
x = broom->lx
+ ((dpos == -1) ? rn2(1 + (broom->hx - broom->lx)) : dpos);
if (!isok(x,y - 1))
if (!isok(x,y - 1) || IS_ROCK(levl[x][y - 1].typ))
goto redoloop;
goto outdirloop;
case 1:
@@ -1512,7 +1512,7 @@ struct mkroom *broom;
y = broom->hy + 1;
x = broom->lx
+ ((dpos == -1) ? rn2(1 + (broom->hx - broom->lx)) : dpos);
if (!isok(x,y + 1))
if (!isok(x,y + 1) || IS_ROCK(levl[x][y + 1].typ))
goto redoloop;
goto outdirloop;
case 2:
@@ -1521,7 +1521,7 @@ struct mkroom *broom;
x = broom->lx - 1;
y = broom->ly
+ ((dpos == -1) ? rn2(1 + (broom->hy - broom->ly)) : dpos);
if (!isok(x - 1,y))
if (!isok(x - 1,y) || IS_ROCK(levl[x - 1][y].typ))
goto redoloop;
goto outdirloop;
case 3:
@@ -1530,7 +1530,7 @@ struct mkroom *broom;
x = broom->hx + 1;
y = broom->ly
+ ((dpos == -1) ? rn2(1 + (broom->hy - broom->ly)) : dpos);
if (!isok(x + 1,y))
if (!isok(x + 1,y) || IS_ROCK(levl[x + 1][y].typ))
goto redoloop;
goto outdirloop;
default: