diff --git a/doc/fixes36.1 b/doc/fixes36.1 index efc7afa1e..282b8bdd3 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -348,7 +348,8 @@ give quest guardians some equipment hero polyed into ghoul can only eat non-veggy corpses or eggs kicking activates statue traps 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 diff --git a/src/mkmaze.c b/src/mkmaze.c index bdfb2ca37..9c6d18715 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -618,6 +618,57 @@ fixup_special() 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 * TODO: rewrite walkfrom so it works on temp space, not levl */ @@ -665,6 +716,9 @@ int wallthick; maze0xy(&mm); walkfrom((int) mm.x, (int) mm.y, 0); + if (!rn2(5)) + maze_remove_deadends((level.flags.corrmaze) ? CORR : ROOM); + /* restore bounds */ x_maze_max = tmp_xmax; y_maze_max = tmp_ymax;