/*
+ * Count the number of walls adjacent to the given grid.
+ *
+ * Note -- Assumes "in_bounds(y, x)"
+ *
+ * We count only granite walls and permanent walls.
+ */
+static int next_to_walls(int y, int x)
+{
+ int k = 0;
+
+ if (have_flag(f_flags_bold(y + 1, x), FF_WALL)) k++;
+ if (have_flag(f_flags_bold(y - 1, x), FF_WALL)) k++;
+ if (have_flag(f_flags_bold(y, x + 1), FF_WALL)) k++;
+ if (have_flag(f_flags_bold(y, x - 1), FF_WALL)) k++;
+
+ return (k);
+}
+
+
+/*
* Places some staircases near walls
*/
static bool alloc_stairs(int feat, int num, int walls)
{
int y, x, i, j, flag;
- int more_num = 0;
+ int shaft_num = 0;
cave_type *c_ptr;
feature_type *f_ptr = &f_info[feat];
if (ironman_downward || !dun_level) return TRUE;
if (dun_level > d_info[dungeon_type].mindepth)
- more_num = (randint1(num+1))/2;
+ shaft_num = (randint1(num+1))/2;
}
else if (have_flag(f_ptr->flags, FF_MORE))
{
if (dun_level >= d_info[dungeon_type].maxdepth) return TRUE;
if ((dun_level < d_info[dungeon_type].maxdepth-1) && !quest_number(dun_level+1))
- more_num = (randint1(num)+1)/2;
+ shaft_num = (randint1(num)+1)/2;
}
/* Paranoia */
else return FALSE;
+
+ /* There very few walls in an arena level */
+ if (dun->empty_level) walls = 1;
+
/* Place "num" stairs */
for (i = 0; i < num; i++)
{
- /* Place some stairs */
+ /* Try several times */
for (flag = FALSE; !flag; )
{
/* Try several times, then decrease "walls" */
- for (j = 0; !flag && j <= 3000; j++)
+ for (j = 0; j <= 3000; j++)
{
/* Pick a random grid */
y = randint1(cur_hgt-2);
c_ptr->mimic = 0;
/* Clear previous contents, add stairs */
- c_ptr->feat = (i < more_num) ? feat_state(feat, FF_SHAFT) : feat;
+ c_ptr->feat = (i < shaft_num) ? feat_state(feat, FF_SHAFT) : feat;
/* All done */
flag = TRUE;
+ break;
}
- if (!flag) return FALSE;
/* Require fewer walls */
if (walls) walls--;
}
c_ptr = &cave[y][x];
/* Skip non floors */
- if (!cave_floor_grid(c_ptr)) continue;
+ if (have_flag(f_flags_grid(c_ptr), FF_WALL)) continue;
/* Skip non "empty floor" grids */
if (!is_floor_grid(c_ptr))
if (!in_bounds(y, x)) return;
/* Ignore walls */
- if (!cave_floor_bold(y, x)) return;
+ if (have_flag(f_flags_bold(y, x), FF_WALL)) return;
/* Ignore room grids */
if (cave[y][x].info & (CAVE_ROOM)) return;
/* Find an empty grid */
for (l = SAFE_MAX_ATTEMPTS; l > 0; l--)
{
- cave_type *c_ptr;
-
y = randint0(cur_hgt);
x = randint0(cur_wid);
- c_ptr = &cave[y][x];
- if (!cave_floor_grid(c_ptr) || c_ptr->o_idx || c_ptr->m_idx) continue;
+ if (!monster_can_enter(y, x, r_ptr, 0)) continue;
if (distance(y, x, py, px) < 10) continue;
else break;
}
/* Fill the arrays of floors and walls in the good proportions */
set_floor_and_wall(dungeon_type);
-
/* Prepare allocation table */
get_mon_num_prep(get_monster_hook(), NULL);
- feat_wall_outer = d_info[dungeon_type].outer_wall;
- feat_wall_inner = d_info[dungeon_type].inner_wall;
- feat_wall_solid = d_info[dungeon_type].outer_wall;
-
/* Randomize the dungeon creation values */
dun_tun_rnd = rand_range(DUN_TUN_RND_MIN, DUN_TUN_RND_MAX);
dun_tun_chg = rand_range(DUN_TUN_CHG_MIN, DUN_TUN_CHG_MAX);
/*
* Build each type of room in turn until we cannot build any more.
*/
- generate_rooms();
+ if (!generate_rooms()) return FALSE;
/* Make a hole in the dungeon roof sometimes at level 1 */
place_extra_perm_bold(y_height+6, x_left+18);
cave[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height-6, x_left+18);
+ place_extra_perm_bold(y_depth-6, x_left+18);
cave[y_depth-6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height+6, x_left-18);
+ place_extra_perm_bold(y_height+6, x_right-18);
cave[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height-6, x_left-18);
+ place_extra_perm_bold(y_depth-6, x_right-18);
cave[y_depth-6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
i = y_height + 5;
place_extra_perm_bold(y_height+6, x_left+18);
cave[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height-4, x_left+18);
+ place_extra_perm_bold(y_depth-4, x_left+18);
cave[y_depth-4][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height+6, x_left-18);
+ place_extra_perm_bold(y_height+6, x_right-18);
cave[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(y_height-4, x_left-18);
+ place_extra_perm_bold(y_depth-4, x_right-18);
cave[y_depth-4][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
i = y_height + 4;
{
if (cheat_room)
#ifdef JP
-msg_print("¾®¤µ¤Ê¥Õ¥í¥¢");
+ msg_print("¾®¤µ¤Ê¥Õ¥í¥¢");
#else
- msg_print("A 'small' dungeon level.");
+ msg_print("A 'small' dungeon level.");
#endif
-
if (d_info[dungeon_type].flags1 & DF1_SMALLEST)
{
level_height = 1;
* Generates a random dungeon level -RAK-
*
* Hack -- regenerate any "overflow" levels
- *
- * Hack -- allow auto-scumming via a gameplay option.
*/
void generate_cave(void)
{
- int num;
+ int num, i;
/* Fill the arrays of floors and walls in the good proportions */
set_floor_and_wall(dungeon_type);
/* Clear and empty the cave */
clear_cave();
- if (have_flag(f_info[d_info[dungeon_type].fill_type1].flags, FF_HAS_GOLD) ||
- have_flag(f_info[d_info[dungeon_type].fill_type2].flags, FF_HAS_GOLD) ||
- have_flag(f_info[d_info[dungeon_type].fill_type3].flags, FF_HAS_GOLD)) rating += 40;
+ for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
+ {
+ if (have_flag(f_info[d_info[dungeon_type].fill[i].feat].flags, FF_HAS_GOLD))
+ {
+ rating += 40;
+ break;
+ }
+ }
/* Build the arena -KMW- */
if (p_ptr->inside_arena)