OSDN Git Service

[Refactor] #38997 new_player_spot() に player_type * 引数を追加. / Add player_type * argume...
authordeskull <deskull@users.sourceforge.jp>
Tue, 12 Nov 2019 00:49:32 +0000 (09:49 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 12 Nov 2019 00:49:32 +0000 (09:49 +0900)
src/floor-generate.c
src/floor-save.c
src/grid.c
src/grid.h

index 0d0e632..89d07e0 100644 (file)
@@ -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;
 
index e6a106e..5d25d84 100644 (file)
@@ -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 */
index 9bda7ac..459b62a 100644 (file)
@@ -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;
 }
index e3c2ffd..098e03d 100644 (file)
@@ -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);