* @note Assumes "in_bounds(p_ptr->current_floor_ptr, y, x)"
* @details We count only granite walls and permanent walls.
*/
-static int next_to_walls(POSITION y, POSITION x)
+static int next_to_walls(floor_type* floor_ptr, POSITION y, POSITION x)
{
int k = 0;
- if (in_bounds(p_ptr->current_floor_ptr, y + 1, x) && is_extra_bold(p_ptr->current_floor_ptr, y + 1, x)) k++;
- if (in_bounds(p_ptr->current_floor_ptr, y - 1, x) && is_extra_bold(p_ptr->current_floor_ptr, y - 1, x)) k++;
- if (in_bounds(p_ptr->current_floor_ptr, y, x + 1) && is_extra_bold(p_ptr->current_floor_ptr, y, x + 1)) k++;
- if (in_bounds(p_ptr->current_floor_ptr, y, x - 1) && is_extra_bold(p_ptr->current_floor_ptr, y, x - 1)) k++;
+ if (in_bounds(floor_ptr, y + 1, x) && is_extra_bold(floor_ptr, y + 1, x)) k++;
+ if (in_bounds(floor_ptr, y - 1, x) && is_extra_bold(floor_ptr, y - 1, x)) k++;
+ if (in_bounds(floor_ptr, y, x + 1) && is_extra_bold(floor_ptr, y, x + 1)) k++;
+ if (in_bounds(floor_ptr, y, x - 1) && is_extra_bold(floor_ptr, y, x - 1)) k++;
return (k);
}
* @param walls 最低減隣接させたい外壁の数
* @return 階段を生成して問題がないならばTRUEを返す。
*/
-static bool alloc_stairs_aux(POSITION y, POSITION x, int walls)
+static bool alloc_stairs_aux(floor_type *floor_ptr, POSITION y, POSITION x, int walls)
{
- grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &floor_ptr->grid_array[y][x];
/* Require "naked" floor grid */
if (!is_floor_grid(g_ptr)) return FALSE;
if (g_ptr->o_idx || g_ptr->m_idx) return FALSE;
/* Require a certain number of adjacent walls */
- if (next_to_walls(y, x) < walls) return FALSE;
+ if (next_to_walls(floor_ptr, y, x) < walls) return FALSE;
return TRUE;
}
/* No up stairs in town or in ironman mode */
if (ironman_downward || !floor_ptr->dun_level) return TRUE;
- if (floor_ptr->dun_level > d_info[p_ptr->dungeon_idx].mindepth)
+ if (floor_ptr->dun_level > d_info[floor_ptr->dungeon_idx].mindepth)
shaft_num = (randint1(num+1))/2;
}
else if (have_flag(f_ptr->flags, FF_MORE))
}
/* No downstairs at the bottom */
- if (floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) return TRUE;
+ if (floor_ptr->dun_level >= d_info[floor_ptr->dungeon_idx].maxdepth) return TRUE;
- if ((floor_ptr->dun_level < d_info[p_ptr->dungeon_idx].maxdepth-1) && !quest_number(floor_ptr->dun_level+1))
+ if ((floor_ptr->dun_level < d_info[floor_ptr->dungeon_idx].maxdepth-1) && !quest_number(floor_ptr->dun_level+1))
shaft_num = (randint1(num)+1)/2;
}
else return FALSE;
{
for (x = 1; x < floor_ptr->width - 1; x++)
{
- if (alloc_stairs_aux(y, x, walls))
+ if (alloc_stairs_aux(floor_ptr, y, x, walls))
{
/* A valid space found */
candidates++;
{
for (x = 1; x < floor_ptr->width - 1; x++)
{
- if (alloc_stairs_aux(y, x, walls))
+ if (alloc_stairs_aux(floor_ptr, y, x, walls))
{
pick--;
if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx) continue;
/* Avoid player location */
- if (player_bold(y, x)) continue;
+ if (player_bold(p_ptr, y, x)) continue;
/* Check for "room" */
room = (floor_ptr->grid_array[y][x].info & CAVE_ROOM) ? TRUE : FALSE;
case ALLOC_TYP_TRAP:
{
- place_trap(y, x);
+ place_trap(floor_ptr, y, x);
floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
break;
}
/*!
* @brief クエストに関わるモンスターの配置を行う / Place quest monsters
+ * @param floor_ptr 配置するフロアの参照ポインタ
+ * @param subject_ptr 近隣への即出現を避けるためのプレイヤークリーチャー参照ポインタ
* @return 成功したならばTRUEを返す
*/
-bool place_quest_monsters(void)
+bool place_quest_monsters(floor_type *floor_ptr, player_type *creature_ptr)
{
int i;
if (quest[i].status != QUEST_STATUS_TAKEN ||
(quest[i].type != QUEST_TYPE_KILL_LEVEL &&
quest[i].type != QUEST_TYPE_RANDOM) ||
- quest[i].level != p_ptr->current_floor_ptr->dun_level ||
- p_ptr->dungeon_idx != quest[i].dungeon ||
+ quest[i].level != floor_ptr->dun_level ||
+ creature_ptr->dungeon_idx != quest[i].dungeon ||
(quest[i].flags & QUEST_FLAG_PRESET))
{
/* Ignore it */
grid_type *g_ptr;
feature_type *f_ptr;
- y = randint0(p_ptr->current_floor_ptr->height);
- x = randint0(p_ptr->current_floor_ptr->width);
+ y = randint0(floor_ptr->height);
+ x = randint0(floor_ptr->width);
- g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+ g_ptr = &floor_ptr->grid_array[y][x];
f_ptr = &f_info[g_ptr->feat];
if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) continue;
if (!monster_can_enter(y, x, r_ptr, 0)) continue;
- if (distance(y, x, p_ptr->y, p_ptr->x) < 10) continue;
+ if (distance(y, x, creature_ptr->y, creature_ptr->x) < 10) continue;
if (g_ptr->info & CAVE_ICKY) continue;
else break;
}
dun->destroyed = TRUE;
/* extra rubble around the place looks cool */
- build_lake(one_in_(2) ? LAKE_T_CAVE : LAKE_T_EARTH_VAULT);
+ build_lake(floor_ptr, one_in_(2) ? LAKE_T_CAVE : LAKE_T_EARTH_VAULT);
}
/* Make a lake some of the time */
if (dun->laketype)
{
msg_print_wizard(CHEAT_DUNGEON, _("湖を生成します。", "Lake on the level."));
- build_lake(dun->laketype);
+ build_lake(floor_ptr, dun->laketype);
}
}
/* make a large fractal floor_ptr->grid_array in the middle of the dungeon */
msg_print_wizard(CHEAT_DUNGEON, _("洞窟を生成。", "Cavern on level."));
- build_cavern();
+ build_cavern(floor_ptr);
}
#endif /* ALLOW_CAVERNS_AND_LAKES */
* @details Note that "dun_body" adds about 4000 bytes of memory to the stack.
* @return ダンジョン生成が全て無事に成功したらTRUEを返す。
*/
-static bool cave_gen(dungeon_type* dungeon_ptr, floor_type *floor_ptr)
+static bool cave_gen(floor_type *floor_ptr)
{
int i, k;
POSITION y, x;
dun_data dun_body;
+ dungeon_type* dungeon_ptr = &d_info[floor_ptr->dungeon_idx];
+
floor_ptr->lite_n = 0;
floor_ptr->mon_lite_n = 0;
floor_ptr->redraw_n = 0;
int tunnel_fail_count = 0;
/*
- * Build each type of room in current_world_ptr->game_turn until we cannot build any more.
+ * Build each type of room in turn until we cannot build any more.
*/
- if (!generate_rooms()) return FALSE;
+ if (!generate_rooms(floor_ptr)) return FALSE;
/* Make a hole in the dungeon roof sometimes at level 1 */
{
while (one_in_(DUN_MOS_DEN))
{
- place_trees(randint1(floor_ptr->width - 2), randint1(floor_ptr->height - 2));
+ place_trees(floor_ptr, randint1(floor_ptr->width - 2), randint1(floor_ptr->height - 2));
}
}
((dun->laketype == LAKE_T_WATER) && have_flag(f_ptr->flags, FF_WATER)) ||
!dun->laketype)
{
- add_river(feat1, feat2);
+ add_river(floor_ptr, feat1, feat2);
}
}
}
}
/* Determine the character location */
- if (!new_player_spot()) return FALSE;
+ if (!new_player_spot(p_ptr)) return FALSE;
- if (!place_quest_monsters()) return FALSE;
+ if (!place_quest_monsters(floor_ptr, p_ptr)) return FALSE;
/* Basic "amount" */
k = (floor_ptr->dun_level / 3);
* @brief モンスター闘技場への導入処理 / Town logic flow for generation of arena -KMW-
* @return なし
*/
-static void generate_gambling_arena(floor_type *floor_ptr)
+static void generate_gambling_arena(floor_type *floor_ptr, player_type *creature_ptr)
{
POSITION y, x;
MONSTER_IDX i;
for(i = 0; i < 4; i++)
{
- place_monster_aux(0, p_ptr->y + 8 + (i/2)*4, p_ptr->x - 2 + (i%2)*4, battle_mon[i], (PM_NO_KAGE | PM_NO_PET));
- set_friendly(&floor_ptr->m_list[floor_ptr->grid_array[p_ptr->y+8+(i/2)*4][p_ptr->x-2+(i%2)*4].m_idx]);
+ place_monster_aux(0, creature_ptr->y + 8 + (i/2)*4, creature_ptr->x - 2 + (i%2)*4, battle_mon[i], (PM_NO_KAGE | PM_NO_PET));
+ set_friendly(&floor_ptr->m_list[floor_ptr->grid_array[creature_ptr->y+8+(i/2)*4][creature_ptr->x-2+(i%2)*4].m_idx]);
}
for(i = 1; i < floor_ptr->m_max; i++)
{
static bool level_gen(floor_type *floor_ptr, concptr *why)
{
int level_height, level_width;
+ DUNGEON_IDX d_idx = floor_ptr->dungeon_idx;
if ((always_small_levels || ironman_small_levels ||
(one_in_(SMALL_LEVEL) && small_levels) ||
- (d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER) ||
- (d_info[p_ptr->dungeon_idx].flags1 & DF1_SMALLEST)) &&
- !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BIG))
+ (d_info[d_idx].flags1 & DF1_BEGINNER) ||
+ (d_info[d_idx].flags1 & DF1_SMALLEST)) &&
+ !(d_info[d_idx].flags1 & DF1_BIG))
{
- if (d_info[p_ptr->dungeon_idx].flags1 & DF1_SMALLEST)
+ if (d_info[d_idx].flags1 & DF1_SMALLEST)
{
level_height = 1;
level_width = 1;
}
- else if (d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER)
+ else if (d_info[d_idx].flags1 & DF1_BEGINNER)
{
level_height = 2;
level_width = 2;
}
/* Make a dungeon */
- if (!cave_gen(&d_info[p_ptr->dungeon_idx], floor_ptr))
+ floor_ptr->dungeon_idx = d_idx;
+ if (!cave_gen(floor_ptr))
{
*why = _("ダンジョン生成に失敗", "could not place player");
return FALSE;
* @return なし
* @note Hack -- regenerate any "overflow" levels
*/
-void generate_random_floor(floor_type *floor_ptr)
+void generate_floor(floor_type *floor_ptr)
{
int num;
/* Fill the arrays of floors and walls in the good proportions */
- set_floor_and_wall(p_ptr->dungeon_idx);
+ set_floor_and_wall(floor_ptr->dungeon_idx);
/* Generate */
for (num = 0; TRUE; num++)
else if (p_ptr->phase_out)
{
- generate_gambling_arena(floor_ptr);
+ generate_gambling_arena(floor_ptr, p_ptr);
}
else if (p_ptr->inside_quest)
else if (!floor_ptr->dun_level)
{
/* Make the wilderness */
- if (p_ptr->wild_mode) wilderness_gen_small();
- else wilderness_gen();
+ if (p_ptr->wild_mode) wilderness_gen_small(p_ptr, floor_ptr);
+ else wilderness_gen(floor_ptr);
}
/* Build a real level */
* Note that this routine is only called on "even" squares - so it gives
* a natural checkerboard pattern.
*/
-static void create_cata_tunnel(POSITION x, POSITION y)
+static void create_cata_tunnel(floor_type *floor_ptr, POSITION x, POSITION y)
{
POSITION x1, y1;
/* Build tunnel */
x1 = x - 1;
y1 = y;
- set_tunnel(p_ptr->current_floor_ptr, &x1, &y1, FALSE);
+ set_tunnel(floor_ptr, &x1, &y1, FALSE);
x1 = x + 1;
y1 = y;
- set_tunnel(p_ptr->current_floor_ptr, &x1, &y1, FALSE);
+ set_tunnel(floor_ptr, &x1, &y1, FALSE);
x1 = x;
y1 = y - 1;
- set_tunnel(p_ptr->current_floor_ptr, &x1, &y1, FALSE);
+ set_tunnel(floor_ptr, &x1, &y1, FALSE);
x1 = x;
y1 = y + 1;
- set_tunnel(p_ptr->current_floor_ptr, &x1, &y1, FALSE);
+ set_tunnel(floor_ptr, &x1, &y1, FALSE);
}
* This, when used with longer line segments gives the "catacomb-like" tunnels seen near\n
* the surface.\n
*/
-static void short_seg_hack(POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type, int count, bool *fail)
+static void short_seg_hack(floor_type *floor_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type, int count, bool *fail)
{
int i;
POSITION x, y;
{
x = x1 + i * (x2 - x1) / length;
y = y1 + i * (y2 - y1) / length;
- if (!set_tunnel(p_ptr->current_floor_ptr, &x, &y, TRUE))
+ if (!set_tunnel(floor_ptr, &x, &y, TRUE))
{
if (count > 50)
{
}
/* solid wall - so try to go around */
- short_seg_hack(x, y, x1 + (i - 1) * (x2 - x1) / length, y1 + (i - 1) * (y2 - y1) / length, 1, count, fail);
- short_seg_hack(x, y, x1 + (i + 1) * (x2 - x1) / length, y1 + (i + 1) * (y2 - y1) / length, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x1 + (i - 1) * (x2 - x1) / length, y1 + (i - 1) * (y2 - y1) / length, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x1 + (i + 1) * (x2 - x1) / length, y1 + (i + 1) * (y2 - y1) / length, 1, count, fail);
}
}
}
{
x = i;
y = y1;
- if (!set_tunnel(p_ptr->current_floor_ptr, &x, &y, TRUE))
+ if (!set_tunnel(floor_ptr, &x, &y, TRUE))
{
/* solid wall - so try to go around */
- short_seg_hack(x, y, i - 1, y1, 1, count, fail);
- short_seg_hack(x, y, i + 1, y1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, i - 1, y1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, i + 1, y1, 1, count, fail);
}
if ((type == 3) && ((x + y) % 2))
{
- create_cata_tunnel(i, y1);
+ create_cata_tunnel(floor_ptr, i, y1);
}
}
}
{
x = i;
y = y1;
- if (!set_tunnel(p_ptr->current_floor_ptr, &x, &y, TRUE))
+ if (!set_tunnel(floor_ptr, &x, &y, TRUE))
{
/* solid wall - so try to go around */
- short_seg_hack(x, y, i - 1, y1, 1, count, fail);
- short_seg_hack(x, y, i + 1, y1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, i - 1, y1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, i + 1, y1, 1, count, fail);
}
if ((type == 3) && ((x + y) % 2))
{
- create_cata_tunnel(i, y1);
+ create_cata_tunnel(floor_ptr, i, y1);
}
}
{
x = x2;
y = i;
- if (!set_tunnel(p_ptr->current_floor_ptr, &x, &y, TRUE))
+ if (!set_tunnel(floor_ptr, &x, &y, TRUE))
{
/* solid wall - so try to go around */
- short_seg_hack(x, y, x2, i - 1, 1, count, fail);
- short_seg_hack(x, y, x2, i + 1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x2, i - 1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x2, i + 1, 1, count, fail);
}
if ((type == 3) && ((x + y) % 2))
{
- create_cata_tunnel(x2, i);
+ create_cata_tunnel(floor_ptr, x2, i);
}
}
}
{
x = x2;
y = i;
- if (!set_tunnel(p_ptr->current_floor_ptr, &x, &y, TRUE))
+ if (!set_tunnel(floor_ptr, &x, &y, TRUE))
{
/* solid wall - so try to go around */
- short_seg_hack(x, y, x2, i - 1, 1, count, fail);
- short_seg_hack(x, y, x2, i + 1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x2, i - 1, 1, count, fail);
+ short_seg_hack(floor_ptr, x, y, x2, i + 1, 1, count, fail);
}
if ((type == 3) && ((x + y) % 2))
{
- create_cata_tunnel(x2, i);
+ create_cata_tunnel(floor_ptr, x2, i);
}
}
}
{
/* Do a short segment */
retval = TRUE;
- short_seg_hack(x1, y1, x2, y2, type, 0, &retval);
+ short_seg_hack(floor_ptr, x1, y1, x2, y2, type, 0, &retval);
/* Hack - ignore return value so avoid infinite loops */
return TRUE;