OSDN Git Service

[Refactor] #38997 scatter() に player_type * 引数を追加 / Added player_type * argument...
authordeskull <deskull@users.sourceforge.jp>
Tue, 7 Jan 2020 17:09:11 +0000 (02:09 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 7 Jan 2020 17:09:11 +0000 (02:09 +0900)
15 files changed:
src/cmd/cmd-activate.c
src/floor-save.c
src/floor.c
src/floor.h
src/geometry.c
src/geometry.h
src/mind.c
src/monster1.c
src/monster2.c
src/mspells4.c
src/player-status.c
src/quest.c
src/realm-crusade.c
src/spells2.c
src/wizard2.c

index 34d6956..15731c4 100644 (file)
@@ -1011,7 +1011,7 @@ bool activate_artifact(player_type *user_ptr, object_type *o_ptr)
 
                        while (attempts--)
                        {
-                               scatter(&y, &x, user_ptr->y, user_ptr->x, 4, 0);
+                               scatter(user_ptr->current_floor_ptr, &y, &x, user_ptr->y, user_ptr->x, 4, 0);
                                if (!cave_have_flag_bold(user_ptr->current_floor_ptr, y, x, FF_PROJECT)) continue;
                                if (!player_bold(user_ptr, y, x)) break;
                        }
index 4311e58..47f6db1 100644 (file)
@@ -579,7 +579,7 @@ static void place_pet(player_type *master_ptr)
                        {
                                for (j = 1000; j > 0; j--)
                                {
-                                       scatter(&cy, &cx, master_ptr->y, master_ptr->x, d, 0);
+                                       scatter(master_ptr->current_floor_ptr, &cy, &cx, master_ptr->y, master_ptr->x, d, 0);
                                        if (monster_can_enter(cy, cx, &r_info[party_mon[i].r_idx], 0)) break;
                                }
                                if (j) break;
index bd6c273..1f763c4 100644 (file)
@@ -604,7 +604,7 @@ void vault_monsters(floor_type *floor_ptr, POSITION y1, POSITION x1, int num)
                        int d = 1;
 
                        /* Pick a nearby location */
-                       scatter(&y, &x, y1, x1, d, 0);
+                       scatter(floor_ptr, &y, &x, y1, x1, d, 0);
 
                        /* Require "empty" floor grids */
                        g_ptr = &floor_ptr->grid_array[y][x];
@@ -1944,3 +1944,48 @@ void vault_traps(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POS
                vault_trap_aux(floor_ptr, y, x, yd, xd);
        }
 }
+
+
+/*
+ * Standard "find me a location" function
+ *
+ * Obtains a legal location within the given distance of the initial
+ * location, and with "los()" from the source to destination location.
+ *
+ * This function is often called from inside a loop which searches for
+ * locations while increasing the "d" distance.
+ *
+ * Currently the "m" parameter is unused.
+ */
+void scatter(floor_type *floor_ptr, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode)
+{
+       POSITION nx, ny;
+
+       /* Pick a location */
+       while (TRUE)
+       {
+               /* Pick a new location */
+               ny = rand_spread(y, d);
+               nx = rand_spread(x, d);
+
+               /* Ignore annoying locations */
+               if (!in_bounds(floor_ptr, ny, nx)) continue;
+
+               /* Ignore "excessively distant" locations */
+               if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
+
+               if (mode & PROJECT_LOS)
+               {
+                       if (los(floor_ptr, y, x, ny, nx)) break;
+               }
+               else
+               {
+                       if (projectable(floor_ptr, y, x, ny, nx)) break;
+               }
+
+       }
+
+       /* Save the location */
+       (*yp) = ny;
+       (*xp) = nx;
+}
index 59f9ebf..0150adf 100644 (file)
@@ -428,3 +428,4 @@ extern void place_gold(floor_type *floor_ptr, POSITION y, POSITION x);
 extern void delete_monster(floor_type *floor_ptr, POSITION y, POSITION x);
 extern void compact_objects(floor_type *floor_ptr, int size);
 extern void vault_traps(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num);
+extern void scatter(floor_type *floor_ptr, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode);
index 77dd0a0..bed7731 100644 (file)
@@ -112,50 +112,6 @@ DIRECTION coords_to_dir(player_type *creature_ptr, POSITION y, POSITION x)
 }
 
 
