OSDN Git Service

[Refactor] #40734 Separated check_invisible() from update_monster()
authorHourier <hourier@users.sourceforge.jp>
Sun, 13 Sep 2020 12:42:24 +0000 (21:42 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 13 Sep 2020 13:36:45 +0000 (22:36 +0900)
src/monster/monster-update.c

index 1e2cd89..6d984a7 100644 (file)
@@ -332,7 +332,8 @@ static bool check_cold_blood(player_type *subject_ptr, um_type *um_ptr)
     if (distance > subject_ptr->see_infra)
         return FALSE;
 
-    if ((r_info[um_ptr->m_ptr->r_idx].flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
+    monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
+    if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) != RF2_COLD_BLOOD)
         return TRUE;
 
     um_ptr->easy = TRUE;
@@ -340,6 +341,25 @@ static bool check_cold_blood(player_type *subject_ptr, um_type *um_ptr)
     return TRUE;
 }
 
+static bool check_invisible(player_type *subject_ptr, um_type *um_ptr)
+{
+    if (!player_can_see_bold(subject_ptr, um_ptr->fy, um_ptr->fx))
+        return FALSE;
+    
+    monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
+    if (r_ptr->flags2 & RF2_INVISIBLE) {
+        if (subject_ptr->see_inv) {
+            um_ptr->easy = TRUE;
+            um_ptr->flag = TRUE;
+        }
+    } else {
+        um_ptr->easy = TRUE;
+        um_ptr->flag = TRUE;
+    }
+
+    return TRUE;
+}
+
 /*!
  * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
  * @param m_idx 更新するモンスター情報のID
@@ -374,19 +394,7 @@ void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
             }
             
             bool do_cold_blood = check_cold_blood(subject_ptr, um_ptr);
-            bool do_invisible = FALSE;
-            if (player_can_see_bold(subject_ptr, um_ptr->fy, um_ptr->fx))
-                if (r_ptr->flags2 & RF2_INVISIBLE) {
-                    do_invisible = TRUE;
-                    if (subject_ptr->see_inv) {
-                        um_ptr->easy = TRUE;
-                        um_ptr->flag = TRUE;
-                    }                    
-                } else {
-                    um_ptr->easy = TRUE;
-                    um_ptr->flag = TRUE;
-                }
-                
+            bool do_invisible = check_invisible(subject_ptr, um_ptr);                
             if (um_ptr->flag && is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
                 if (do_invisible)
                     r_ptr->r_flags2 |= RF2_INVISIBLE;