OSDN Git Service

[Refactor] #2680 MAX_SIGHTとAAF_LIMITが分かりにくかったので分かりやすい定数名に変更した
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 30 Oct 2022 14:42:01 +0000 (23:42 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Thu, 3 Nov 2022 00:55:51 +0000 (09:55 +0900)
26 files changed:
src/cmd-item/cmd-zaprod.cpp
src/cmd-item/cmd-zapwand.cpp
src/effect/effect-monster-util.cpp
src/floor/wild.cpp
src/melee/melee-postprocess.cpp
src/melee/melee-util.cpp
src/melee/monster-attack-monster.cpp
src/monster-floor/monster-lite.cpp
src/monster-floor/monster-move.cpp
src/monster-floor/monster-sweep-grid.cpp
src/monster/monster-processor.cpp
src/monster/monster-status.cpp
src/monster/monster-update.cpp
src/mspell/mspell-floor.cpp
src/mspell/mspell-util.cpp
src/player/player-view.cpp
src/realm/realm-crusade.cpp
src/realm/realm-hex.cpp
src/realm/realm-hissatsu.cpp
src/spell-kind/spells-genocide.cpp
src/spell-kind/spells-sight.cpp
src/spell-kind/spells-teleport.cpp
src/spell-realm/spells-hex.cpp
src/system/gamevalue.h
src/wizard/wizard-special-process.cpp
src/world/world-turn-processor.cpp

index 09c0e55..5adcf48 100644 (file)
@@ -157,7 +157,7 @@ int rod_effect(PlayerType *player_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir,
     }
 
     case SV_ROD_TELEPORT_AWAY: {
-        int distance = MAX_SIGHT * (powerful ? 8 : 5);
+        int distance = MAX_PLAYER_SIGHT * (powerful ? 8 : 5);
         if (teleport_monster(player_ptr, dir, distance)) {
             ident = true;
         }
index e0d3c70..8d5ddd2 100644 (file)
@@ -109,7 +109,7 @@ bool wand_effect(PlayerType *player_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION di
     }
 
     case SV_WAND_TELEPORT_AWAY: {
-        int distance = MAX_SIGHT * (powerful ? 8 : 5);
+        int distance = MAX_PLAYER_SIGHT * (powerful ? 8 : 5);
         if (teleport_monster(player_ptr, dir, distance)) {
             ident = true;
         }
index 6f39b44..cc8245e 100644 (file)
@@ -66,7 +66,7 @@ effect_monster_type *initialize_effect_monster(PlayerType *player_ptr, effect_mo
     em_ptr->seen_msg = is_seen(player_ptr, em_ptr->m_ptr);
     em_ptr->slept = em_ptr->m_ptr->is_asleep();
     em_ptr->obvious = false;
-    em_ptr->known = ((em_ptr->m_ptr->cdis <= MAX_SIGHT) || player_ptr->phase_out);
+    em_ptr->known = ((em_ptr->m_ptr->cdis <= MAX_PLAYER_SIGHT) || player_ptr->phase_out);
     em_ptr->skipped = false;
     em_ptr->get_angry = false;
     em_ptr->do_polymorph = false;
index 1d2a5ee..1cf6d6b 100644 (file)
@@ -929,7 +929,7 @@ bool change_wild_mode(PlayerType *player_ptr, bool encount)
             has_pet = true;
         }
 
-        if (m_ptr->is_asleep() || (m_ptr->cdis > MAX_SIGHT) || !m_ptr->is_hostile()) {
+        if (m_ptr->is_asleep() || (m_ptr->cdis > MAX_PLAYER_SIGHT) || !m_ptr->is_hostile()) {
             continue;
         }
 
index a48b0e7..ec19298 100644 (file)
@@ -66,7 +66,7 @@ mam_pp_type *initialize_mam_pp_type(
     mam_pp_ptr->m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
     mam_pp_ptr->seen = is_seen(player_ptr, mam_pp_ptr->m_ptr);
     mam_pp_ptr->dam = dam;
-    mam_pp_ptr->known = mam_pp_ptr->m_ptr->cdis <= MAX_SIGHT;
+    mam_pp_ptr->known = mam_pp_ptr->m_ptr->cdis <= MAX_PLAYER_SIGHT;
     mam_pp_ptr->dead = dead;
     mam_pp_ptr->fear = fear;
     mam_pp_ptr->note = note;
index dfddd5d..38d9cc3 100644 (file)
@@ -34,7 +34,7 @@ mam_type *initialize_mam_type(PlayerType *player_ptr, mam_type *mam_ptr, MONSTER
     mam_ptr->do_silly_attack = (one_in_(2) && player_ptr->effects()->hallucination()->is_hallucinated());
     mam_ptr->power = 0;
     mam_ptr->obvious = false;
-    mam_ptr->known = (mam_ptr->m_ptr->cdis <= MAX_SIGHT) || (mam_ptr->t_ptr->cdis <= MAX_SIGHT);
+    mam_ptr->known = (mam_ptr->m_ptr->cdis <= MAX_PLAYER_SIGHT) || (mam_ptr->t_ptr->cdis <= MAX_PLAYER_SIGHT);
     mam_ptr->fear = false;
     mam_ptr->dead = false;
     return mam_ptr;
index bff37a2..80bb26c 100644 (file)
@@ -272,7 +272,7 @@ static void thief_runaway_by_melee(PlayerType *player_ptr, mam_type *mam_ptr)
             player_ptr->current_floor_ptr->monster_noise = true;
         }
 
-        teleport_away(player_ptr, mam_ptr->m_idx, MAX_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
+        teleport_away(player_ptr, mam_ptr->m_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
     }
 }
 
index 090e809..3334552 100644 (file)
@@ -151,7 +151,7 @@ void update_mon_lite(PlayerType *player_ptr)
     std::vector<Pos2D> points;
 
     void (*add_mon_lite)(PlayerType *, std::vector<Pos2D> &, const POSITION, const POSITION, const monster_lite_type *);
-    int dis_lim = (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::DARKNESS) && !player_ptr->see_nocto) ? (MAX_SIGHT / 2 + 1) : (MAX_SIGHT + 3);
+    int dis_lim = (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::DARKNESS) && !player_ptr->see_nocto) ? (MAX_PLAYER_SIGHT / 2 + 1) : (MAX_PLAYER_SIGHT + 3);
     auto *floor_ptr = player_ptr->current_floor_ptr;
     for (int i = 0; i < floor_ptr->mon_lite_n; i++) {
         grid_type *g_ptr;
index bee70c9..274567a 100644 (file)
@@ -518,7 +518,7 @@ void process_speak_sound(PlayerType *player_ptr, MONSTER_IDX m_idx, POSITION oy,
     }
 
     auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
-    if (m_ptr->ap_r_idx == MonsterRaceId::CYBER && one_in_(CYBERNOISE) && !m_ptr->ml && (m_ptr->cdis <= MAX_SIGHT)) {
+    if (m_ptr->ap_r_idx == MonsterRaceId::CYBER && one_in_(CYBERNOISE) && !m_ptr->ml && (m_ptr->cdis <= MAX_PLAYER_SIGHT)) {
         if (disturb_minor) {
             disturb(player_ptr, false, false);
         }
index fb73a1e..80f0380 100644 (file)
@@ -103,7 +103,7 @@ bool MonsterSweepGrid::mon_will_run()
         return (this->player_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - this->player_ptr->pet_follow_distance));
     }
 
-    if (m_ptr->cdis > MAX_SIGHT + 5) {
+    if (m_ptr->cdis > MAX_PLAYER_SIGHT + 5) {
         return false;
     }
 
@@ -144,7 +144,7 @@ void MonsterSweepGrid::check_hiding_grid(POSITION *y, POSITION *x, POSITION *y2,
     }
 
     if ((!los(this->player_ptr, m_ptr->fy, m_ptr->fx, this->player_ptr->y, this->player_ptr->x) || !projectable(this->player_ptr, m_ptr->fy, m_ptr->fx, this->player_ptr->y, this->player_ptr->x))) {
-        if (floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].get_distance(r_ptr) >= MAX_SIGHT / 2) {
+        if (floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].get_distance(r_ptr) >= MAX_PLAYER_SIGHT / 2) {
             return;
         }
     }
index 724ca26..fb4f604 100644 (file)
@@ -597,7 +597,7 @@ void sweep_monster_process(PlayerType *player_ptr)
             continue;
         }
 
-        if ((m_ptr->cdis >= AAF_LIMIT) || !decide_process_continue(player_ptr, m_ptr)) {
+        if ((m_ptr->cdis >= MAX_MONSTER_SENSING) || !decide_process_continue(player_ptr, m_ptr)) {
             continue;
         }
 
@@ -635,11 +635,11 @@ bool decide_process_continue(PlayerType *player_ptr, monster_type *m_ptr)
         m_ptr->mflag2.reset(MonsterConstantFlagType::NOFLOW);
     }
 
-    if (m_ptr->cdis <= (m_ptr->is_pet() ? (r_ptr->aaf > MAX_SIGHT ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
+    if (m_ptr->cdis <= (m_ptr->is_pet() ? (r_ptr->aaf > MAX_PLAYER_SIGHT ? MAX_PLAYER_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
         return true;
     }
 
-    if ((m_ptr->cdis <= MAX_SIGHT || player_ptr->phase_out) && (player_has_los_bold(player_ptr, m_ptr->fy, m_ptr->fx) || has_aggravate(player_ptr))) {
+    if ((m_ptr->cdis <= MAX_PLAYER_SIGHT || player_ptr->phase_out) && (player_has_los_bold(player_ptr, m_ptr->fy, m_ptr->fx) || has_aggravate(player_ptr))) {
         return true;
     }
 
index 0335882..4411a97 100644 (file)
@@ -169,14 +169,14 @@ static void process_monsters_mtimed_aux(PlayerType *player_ptr, MONSTER_IDX m_id
     case MTIMED_CSLEEP: {
         auto *r_ptr = &monraces_info[m_ptr->r_idx];
         auto is_wakeup = false;
-        if (m_ptr->cdis < AAF_LIMIT) {
+        if (m_ptr->cdis < MAX_MONSTER_SENSING) {
             /* Handle "sensing radius" */
-            if (m_ptr->cdis <= (m_ptr->is_pet() ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
+            if (m_ptr->cdis <= (m_ptr->is_pet() ? ((r_ptr->aaf > MAX_PLAYER_SIGHT) ? MAX_PLAYER_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
                 is_wakeup = true;
             }
 
             /* Handle "sight" and "aggravation" */
-            else if ((m_ptr->cdis <= MAX_SIGHT) && (player_has_los_bold(player_ptr, m_ptr->fy, m_ptr->fx))) {
+            else if ((m_ptr->cdis <= MAX_PLAYER_SIGHT) && (player_has_los_bold(player_ptr, m_ptr->fy, m_ptr->fx))) {
                 is_wakeup = true;
             }
         }
@@ -199,7 +199,7 @@ static void process_monsters_mtimed_aux(PlayerType *player_ptr, MONSTER_IDX m_id
 
         /* Hack -- amount of "waking" */
         /* Wake up faster near the player */
-        auto d = (m_ptr->cdis < AAF_LIMIT / 2) ? (AAF_LIMIT / m_ptr->cdis) : 1;
+        auto d = (m_ptr->cdis < MAX_MONSTER_SENSING / 2) ? (MAX_MONSTER_SENSING / m_ptr->cdis) : 1;
 
         /* Hack -- amount of "waking" is affected by speed of player */
         d = (d * speed_to_energy(player_ptr->pspeed)) / 10;
index 9037c0c..06ae626 100644 (file)
@@ -439,11 +439,11 @@ static void decide_sight_invisible_monster(PlayerType *player_ptr, um_type *um_p
 
     m_ptr->mflag.reset(MonsterTemporaryFlagType::ESP);
 
-    if (distance > (um_ptr->in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT)) {
+    if (distance > (um_ptr->in_darkness ? MAX_PLAYER_SIGHT / 2 : MAX_PLAYER_SIGHT)) {
         return;
     }
 
-    if (!um_ptr->in_darkness || (distance <= MAX_SIGHT / 4)) {
+    if (!um_ptr->in_darkness || (distance <= MAX_PLAYER_SIGHT / 4)) {
         update_telepathy_sight(player_ptr, um_ptr, m_idx);
         update_specific_race_telepathy(player_ptr, um_ptr);
     }
index 86e44e3..02ba0d8 100644 (file)
@@ -314,9 +314,9 @@ MonsterSpellResult spell_RF6_TELE_AWAY(PlayerType *player_ptr, MONSTER_IDX m_idx
     }
 
     if (t_idx == player_ptr->riding) {
-        teleport_player_away(m_idx, player_ptr, MAX_SIGHT * 2 + 5, false);
+        teleport_player_away(m_idx, player_ptr, MAX_PLAYER_SIGHT * 2 + 5, false);
     } else {
-        teleport_away(player_ptr, t_idx, MAX_SIGHT * 2 + 5, TELEPORT_PASSIVE);
+        teleport_away(player_ptr, t_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_PASSIVE);
     }
     set_monster_csleep(player_ptr, t_idx, 0);
 
index 550ddec..7eecf54 100644 (file)
@@ -54,7 +54,7 @@ bool monster_near_player(FloorType *floor_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_
 {
     monster_type *m_ptr = &floor_ptr->m_list[m_idx];
     monster_type *t_ptr = &floor_ptr->m_list[t_idx];
-    return (m_ptr->cdis <= MAX_SIGHT) || (t_ptr->cdis <= MAX_SIGHT);
+    return (m_ptr->cdis <= MAX_PLAYER_SIGHT) || (t_ptr->cdis <= MAX_PLAYER_SIGHT);
 }
 
 /*!
index 6cd5794..24d81f9 100644 (file)
@@ -116,11 +116,11 @@ void update_view(PlayerType *player_ptr)
 
     grid_type *g_ptr;
     if (view_reduce_view && !floor_ptr->dun_level) {
-        full = MAX_SIGHT / 2;
-        over = MAX_SIGHT * 3 / 4;
+        full = MAX_PLAYER_SIGHT / 2;
+        over = MAX_PLAYER_SIGHT * 3 / 4;
     } else {
-        full = MAX_SIGHT;
-        over = MAX_SIGHT * 3 / 2;
+        full = MAX_PLAYER_SIGHT;
+        over = MAX_PLAYER_SIGHT * 3 / 2;
     }
 
     for (n = 0; n < floor_ptr->view_n; n++) {
index 08d07b1..4f8c2c4 100644 (file)
@@ -213,7 +213,7 @@ concptr do_crusade_spell(PlayerType *player_ptr, SPELL_IDX spell, SpellProcessTy
         }
 
         {
-            int power = MAX_SIGHT * 5;
+            int power = MAX_PLAYER_SIGHT * 5;
             if (info) {
                 return info_power(power);
             }
index a4a8729..a8539e6 100644 (file)
@@ -265,7 +265,7 @@ concptr do_hex_spell(PlayerType *player_ptr, spell_hex_type spell, SpellProcessT
             return _("周囲の邪悪なモンスターを感知する。", "Detects evil monsters.");
         }
         if (info) {
-            return info_range(MAX_SIGHT);
+            return info_range(MAX_PLAYER_SIGHT);
         }
         if (cast) {
             msg_print(_("邪悪な生物の存在を感じ取ろうとした。", "You sense the presence of evil creatures."));
index e5f45cc..351badd 100644 (file)
@@ -982,7 +982,7 @@ concptr do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX spell, SpellProcessT
                 return nullptr;
             }
 
-            if (!cave_player_teleportable_bold(player_ptr, y, x, TELEPORT_SPONTANEOUS) || (distance(y, x, player_ptr->y, player_ptr->x) > MAX_SIGHT / 2) || !projectable(player_ptr, player_ptr->y, player_ptr->x, y, x)) {
+            if (!cave_player_teleportable_bold(player_ptr, y, x, TELEPORT_SPONTANEOUS) || (distance(y, x, player_ptr->y, player_ptr->x) > MAX_PLAYER_SIGHT / 2) || !projectable(player_ptr, player_ptr->y, player_ptr->x, y, x)) {
                 msg_print(_("失敗!", "You cannot move to that place!"));
                 break;
             }
index 54e9488..98cb8cf 100644 (file)
@@ -179,7 +179,7 @@ bool mass_genocide(PlayerType *player_ptr, int power, bool player_cast)
         if (!m_ptr->is_valid()) {
             continue;
         }
-        if (m_ptr->cdis > MAX_SIGHT) {
+        if (m_ptr->cdis > MAX_PLAYER_SIGHT) {
             continue;
         }
 
@@ -220,7 +220,7 @@ bool mass_genocide_undead(PlayerType *player_ptr, int power, bool player_cast)
         if (r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD)) {
             continue;
         }
-        if (m_ptr->cdis > MAX_SIGHT) {
+        if (m_ptr->cdis > MAX_PLAYER_SIGHT) {
             continue;
         }
 
index 5902e77..06b7167 100644 (file)
@@ -227,7 +227,7 @@ void aggravate_monsters(PlayerType *player_ptr, MONSTER_IDX who)
             continue;
         }
 
-        if (m_ptr->cdis < MAX_SIGHT * 2) {
+        if (m_ptr->cdis < MAX_PLAYER_SIGHT * 2) {
             if (m_ptr->is_asleep()) {
                 (void)set_monster_csleep(player_ptr, i, 0);
                 sleep = true;
index 1bb77e0..e84c152 100644 (file)
@@ -538,10 +538,10 @@ void teleport_away_followable(PlayerType *player_ptr, MONSTER_IDX m_idx)
     bool old_ml = m_ptr->ml;
     POSITION old_cdis = m_ptr->cdis;
 
-    teleport_away(player_ptr, m_idx, MAX_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
+    teleport_away(player_ptr, m_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
 
     bool is_followable = old_ml;
-    is_followable &= old_cdis <= MAX_SIGHT;
+    is_followable &= old_cdis <= MAX_PLAYER_SIGHT;
     is_followable &= w_ptr->timewalk_m_idx == 0;
     is_followable &= !player_ptr->phase_out;
     is_followable &= los(player_ptr, player_ptr->y, player_ptr->x, oldfy, oldfx);
index 7115823..30ee636 100644 (file)
@@ -382,7 +382,7 @@ void SpellHex::thief_teleport()
         msg_print(_("泥棒は笑って逃げ...ようとしたがバリアに防がれた。", "The thief flees laughing...? But a magic barrier obstructs it."));
     } else {
         msg_print(_("泥棒は笑って逃げた!", "The thief flees laughing!"));
-        teleport_away(this->player_ptr, this->monap_ptr->m_idx, MAX_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
+        teleport_away(this->player_ptr, this->monap_ptr->m_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_SPONTANEOUS);
     }
 }
 
index 82fb8f7..b523d23 100644 (file)
 #define FUEL_TORCH 5000 /*!< 松明の基本寿命値 / Maximum amount of fuel in a torch */
 #define FUEL_LAMP 15000 /*!< ランタンの基本寿命値 / Maximum amount of fuel in a lantern */
 
-/*
- * More maximum values
- */
-#define MAX_SIGHT 20 /*!< プレイヤーの最大視界範囲(マス) / Maximum view distance */
-
-#define AAF_LIMIT 100 /*!< モンスターの限界感知範囲(マス) Limit of sensing radius */
-
 #define MAX_SKILLS 10
 
 #define TY_CURSE_CHANCE 200 /*!<太古の怨念の1ターン毎の発動確率(1/n)*/
@@ -61,6 +54,9 @@
 #define MON_DRAIN_LIFE 2 /*!< モンスターの打撃によるプレイヤーの経験値吸収基本倍率(%) / Percent of player exp drained per hit */
 #define USE_DEVICE 3 /*!< 魔道具の最低失敗基準値 x> Harder devices x< Easier devices     */
 
+constexpr auto MAX_PLAYER_SIGHT = 20; /*!< プレイヤーの最大視界グリッド数 */
+constexpr auto MAX_MONSTER_SENSING = 100; /*!< モンスターの最大感知グリッド数 */
+
 /*!
  * @brief 1フロアに存在可能な、増殖フラグ付きモンスター実体の最大数
  * @details 呪術や突然変異で増殖阻止状態にすると、
index ab67210..487605a 100644 (file)
@@ -820,7 +820,7 @@ void wiz_zap_surrounding_monsters(PlayerType *player_ptr)
 {
     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!m_ptr->is_valid() || (i == player_ptr->riding) || (m_ptr->cdis > MAX_SIGHT)) {
+        if (!m_ptr->is_valid() || (i == player_ptr->riding) || (m_ptr->cdis > MAX_PLAYER_SIGHT)) {
             continue;
         }
 
index 8b79b8a..854912f 100644 (file)
@@ -307,7 +307,7 @@ void WorldTurnProcessor::decide_alloc_monster()
     should_alloc &= !inside_quest(floor_ptr->quest_number);
     should_alloc &= !this->player_ptr->phase_out;
     if (should_alloc) {
-        (void)alloc_monster(this->player_ptr, MAX_SIGHT + 5, 0, summon_specific);
+        (void)alloc_monster(this->player_ptr, MAX_PLAYER_SIGHT + 5, 0, summon_specific);
     }
 }