* @param y 基準のy座標
* @param x 基準のx座標
* @return 隣接する外壁の数
- * @note Assumes "in_bounds(p_ptr->current_floor_ptr, y, x)"
+ * @note Assumes "in_bounds()"
* @details We count only granite walls and permanent walls.
*/
static int next_to_walls(floor_type* floor_ptr, POSITION y, POSITION x)
case ALLOC_TYP_GOLD:
{
- place_gold(y, x);
+ place_gold(floor_ptr, y, x);
break;
}
case ALLOC_TYP_OBJECT:
{
- place_object(y, x, 0L);
+ place_object(floor_ptr, y, x, 0L);
break;
}
}
/*!
* @brief ダンジョン生成のメインルーチン / Generate a new dungeon level
* @details Note that "dun_body" adds about 4000 bytes of memory to the stack.
+ * @param player_ptr プレーヤーへの参照ポインタ
* @return ダンジョン生成が全て無事に成功したらTRUEを返す。
*/
-static bool cave_gen(floor_type *floor_ptr)
+static bool cave_gen(player_type *player_ptr)
{
int i, k;
POSITION y, x;
dun_data dun_body;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
dungeon_type* dungeon_ptr = &d_info[floor_ptr->dungeon_idx];
floor_ptr->lite_n = 0;
}
/* Destroy the level if necessary */
- if (dun->destroyed) destroy_level();
+ if (dun->destroyed) destroy_level(player_ptr);
/* Hack -- Add some rivers */
if (one_in_(3) && (randint1(floor_ptr->dun_level) > 5))
x = dun->door[i].x;
/* Try placing doors */
- try_door(y, x - 1);
- try_door(y, x + 1);
- try_door(y - 1, x);
- try_door(y + 1, x);
+ try_door(floor_ptr, y, x - 1);
+ try_door(floor_ptr, y, x + 1);
+ try_door(floor_ptr, y - 1, x);
+ try_door(floor_ptr, y + 1, x);
}
/* Place 3 or 4 down stairs near some walls */
/* Put the Guardian */
if (!alloc_guardian(TRUE)) return FALSE;
- if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > floor_ptr->dun_level)) && !(dungeon_ptr->flags1 & DF1_DARKNESS))
+ bool is_empty_or_dark = dun->empty_level;
+ is_empty_or_dark &= !one_in_(DARK_EMPTY) || (randint1(100) > floor_ptr->dun_level);
+ is_empty_or_dark &= !(dungeon_ptr->flags1 & DF1_DARKNESS);
+ if (!is_empty_or_dark) return TRUE;
+
+ /* Lite the floor_ptr->grid_array */
+ for (y = 0; y < floor_ptr->height; y++)
{
- /* Lite the floor_ptr->grid_array */
- for (y = 0; y < floor_ptr->height; y++)
+ for (x = 0; x < floor_ptr->width; x++)
{
- for (x = 0; x < floor_ptr->width; x++)
- {
- floor_ptr->grid_array[y][x].info |= (CAVE_GLOW);
- }
+ floor_ptr->grid_array[y][x].info |= (CAVE_GLOW);
}
}
* @brief 闘技場用のアリーナ地形を作成する / Builds the arena after it is entered -KMW-
* @return なし
*/
-static void build_arena(floor_type *floor_ptr)
+static void build_arena(floor_type *floor_ptr, POSITION *start_y, POSITION *start_x)
{
POSITION yval, y_height, y_depth, xval, x_left, x_right;
- register int i, j;
+ POSITION i, j;
yval = SCREEN_HGT / 2;
xval = SCREEN_WID / 2;
floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
}
- place_extra_perm_bold(floor_ptr, y_height+6, x_left+18);
- floor_ptr->grid_array[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(floor_ptr, y_depth-6, x_left+18);
- floor_ptr->grid_array[y_depth-6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(floor_ptr, y_height+6, x_right-18);
- floor_ptr->grid_array[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
- place_extra_perm_bold(floor_ptr, y_depth-6, x_right-18);
- floor_ptr->grid_array[y_depth-6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
+ place_extra_perm_bold(floor_ptr, y_height + 6, x_left + 18);
+ floor_ptr->grid_array[y_height + 6][x_left + 18].info |= (CAVE_GLOW | CAVE_MARK);
+ place_extra_perm_bold(floor_ptr, y_depth - 6, x_left + 18);
+ floor_ptr->grid_array[y_depth - 6][x_left + 18].info |= (CAVE_GLOW | CAVE_MARK);
+ place_extra_perm_bold(floor_ptr, y_height + 6, x_right - 18);
+ floor_ptr->grid_array[y_height + 6][x_right - 18].info |= (CAVE_GLOW | CAVE_MARK);
+ place_extra_perm_bold(floor_ptr, y_depth - 6, x_right - 18);
+ floor_ptr->grid_array[y_depth - 6][x_right - 18].info |= (CAVE_GLOW | CAVE_MARK);
- i = y_height + 5;
- j = xval;
- floor_ptr->grid_array[i][j].feat = f_tag_to_index("ARENA_GATE");
- floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
- player_place(p_ptr, i, j);
+ *start_y = y_height + 5;
+ *start_x = xval;
+ floor_ptr->grid_array[*start_y][*start_x].feat = f_tag_to_index("ARENA_GATE");
+ floor_ptr->grid_array[*start_y][*start_x].info |= (CAVE_GLOW | CAVE_MARK);
}
/*!
for (x = 0; x < MAX_WID; x++)
{
/* Create "solid" perma-wall */
- place_solid_perm_bold(y, x);
+ place_solid_perm_bold(floor_ptr, y, x);
/* Illuminate and memorize the walls */
floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
}
}
- build_arena(floor_ptr);
+ build_arena(floor_ptr, &y, &x);
+ player_place(challanger_ptr, y, x);
if(!place_monster_aux(0, challanger_ptr->y + 5, challanger_ptr->x, arena_info[challanger_ptr->arena_number].r_idx, (PM_NO_KAGE | PM_NO_PET)))
{
* @brief モンスター闘技場のフロア生成 / Builds the arena after it is entered -KMW-
* @return なし
*/
-static void build_battle(floor_type *floor_ptr)
+static void build_battle(floor_type *floor_ptr, POSITION *y, POSITION *x)
{
POSITION yval, y_height, y_depth, xval, x_left, x_right;
register int i, j;
j = xval;
floor_ptr->grid_array[i][j].feat = f_tag_to_index("BUILDING_3");
floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
- player_place(p_ptr, i, j);
+
+ *y = i;
+ *x = j;
}
/*!
for (x = 0; x < MAX_WID; x++)
{
/* Create "solid" perma-wall */
- place_solid_perm_bold(y, x);
+ place_solid_perm_bold(floor_ptr, y, x);
/* Illuminate and memorize the walls */
floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
}
}
- build_battle(floor_ptr);
+ build_battle(floor_ptr, &y, &x);
+
+ player_place(creature_ptr, y, x);
for(i = 0; i < 4; i++)
{
/*!
* @brief 固定マップクエストのフロア生成 / Generate a quest level
+ * @param player_ptr プレーヤーへの参照ポインタ
* @return なし
*/
-static void generate_fixed_floor(floor_type *floor_ptr)
+static void generate_fixed_floor(player_type *player_ptr)
{
POSITION x, y;
/* Start with perm walls */
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
for (y = 0; y < floor_ptr->height; y++)
{
for (x = 0; x < floor_ptr->width; x++)
{
- place_solid_perm_bold(y, x);
+ place_solid_perm_bold(floor_ptr, y, x);
}
}
/* Set the quest level */
- floor_ptr->base_level = quest[p_ptr->current_floor_ptr->inside_quest].level;
+ floor_ptr->base_level = quest[floor_ptr->inside_quest].level;
floor_ptr->dun_level = floor_ptr->base_level;
floor_ptr->object_level = floor_ptr->base_level;
floor_ptr->monster_level = floor_ptr->base_level;
- if (record_stair) exe_write_diary(p_ptr, NIKKI_TO_QUEST, p_ptr->current_floor_ptr->inside_quest, NULL);
+ if (record_stair) exe_write_diary(p_ptr, NIKKI_TO_QUEST, floor_ptr->inside_quest, NULL);
get_mon_num_prep(get_monster_hook(), NULL);
init_flags = INIT_CREATE_DUNGEON;
- process_dungeon_file("q_info.txt", 0, 0, MAX_HGT, MAX_WID);
+ process_dungeon_file(player_ptr, "q_info.txt", 0, 0, MAX_HGT, MAX_WID);
}
/*!
* @brief ダンジョン時のランダムフロア生成 / Make a real level
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param concptr
* @return フロアの生成に成功したらTRUE
*/
-static bool level_gen(floor_type *floor_ptr, concptr *why)
+static bool level_gen(player_type *player_ptr, concptr *why)
{
- int level_height, level_width;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
DUNGEON_IDX d_idx = floor_ptr->dungeon_idx;
if ((always_small_levels || ironman_small_levels ||
(d_info[d_idx].flags1 & DF1_SMALLEST)) &&
!(d_info[d_idx].flags1 & DF1_BIG))
{
+ int level_height, level_width;
if (d_info[d_idx].flags1 & DF1_SMALLEST)
{
level_height = 1;
}
else
{
- do
+ level_height = randint1(MAX_HGT / SCREEN_HGT);
+ level_width = randint1(MAX_WID / SCREEN_WID);
+ bool is_first_level_area = TRUE;
+ bool is_max_area = (level_height == MAX_HGT / SCREEN_HGT) && (level_width == MAX_WID / SCREEN_WID);
+ while (is_first_level_area || is_max_area)
{
- level_height = randint1(MAX_HGT/SCREEN_HGT);
- level_width = randint1(MAX_WID/SCREEN_WID);
+ level_height = randint1(MAX_HGT / SCREEN_HGT);
+ level_width = randint1(MAX_WID / SCREEN_WID);
+ is_max_area = (level_height == MAX_HGT / SCREEN_HGT) && (level_width == MAX_WID / SCREEN_WID);
}
- while ((level_height == MAX_HGT/SCREEN_HGT) && (level_width == MAX_WID/SCREEN_WID));
}
floor_ptr->height = level_height * SCREEN_HGT;
panel_col_min = floor_ptr->width;
}
- /* Make a dungeon */
floor_ptr->dungeon_idx = d_idx;
- if (!cave_gen(floor_ptr))
+ if (!cave_gen(player_ptr))
{
*why = _("ダンジョン生成に失敗", "could not place player");
return FALSE;
}
+
else return TRUE;
}
/*!
- * @brief フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after p_ptr->current_floor_ptr->grid_array generation
+ * @brief フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after grid_array generation
* @return なし
*/
void wipe_generate_random_floor_flags(floor_type *floor_ptr)
}
/*!
- * @brief フロアの全情報を初期化する / Clear and empty the p_ptr->current_floor_ptr->grid_array
+ * @brief フロアの全情報を初期化する / Clear and empty floor.
+ * @parama player_ptr プレーヤーへの参照ポインタ
* @return なし
*/
-void clear_cave(floor_type *floor_ptr)
+void clear_cave(player_type *player_ptr)
{
POSITION x, y;
int i;
/* Very simplified version of wipe_o_list() */
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
(void)C_WIPE(floor_ptr->o_list, floor_ptr->o_max, object_type);
floor_ptr->o_max = 1;
floor_ptr->o_cnt = 0;
for (i = 0; i < MAX_MTIMED; i++) floor_ptr->mproc_max[i] = 0;
/* Pre-calc cur_num of pets in party_mon[] */
- precalc_cur_num_of_pet();
+ precalc_cur_num_of_pet(player_ptr);
/* Start with a blank floor_ptr->grid_array */
}
}
- /* Mega-Hack -- no player yet */
- p_ptr->x = p_ptr->y = 0;
-
/* Set the base level */
floor_ptr->base_level = floor_ptr->dun_level;
/*!
* ダンジョンのランダムフロアを生成する / Generates a random dungeon level -RAK-
+ * @parama player_ptr プレーヤーへの参照ポインタ
* @return なし
* @note Hack -- regenerate any "overflow" levels
*/
-void generate_floor(floor_type *floor_ptr)
+void generate_floor(player_type *player_ptr)
{
int num;
/* Fill the arrays of floors and walls in the good proportions */
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
set_floor_and_wall(floor_ptr->dungeon_idx);
/* Generate */
bool okay = TRUE;
concptr why = NULL;
- clear_cave(floor_ptr);
+ clear_cave(player_ptr);
+
+ /* Mega-Hack -- no player yet */
+ player_ptr->x = player_ptr->y = 0;
if (floor_ptr->inside_arena)
{
- generate_challenge_arena(floor_ptr, p_ptr);
+ generate_challenge_arena(floor_ptr, player_ptr);
}
- else if (p_ptr->phase_out)
+ else if (player_ptr->phase_out)
{
- generate_gambling_arena(floor_ptr, p_ptr);
+ generate_gambling_arena(floor_ptr, player_ptr);
}
else if (floor_ptr->inside_quest)
{
- generate_fixed_floor(floor_ptr);
+ generate_fixed_floor(player_ptr);
}
/* Build the town */
else if (!floor_ptr->dun_level)
{
/* Make the wilderness */
- if (p_ptr->wild_mode) wilderness_gen_small(p_ptr, floor_ptr);
- else wilderness_gen(floor_ptr);
+ if (player_ptr->wild_mode) wilderness_gen_small(player_ptr);
+ else wilderness_gen(player_ptr);
}
/* Build a real level */
else
{
- okay = level_gen(floor_ptr, &why);
+ okay = level_gen(player_ptr, &why);
}
glow_deep_lava_and_bldg(floor_ptr);
/* Reset flag */
- p_ptr->enter_dungeon = FALSE;
+ player_ptr->enter_dungeon = FALSE;
wipe_generate_random_floor_flags(floor_ptr);
}
if (is_outer_bold(floor_ptr, y, x))
{
/* Change the wall to a "solid" wall */
- place_solid_noperm_bold(y, x);
+ place_solid_noperm_bold(floor_ptr, y, x);
}
}
}
if (is_outer_bold(floor_ptr, j, i))
{
/* Change the wall to a "solid" wall */
- place_solid_noperm_bold(j, i);
+ place_solid_noperm_bold(floor_ptr, j, i);
}
}
}