OSDN Git Service

[Refactor] #38997 Changed macro function MAX_RANGE to get_max_range and moved it...
authorHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 16:00:42 +0000 (01:00 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 16:00:42 +0000 (01:00 +0900)
12 files changed:
src/floor/floor.c
src/io/cursor.c
src/io/targeting.c
src/io/targeting.h
src/mind/mind-mirror-master.c
src/mspell/mspells1.c
src/mspell/mspells2.c
src/spell-kind/spells-lite.c
src/spell-realm/spells-crusade.c
src/spell/process-effect.c
src/spell/spells3.c
src/system/gamevalue.h

index 4c27e79..3e27e12 100644 (file)
@@ -10,6 +10,7 @@
 #include "game-option/map-screen-options.h"
 #include "grid/grid.h"
 #include "grid/trap.h"
+#include "io/targeting.h"
 #include "monster-floor/monster-generator.h"
 #include "monster-floor/monster-remover.h"
 #include "monster/monster-update.h"
@@ -541,7 +542,7 @@ bool los(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITIO
 bool projectable(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
 {
        u16b grid_g[512];
-       int grid_n = project_path(player_ptr, grid_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, 0);
+    int grid_n = project_path(player_ptr, grid_g, (project_length ? project_length : get_max_range(player_ptr)), y1, x1, y2, x2, 0);
        if (!grid_n) return TRUE;
 
        POSITION y = GRID_Y(grid_g[grid_n - 1]);
index 50840f1..5088eb2 100644 (file)
@@ -40,7 +40,7 @@ void print_path(player_type *player_ptr, POSITION y, POSITION x)
         return;
 
     floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    int path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
+    int path_n = project_path(player_ptr, path_g, (project_length ? project_length : get_max_range(player_ptr)), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
     player_ptr->redraw |= (PR_MAP);
     handle_stuff(player_ptr);
     for (int i = 0; i < path_n; i++) {
index 40c8701..82f270c 100644 (file)
@@ -395,10 +395,10 @@ static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
        if (mode & TARGET_KILL)
        {
                /* Inner range */
-               min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
-               max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
-               min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
-               max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
+               min_hgt = MAX((creature_ptr->y - get_max_range(creature_ptr)), 0);
+               max_hgt = MIN((creature_ptr->y + get_max_range(creature_ptr)), creature_ptr->current_floor_ptr->height - 1);
+               min_wid = MAX((creature_ptr->x - get_max_range(creature_ptr)), 0);
+               max_wid = MIN((creature_ptr->x + get_max_range(creature_ptr)), creature_ptr->current_floor_ptr->width - 1);
        }
        else /* not targetting */
        {
@@ -2230,3 +2230,10 @@ bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
        *dp = dir;
        return TRUE;
 }
+
+/*!
+ * @briefプレイヤーの攻撃射程(マス) / Maximum range (spells, etc)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 射程
+ */
+int get_max_range(player_type *creature_ptr) { return creature_ptr->phase_out ? 36 : 18; }
index f8396a4..b59baa9 100644 (file)
@@ -25,3 +25,4 @@ bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp);
 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed);
 bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under);
 bool tgt_pt(player_type *creature_ptr, POSITION *x, POSITION *y);
+int get_max_range(player_type *creature_ptr);
index 900a20d..59fd400 100644 (file)
@@ -98,7 +98,7 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
 
     for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
         for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
-            if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE
+            if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= get_max_range(caster_ptr)
                 && distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x)
                 && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
                 mirror_y[mirror_num] = y;
index 331426c..a2c8132 100644 (file)
@@ -15,6 +15,7 @@
 #include "effect/effect-characteristics.h"
 #include "game-option/birth-options.h"
 #include "grid/grid.h"
+#include "io/targeting.h"
 #include "monster-floor/monster-move.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags-ability1.h"
@@ -476,7 +477,7 @@ bool clean_shot(player_type *target_ptr, POSITION y1, POSITION x1, POSITION y2,
 {
     floor_type *floor_ptr = target_ptr->current_floor_ptr;
     u16b grid_g[512];
-    int grid_n = project_path(target_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, 0);
+    int grid_n = project_path(target_ptr, grid_g, get_max_range(target_ptr), y1, x1, y2, x2, 0);
     if (!grid_n)
         return FALSE;
 
@@ -1271,7 +1272,7 @@ bool make_attack_spell(MONSTER_IDX m_idx, player_type *target_ptr)
     BIT_FLAGS f5 = r_ptr->a_ability_flags1;
     BIT_FLAGS f6 = r_ptr->a_ability_flags2;
 
-    if ((m_ptr->cdis > MAX_RANGE) && !m_ptr->target_y)
+    if ((m_ptr->cdis > get_max_range(target_ptr)) && !m_ptr->target_y)
         return FALSE;
 
     POSITION x = target_ptr->x;
@@ -1309,14 +1310,14 @@ bool make_attack_spell(MONSTER_IDX m_idx, player_type *target_ptr)
         }
     } else {
         bool success = FALSE;
-        if ((f4 & RF4_BR_DISI) && (m_ptr->cdis < MAX_RANGE / 2) && in_disintegration_range(floor_ptr, m_ptr->fy, m_ptr->fx, y, x)
+        if ((f4 & RF4_BR_DISI) && (m_ptr->cdis < get_max_range(target_ptr) / 2) && in_disintegration_range(floor_ptr, m_ptr->fy, m_ptr->fx, y, x)
             && (one_in_(10) || (projectable(target_ptr, y, x, m_ptr->fy, m_ptr->fx) && one_in_(2)))) {
             do_spell = DO_SPELL_BR_DISI;
             success = TRUE;
-        } else if ((f4 & RF4_BR_LITE) && (m_ptr->cdis < MAX_RANGE / 2) && los(target_ptr, m_ptr->fy, m_ptr->fx, y, x) && one_in_(5)) {
+        } else if ((f4 & RF4_BR_LITE) && (m_ptr->cdis < get_max_range(target_ptr) / 2) && los(target_ptr, m_ptr->fy, m_ptr->fx, y, x) && one_in_(5)) {
             do_spell = DO_SPELL_BR_LITE;
             success = TRUE;
-        } else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= MAX_RANGE)) {
+        } else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= get_max_range(target_ptr))) {
             POSITION by = y, bx = x;
             get_project_point(target_ptr, m_ptr->fy, m_ptr->fx, &by, &bx, 0L);
             if ((distance(by, bx, y, x) <= 3) && los(target_ptr, by, bx, y, x) && one_in_(5)) {
@@ -1338,7 +1339,7 @@ bool make_attack_spell(MONSTER_IDX m_idx, player_type *target_ptr)
                 success = TRUE;
             }
 
-            if (y_br_lite && x_br_lite && (m_ptr->cdis < MAX_RANGE / 2) && one_in_(5)) {
+            if (y_br_lite && x_br_lite && (m_ptr->cdis < get_max_range(target_ptr) / 2) && one_in_(5)) {
                 if (!success) {
                     y = y_br_lite;
                     x = x_br_lite;
index e6d46ed..6d54ff3 100644 (file)
@@ -15,6 +15,7 @@
 #include "effect/effect-characteristics.h"
 #include "floor/floor.h"
 #include "grid/grid.h"
+#include "io/targeting.h"
 #include "main/sound-definitions-table.h"
 #include "monster-floor/monster-move.h"
 #include "monster-race/monster-race.h"
@@ -63,7 +64,7 @@ static bool direct_beam(player_type *target_ptr, POSITION y1, POSITION x1, POSIT
 {
     floor_type *floor_ptr = target_ptr->current_floor_ptr;
     u16b grid_g[512];
-    int grid_n = project_path(target_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, PROJECT_THRU);
+    int grid_n = project_path(target_ptr, grid_g, get_max_range(target_ptr), y1, x1, y2, x2, PROJECT_THRU);
     if (!grid_n)
         return FALSE;
 
@@ -118,7 +119,7 @@ static bool breath_direct(player_type *master_ptr, POSITION y1, POSITION x1, POS
     }
 
     u16b grid_g[512];
-    int grid_n = project_path(master_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, flg);
+    int grid_n = project_path(master_ptr, grid_g, get_max_range(master_ptr), y1, x1, y2, x2, flg);
     int i;
     POSITION y = y1;
     POSITION x = x1;
@@ -200,7 +201,7 @@ static bool breath_direct(player_type *master_ptr, POSITION y1, POSITION x1, POS
 void get_project_point(player_type *target_ptr, POSITION sy, POSITION sx, POSITION *ty, POSITION *tx, BIT_FLAGS flg)
 {
     u16b path_g[128];
-    int path_n = project_path(target_ptr, path_g, MAX_RANGE, sy, sx, *ty, *tx, flg);
+    int path_n = project_path(target_ptr, path_g, get_max_range(target_ptr), sy, sx, *ty, *tx, flg);
     *ty = sy;
     *tx = sx;
     for (int i = 0; i < path_n; i++) {
index ba4aa25..557ca7f 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor.h"
 #include "game-option/map-screen-options.h"
 #include "grid/grid.h"
+#include "io/targeting.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags2.h"
 #include "monster/monster-describer.h"
@@ -11,8 +12,8 @@
 #include "monster/monster-update.h"
 #include "player/player-effects.h"
 #include "player/special-defense-types.h"
-#include "spell/process-effect.h"
 #include "spell-kind/spells-launcher.h"
+#include "spell/process-effect.h"
 #include "spell/spell-types.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -208,7 +209,7 @@ static void cave_temp_room_aux(player_type *caster_ptr, POSITION y, POSITION x,
             return;
         if (!in_bounds2(floor_ptr, y, x))
             return;
-        if (distance(caster_ptr->y, caster_ptr->x, y, x) > MAX_RANGE)
+        if (distance(caster_ptr->y, caster_ptr->x, y, x) > get_max_range(caster_ptr))
             return;
 
         /* Verify this grid */
index 18ae2cc..b8d7267 100644 (file)
@@ -45,7 +45,7 @@ bool cast_wrath_of_the_god(player_type *caster_ptr, HIT_POINT dam, POSITION rad)
                ny = y;
                nx = x;
                mmove2(&ny, &nx, caster_ptr->y, caster_ptr->x, ty, tx);
-               if (MAX_RANGE <= distance(caster_ptr->y, caster_ptr->x, ny, nx)) break;
+               if (get_max_range(caster_ptr) <= distance(caster_ptr->y, caster_ptr->x, ny, nx)) break;
                if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT)) break;
                if ((dir != 5) && caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx != 0) break;
 
index 3ae125f..18a59b1 100644 (file)
@@ -11,6 +11,7 @@
 #include "grid/feature.h"
 #include "io/cursor.h"
 #include "io/screen-util.h"
+#include "io/targeting.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "monster-race/monster-race.h"
@@ -172,7 +173,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
     }
 
     /* Calculate the projection path */
-    path_n = project_path(caster_ptr, path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flag);
+    path_n = project_path(caster_ptr, path_g, (project_length ? project_length : get_max_range(caster_ptr)), y1, x1, y2, x2, flag);
     handle_stuff(caster_ptr);
 
     if (typ == GF_SEEKER) {
@@ -225,7 +226,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
             monster_target_x = x;
             remove_mirror(caster_ptr, y, x);
             next_mirror(caster_ptr, &oy, &ox, y, x);
-            path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flag);
+            path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, oy, ox, flag);
             for (j = last_i; j <= i; j++) {
                 y = GRID_Y(path_g[j]);
                 x = GRID_X(path_g[j]);
@@ -331,14 +332,14 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
 
                 path_n = i;
                 second_step = i + 1;
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x - 1, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x + 1, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x - 1, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x + 1, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x - 1, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x, flag);
-                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x + 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x - 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x + 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y, x - 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y, x + 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x - 1, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x, flag);
+                path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x + 1, flag);
             }
         }
 
@@ -435,7 +436,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
     project_length = 0;
 
     /* If we found a "target", explode there */
-    if (dist <= MAX_RANGE) {
+    if (dist <= get_max_range(caster_ptr)) {
         if ((flag & (PROJECT_BEAM)) && (grids > 0))
             grids--;
 
index 38738d8..4ccf714 100644 (file)
@@ -233,7 +233,7 @@ void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
         tx = target_col;
         ty = target_row;
 
-        if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) {
+        if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr)) {
             msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
             return;
         }
@@ -269,7 +269,8 @@ void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
             tx += ddx[dir];
             g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
 
-            if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) || !cave_have_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT))
+            if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr))
+                || !cave_have_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT))
                 return;
         }
     }
@@ -1121,7 +1122,7 @@ bool fetch_monster(player_type *caster_ptr)
     m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
     monster_desc(caster_ptr, m_name, m_ptr, 0);
     msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
-    path_n = project_path(caster_ptr, path_g, MAX_RANGE, target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
+    path_n = project_path(caster_ptr, path_g, get_max_range(caster_ptr), target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
     ty = target_row, tx = target_col;
     for (i = 1; i < path_n; i++) {
         POSITION ny = GRID_Y(path_g[i]);
index 007918e..5de40f5 100644 (file)
 */
 #define MAX_SIGHT       20      /*!< プレイヤーの最大視界範囲(マス) / Maximum view distance */
 
-/*!
- * todo この関数マクロをどこに置くべきか迷ったので保留
- * !< プレイヤーの攻撃射程(マス) / Maximum range (spells, etc)
- */
-#define MAX_RANGE       (p_ptr->phase_out ? 36 : 18)
 #define AAF_LIMIT       100     /*!< モンスターの限界感知範囲(マス) Limit of sensing radius */
 
 #define MIN_M_ALLOC_TD          4 /*!< 街(昼間)の最低住人配置数 / The town starts out with 4 residents during the day */