OSDN Git Service

[refactor] repair_monstersフラグの削除
authorHabu <habu1010+github@gmail.com>
Wed, 3 Mar 2021 12:47:30 +0000 (21:47 +0900)
committerHabu <habu1010+github@gmail.com>
Wed, 3 Mar 2021 12:50:52 +0000 (21:50 +0900)
プレイヤーの行動処理中に一時的にモンスターにフラグを
設定しておき、プレイヤーの行動後にまとめてモンスターの
処理を行う時に、この処理が必要かどうかを設定する
repair_monstersというグローバル変数のフラグがある。
しかし、このフラグが設定されていない場合に軽減できる
処理は雀の涙程度のものでしかなく、しかも今後同様の
モンスターをフラグを立てておくような処理を追加する
たびに、そのすべての場所でrepair_monstersをTRUEに
設定する必要がある。
はっきり言ってコストにリターンが見合っていないので
repair_monstersを削除する。

src/core/player-processor.c
src/dungeon/dungeon-processor.c
src/floor/floor-changer.c
src/floor/floor-save-util.c
src/floor/floor-save-util.h
src/monster-floor/one-monster-placer.c
src/spell-kind/spells-detection.c

index 42bcb88..7613dbf 100644 (file)
@@ -43,6 +43,7 @@
 #include "status/action-setter.h"
 #include "system/floor-type-definition.h"
 #include "term/screen-processor.h"
+#include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 #include "window/display-sub-windows.h"
 #include "world/world-turn-processor.h"
@@ -315,43 +316,34 @@ void process_player(player_type *creature_ptr)
                 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
                 if (!monster_is_valid(m_ptr))
                     continue;
-                if (!m_ptr->ml)
-                    continue;
 
                 r_ptr = &r_info[m_ptr->ap_r_idx];
-                if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
-                    continue;
-
-                lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx);
-            }
 
-            if (repair_monsters) {
-                repair_monsters = FALSE;
-                for (MONSTER_IDX m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) {
-                    monster_type *m_ptr;
-                    m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
-                    if (!monster_is_valid(m_ptr))
-                        continue;
+                // モンスターのシンボル/カラーの更新
+                if (m_ptr->ml && any_bits(r_ptr->flags1, (RF1_ATTR_MULTI | RF1_SHAPECHANGER))) {
+                    lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx);
+                }
 
-                    if (m_ptr->mflag & MFLAG_PREVENT_MAGIC) {
-                        m_ptr->mflag &= ~(MFLAG_PREVENT_MAGIC);
-                    }
+                // 出現して即魔法を使わないようにするフラグを落とす処理
+                if (m_ptr->mflag & MFLAG_PREVENT_MAGIC) {
+                    m_ptr->mflag &= ~(MFLAG_PREVENT_MAGIC);
+                }
 
-                    if (m_ptr->mflag2 & MFLAG2_MARK) {
-                        if (m_ptr->mflag2 & MFLAG2_SHOW) {
-                            m_ptr->mflag2 &= ~(MFLAG2_SHOW);
-                            repair_monsters = TRUE;
-                        } else {
-                            m_ptr->mflag2 &= ~(MFLAG2_MARK);
-                            m_ptr->ml = FALSE;
-                            update_monster(creature_ptr, m_idx, FALSE);
-                            if (creature_ptr->health_who == m_idx)
-                                creature_ptr->redraw |= (PR_HEALTH);
-                            if (creature_ptr->riding == m_idx)
-                                creature_ptr->redraw |= (PR_UHEALTH);
-
-                            lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx);
-                        }
+                // 感知中のモンスターのフラグを落とす処理
+                // 感知したターンはMFLAG2_SHOWを落とし、次のターンに感知中フラグのMFLAG2_MARKを落とす
+                if (m_ptr->mflag2 & MFLAG2_MARK) {
+                    if (m_ptr->mflag2 & MFLAG2_SHOW) {
+                        m_ptr->mflag2 &= ~(MFLAG2_SHOW);
+                    } else {
+                        m_ptr->mflag2 &= ~(MFLAG2_MARK);
+                        m_ptr->ml = FALSE;
+                        update_monster(creature_ptr, m_idx, FALSE);
+                        if (creature_ptr->health_who == m_idx)
+                            creature_ptr->redraw |= (PR_HEALTH);
+                        if (creature_ptr->riding == m_idx)
+                            creature_ptr->redraw |= (PR_UHEALTH);
+
+                        lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx);
                     }
                 }
             }
