Occasionally remove maze dead ends, creating loops
This commit is contained in:
+2
-1
@@ -348,7 +348,8 @@ give quest guardians some equipment
|
|||||||
hero polyed into ghoul can only eat non-veggy corpses or eggs
|
hero polyed into ghoul can only eat non-veggy corpses or eggs
|
||||||
kicking activates statue traps
|
kicking activates statue traps
|
||||||
pets start with apport equal to your charisma
|
pets start with apport equal to your charisma
|
||||||
sometimes generate the random mazes with wide corridors or thick walls
|
sometimes generate the random mazes with wide corridors, thick walls,
|
||||||
|
or with dead ends changed to loops
|
||||||
|
|
||||||
|
|
||||||
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
|
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
|
||||||
|
|||||||
@@ -618,6 +618,57 @@ fixup_special()
|
|||||||
num_lregions = 0;
|
num_lregions = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean
|
||||||
|
maze_inbounds(x,y)
|
||||||
|
int x,y;
|
||||||
|
{
|
||||||
|
return (x >= 2 && y >= 2
|
||||||
|
&& x < x_maze_max && y < y_maze_max && isok(x,y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
maze_remove_deadends(typ)
|
||||||
|
xchar typ;
|
||||||
|
{
|
||||||
|
int x,y, dir;
|
||||||
|
for (x = 2; x < x_maze_max; x++)
|
||||||
|
for (y = 2; y < y_maze_max; y++)
|
||||||
|
if (ACCESSIBLE(levl[x][y].typ) && (x % 2) && (y % 2)) {
|
||||||
|
char dirok[4];
|
||||||
|
int idx = 0;
|
||||||
|
int idx2 = 0;
|
||||||
|
for (dir = 0; dir < 4; dir++) {
|
||||||
|
int dx = x;
|
||||||
|
int dy = y;
|
||||||
|
int dx2 = x;
|
||||||
|
int dy2 = y;
|
||||||
|
mz_move(dx,dy, dir);
|
||||||
|
if (!maze_inbounds(dx,dy)) {
|
||||||
|
idx2++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mz_move(dx2,dy2, dir);
|
||||||
|
mz_move(dx2,dy2, dir);
|
||||||
|
if (!maze_inbounds(dx2,dy2)) {
|
||||||
|
idx2++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!ACCESSIBLE(levl[dx][dy].typ)
|
||||||
|
&& ACCESSIBLE(levl[dx2][dy2].typ)) {
|
||||||
|
dirok[idx++] = dir;
|
||||||
|
idx2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idx2 >= 3 && idx > 0) {
|
||||||
|
dir = dirok[rn2(idx)];
|
||||||
|
int dx = x;
|
||||||
|
int dy = y;
|
||||||
|
mz_move(dx,dy, dir);
|
||||||
|
levl[dx][dy].typ = typ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a maze with specified corridor width and wall thickness
|
/* Create a maze with specified corridor width and wall thickness
|
||||||
* TODO: rewrite walkfrom so it works on temp space, not levl
|
* TODO: rewrite walkfrom so it works on temp space, not levl
|
||||||
*/
|
*/
|
||||||
@@ -665,6 +716,9 @@ int wallthick;
|
|||||||
maze0xy(&mm);
|
maze0xy(&mm);
|
||||||
walkfrom((int) mm.x, (int) mm.y, 0);
|
walkfrom((int) mm.x, (int) mm.y, 0);
|
||||||
|
|
||||||
|
if (!rn2(5))
|
||||||
|
maze_remove_deadends((level.flags.corrmaze) ? CORR : ROOM);
|
||||||
|
|
||||||
/* restore bounds */
|
/* restore bounds */
|
||||||
x_maze_max = tmp_xmax;
|
x_maze_max = tmp_xmax;
|
||||||
y_maze_max = tmp_ymax;
|
y_maze_max = tmp_ymax;
|
||||||
|
|||||||
Reference in New Issue
Block a user