-/*
- * Standard "find me a location" function
- *
- * Obtains a legal location within the given distance of the initial
- * location, and with "los()" from the source to destination location.
- *
- * This function is often called from inside a loop which searches for
- * locations while increasing the "d" distance.
- *
- * Currently the "m" parameter is unused.
- */
-void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode)
-{
-       POSITION nx, ny;
-
-       /* Pick a location */
-       while (TRUE)
-       {
-               /* Pick a new location */
-               ny = rand_spread(y, d);
-               nx = rand_spread(x, d);
-
-               /* Ignore annoying locations */
-               if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
-
-               /* Ignore "excessively distant" locations */
-               if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
-
-               if (mode & PROJECT_LOS)
-               {
-                       if (los(p_ptr->current_floor_ptr, y, x, ny, nx)) break;
-               }
-               else
-               {
-                       if (projectable(p_ptr->current_floor_ptr, y, x, ny, nx)) break;
-               }
-
-       }
-
-       /* Save the location */
-       (*yp) = ny;
-       (*xp) = nx;
-}
-
 
 /*!
  * @brief 指定された座標をプレイヤーが視覚に収められるかを返す。 / Can the player "see" the given grid in detail?
index 012cf4b..e301b83 100644 (file)
@@ -15,7 +15,6 @@ extern DIRECTION coords_to_dir(player_type *creature_ptr, POSITION y, POSITION x
 
 extern POSITION distance(POSITION y1, POSITION x1, POSITION y2, POSITION x2);
 
-extern void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode);
 extern void mmove2(POSITION *y, POSITION *x, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
 
 extern bool player_can_see_bold(player_type *creature_ptr, POSITION y, POSITION x);
index da1e121..4accd42 100644 (file)
@@ -1739,7 +1739,7 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
 
                        while (attempts--)
                        {
-                               scatter(&y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
+                               scatter(caster_ptr->current_floor_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
 
                                if (!player_bold(caster_ptr, y, x)) break;
                        }
index 47b3fd5..c9b909e 100644 (file)
@@ -2750,7 +2750,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item)
 
                                do
                                {
-                                       scatter(&wy, &wx, y, x, 20, 0);
+                                       scatter(p_ptr->current_floor_ptr, &wy, &wx, y, x, 20, 0);
                                } while (!(in_bounds(p_ptr->current_floor_ptr, wy, wx) && cave_empty_bold2(p_ptr->current_floor_ptr, wy, wx)) && --attempts);
 
                                if (attempts > 0)
index dc6f6aa..1ca5e8f 100644 (file)
@@ -3010,7 +3010,7 @@ static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE
                {
                        POSITION mx, my;
 
-                       scatter(&my, &mx, hy, hx, 4, 0);
+                       scatter(p_ptr->current_floor_ptr, &my, &mx, hy, hx, 4, 0);
 
                        /* Walls and Monsters block flow */
                        if (!cave_empty_bold2(p_ptr->current_floor_ptr, my, mx)) continue;
@@ -3135,7 +3135,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
                for(j = 0; j < n; j++)
                {
                        POSITION nx, ny, d = 7;
-                       scatter(&ny, &nx, y, x, d, 0);
+                       scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, d, 0);
                        (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
                }
        }
@@ -3160,7 +3160,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
                        MONRACE_IDX z; 
 
                        /* Pick a location */
-                       scatter(&ny, &nx, y, x, d, 0);
+                       scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, d, 0);
 
                        /* Require empty grids */
                        if (!cave_empty_bold2(p_ptr->current_floor_ptr, ny, nx)) continue;