index 07bbe6f..f0a8f74 100644 (file)
@@ -69,7 +69,6 @@ void process_dungeon(player_type *player_ptr, bool load_game)
     player_ptr->riding_t_m_idx = 0;
     player_ptr->ambush_flag = FALSE;
     health_track(player_ptr, 0);
-    repair_monsters = TRUE;
 
     disturb(player_ptr, TRUE, TRUE);
     int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level);
index 774da8d..31f533c 100644 (file)
@@ -110,7 +110,6 @@ static void set_pet_params(player_type *master_ptr, monster_race **r_ptr, const
     m_ptr->target_y = 0;
     if (((*r_ptr)->flags1 & RF1_PREVENT_SUDDEN_MAGIC) && !ironman_nightmare) {
         m_ptr->mflag |= MFLAG_PREVENT_MAGIC;
-        repair_monsters = TRUE;
     }
 }
 
index 22b727a..73923ed 100644 (file)
@@ -6,7 +6,6 @@
  */
 u32b saved_floor_file_sign;
 saved_floor_type saved_floors[MAX_SAVED_FLOORS];
-bool repair_monsters;
 FLOOR_IDX max_floor_id; /*!< Number of floor_id used from birth */
 FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */
 u32b latest_visit_mark; /*!<フロアを渡った回数?(確認中) / Max number of visit_mark */
index ddf1b8a..281d204 100644 (file)
@@ -18,7 +18,6 @@ typedef struct saved_floor_type {
 
 extern u32b saved_floor_file_sign;
 extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
-extern bool repair_monsters;
 extern FLOOR_IDX max_floor_id;
 
 extern FLOOR_IDX new_floor_id;
index cdb047f..553d7c8 100644 (file)
@@ -359,7 +359,6 @@ bool place_monster_one(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
 
     if ((r_ptr->flags1 & RF1_PREVENT_SUDDEN_MAGIC) && !ironman_nightmare) {
         m_ptr->mflag |= (MFLAG_PREVENT_MAGIC);
-        repair_monsters = TRUE;
     }
 
     if (g_ptr->m_idx < hack_m_idx) {
index 7617d2e..6dbd3d5 100644 (file)
@@ -322,7 +322,6 @@ bool detect_monsters_normal(player_type *caster_ptr, POSITION range)
             continue;
 
         if (!(r_ptr->flags2 & RF2_INVISIBLE) || caster_ptr->see_inv) {
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -368,7 +367,6 @@ bool detect_monsters_invis(player_type *caster_ptr, POSITION range)
                 caster_ptr->window_flags |= (PW_MONSTER);
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -416,7 +414,6 @@ bool detect_monsters_evil(player_type *caster_ptr, POSITION range)
                 }
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -457,7 +454,6 @@ bool detect_monsters_nonliving(player_type *caster_ptr, POSITION range)
                 caster_ptr->window_flags |= (PW_MONSTER);
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -500,7 +496,6 @@ bool detect_monsters_mind(player_type *caster_ptr, POSITION range)
                 caster_ptr->window_flags |= (PW_MONSTER);
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -544,7 +539,6 @@ bool detect_monsters_string(player_type *caster_ptr, POSITION range, concptr Mat
                 caster_ptr->window_flags |= (PW_MONSTER);
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;
@@ -593,7 +587,6 @@ bool detect_monsters_xxx(player_type *caster_ptr, POSITION range, u32b match_fla
                 }
             }
 
-            repair_monsters = TRUE;
             m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
             update_monster(caster_ptr, i, FALSE);
             flag = TRUE;