From: deskull Date: Tue, 12 Nov 2019 00:49:32 +0000 (+0900) Subject: [Refactor] #38997 new_player_spot() に player_type * 引数を追加. / Add player_type * argume... X-Git-Url: http://git.osdn.net/view?p=hengband%2Fhengband.git;a=commitdiff_plain;h=7c0a703095f2b72e432f1ed9786ea8aa2946b4cb [Refactor] #38997 new_player_spot() に player_type * 引数を追加. / Add player_type * argument to new_player_spot(). --- diff --git a/src/floor-generate.c b/src/floor-generate.c index 0d0e632df..89d07e0bd 100644 --- a/src/floor-generate.c +++ b/src/floor-generate.c @@ -915,7 +915,7 @@ static bool cave_gen(floor_type *floor_ptr) } /* Determine the character location */ - if (!new_player_spot()) return FALSE; + if (!new_player_spot(p_ptr)) return FALSE; if (!place_quest_monsters(floor_ptr, p_ptr)) return FALSE; diff --git a/src/floor-save.c b/src/floor-save.c index e6a106e82..5d25d84e3 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -1349,7 +1349,7 @@ void change_floor(player_type *creature_ptr) /* Arrive at random grid */ if (creature_ptr->change_floor_mode & (CFM_RAND_PLACE)) { - (void)new_player_spot(); + (void)new_player_spot(creature_ptr); } /* You see stairs blocked */ diff --git a/src/grid.c b/src/grid.c index 9bda7ac44..459b62aa7 100644 --- a/src/grid.c +++ b/src/grid.c @@ -176,9 +176,10 @@ static const byte feature_action_flags[FF_FLAG_MAX] = /*! * @brief 新規フロアに入りたてのプレイヤーをランダムな場所に配置する / Returns random co-ordinates for player/monster/object + * @param creature_ptr 配置したいクリーチャーの参照ポインタ * @return 配置に成功したらTRUEを返す */ -bool new_player_spot(void) +bool new_player_spot(player_type *creature_ptr) { POSITION y = 0, x = 0; int max_attempts = 10000; @@ -189,14 +190,14 @@ bool new_player_spot(void) while (max_attempts--) { /* Pick a legal spot */ - y = (POSITION)rand_range(1, p_ptr->current_floor_ptr->height - 2); - x = (POSITION)rand_range(1, p_ptr->current_floor_ptr->width - 2); + y = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->height - 2); + x = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->width - 2); - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x]; /* Must be a "naked" floor grid */ if (g_ptr->m_idx) continue; - if (p_ptr->current_floor_ptr->dun_level) + if (creature_ptr->current_floor_ptr->dun_level) { f_ptr = &f_info[g_ptr->feat]; @@ -214,7 +215,7 @@ bool new_player_spot(void) if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) continue; } if (!player_can_enter(g_ptr->feat, 0)) continue; - if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue; + if (!in_bounds(creature_ptr->current_floor_ptr, y, x)) continue; /* Refuse to start on anti-teleport grids */ if (g_ptr->info & (CAVE_ICKY)) continue; @@ -226,8 +227,8 @@ bool new_player_spot(void) return FALSE; /* Save the new player grid */ - p_ptr->y = y; - p_ptr->x = x; + creature_ptr->y = y; + creature_ptr->x = x; return TRUE; } diff --git a/src/grid.h b/src/grid.h index e3c2ffd5f..098e03d78 100644 --- a/src/grid.h +++ b/src/grid.h @@ -360,7 +360,7 @@ typedef struct /* Externs */ -extern bool new_player_spot(void); +extern bool new_player_spot(player_type *creature_ptr); extern void place_random_stairs(POSITION y, POSITION x); extern void place_random_door(POSITION y, POSITION x, bool room);