@@ -3262,7 +3262,7 @@ bool alloc_horde(POSITION y, POSITION x)
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
-               scatter(&cy, &cx, y, x, 5, 0);
+               scatter(p_ptr->current_floor_ptr, &cy, &cx, y, x, 5, 0);
 
                (void)summon_specific(m_idx, cy, cx, p_ptr->current_floor_ptr->dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
 
index 1f89f16..f325e1c 100644 (file)
@@ -3190,7 +3190,7 @@ MONSTER_NUMBER summon_NAZGUL(POSITION y, POSITION x, MONSTER_IDX m_idx)
                        int j;
                        for (j = 100; j > 0; j--)
                        {
-                               scatter(&cy, &cx, y, x, 2, 0);
+                               scatter(p_ptr->current_floor_ptr, &cy, &cx, y, x, 2, 0);
                                if (cave_empty_bold(p_ptr->current_floor_ptr, cy, cx)) break;
                        }
                        if (!j) break;
index 8ce01f2..03efec4 100644 (file)
@@ -5183,7 +5183,7 @@ void wreck_the_pattern(player_type *creature_ptr)
 
        while (to_ruin--)
        {
-               scatter(&r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
+               scatter(p_ptr->current_floor_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
 
                if (pattern_tile(r_y, r_x) &&
                        (f_info[p_ptr->current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
index 83f5de2..d98ade2 100644 (file)
@@ -287,7 +287,7 @@ void check_quest_completion(monster_type *m_ptr)
                while (cave_perma_bold(p_ptr->current_floor_ptr, y, x) || p_ptr->current_floor_ptr->grid_array[y][x].o_idx || (p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_OBJECT))
                {
                        /* Pick a location */
-                       scatter(&ny, &nx, y, x, 1, 0);
+                       scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, 1, 0);
 
                        /* Stagger */
                        y = ny; x = nx;
index 98939b3..238589f 100644 (file)
@@ -559,7 +559,7 @@ concptr do_crusade_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mod
 
                                        while (attempt--)
                                        {
-                                               scatter(&my, &mx, caster_ptr->y, caster_ptr->x, 4, 0);
+                                               scatter(caster_ptr->current_floor_ptr, &my, &mx, caster_ptr->y, caster_ptr->x, 4, 0);
 
                                                /* Require empty grids */
                                                if (cave_empty_bold2(caster_ptr->current_floor_ptr, my, mx)) break;
index 974e63d..f94f49d 100644 (file)
@@ -1877,7 +1877,7 @@ bool starlight(player_type *caster_ptr, bool magic)
 
                while (attempts--)
                {
-                       scatter(&y, &x, caster_ptr->y, caster_ptr->x, 4, PROJECT_LOS);
+                       scatter(caster_ptr->current_floor_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, PROJECT_LOS);
                        if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)) continue;
                        if (!player_bold(caster_ptr, y, x)) break;
                }
@@ -2801,7 +2801,7 @@ void wall_breaker(player_type *caster_ptr)
        {
                while (attempts--)
                {
-                       scatter(&y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
+                       scatter(caster_ptr->current_floor_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
 
                        if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)) continue;
 
@@ -2824,7 +2824,7 @@ void wall_breaker(player_type *caster_ptr)
        {
                while (TRUE)
                {
-                       scatter(&y, &x, caster_ptr->y, caster_ptr->x, 10, 0);
+                       scatter(caster_ptr->current_floor_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 10, 0);
 
                        if (!player_bold(caster_ptr, y, x)) break;
                }
index c09d884..cbd7295 100644 (file)
@@ -196,7 +196,7 @@ static void do_cmd_summon_horde(player_type *caster_ptr)
 
        while (--attempts)
        {
-               scatter(&wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
+               scatter(caster_ptr->current_floor_ptr, &wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
                if (cave_empty_bold(caster_ptr->current_floor_ptr, wy, wx)) break;
        }