OSDN Git Service

[Refactor] #40514 have_esp_evil() を calc_bonuses() から分離. / Separated have_esp_evil...
authordeskull <deskull@users.sourceforge.jp>
Sun, 26 Jul 2020 07:06:28 +0000 (16:06 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 26 Jul 2020 07:06:28 +0000 (16:06 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index c289a74..1ca5e4b 100644 (file)
@@ -1,7 +1,10 @@
 #include "player/player-status.h"
 #include "player/player-race.h"
 #include "player/player-race-types.h"
+#include "realm/realm-hex-numbers.h"
+#include "realm/realm-types.h"
 #include "realm/realm-song-numbers.h"
+#include "spell-realm/spells-hex.h"
 #include "system/monster-type-definition.h"
 #include "monster-race/race-flags2.h"
 #include "monster-race/monster-race.h"
@@ -72,3 +75,27 @@ void have_xtra_might(player_type *creature_ptr)
             creature_ptr->xtra_might = TRUE;
     }
 }
+
+void have_esp_evil(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+
+    creature_ptr->esp_evil = FALSE;
+
+    if (creature_ptr->realm1 == REALM_HEX) {
+        if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
+            creature_ptr->esp_evil = TRUE;
+    }
+
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_ESP_EVIL))
+            creature_ptr->esp_evil = TRUE;
+    }
+}
index f4542b8..73abdfc 100644 (file)
@@ -3,4 +3,6 @@
 void have_pass_wall(player_type *creature_ptr);
 void have_kill_wall(player_type *creature_ptr);
 void have_xtra_might(player_type *creature_ptr);
+void have_esp_evil(player_type *creature_ptr);
+
 
index b5c142e..07908c5 100644 (file)
@@ -586,7 +586,6 @@ static void clear_creature_bonuses(player_type *creature_ptr)
     creature_ptr->esp_giant = FALSE;
     creature_ptr->esp_dragon = FALSE;
     creature_ptr->esp_human = FALSE;
-    creature_ptr->esp_evil = FALSE;
     creature_ptr->esp_good = FALSE;
     creature_ptr->esp_nonliving = FALSE;
     creature_ptr->esp_unique = FALSE;
@@ -710,6 +709,8 @@ void calc_bonuses(player_type *creature_ptr)
 
     have_pass_wall(creature_ptr);
     have_kill_wall(creature_ptr);
+    have_xtra_might(creature_ptr);
+    have_esp_evil(creature_ptr);
 
     calc_race_status(creature_ptr);
 
@@ -768,8 +769,6 @@ void calc_bonuses(player_type *creature_ptr)
         creature_ptr->lite = TRUE;
 
     if (creature_ptr->realm1 == REALM_HEX) {
-        if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
-            creature_ptr->esp_evil = TRUE;
 
         if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) {
             creature_ptr->sh_fire = TRUE;
@@ -4721,8 +4720,6 @@ void calc_equipment_status(player_type *creature_ptr)
             creature_ptr->esp_dragon = TRUE;
         if (have_flag(flgs, TR_ESP_HUMAN))
             creature_ptr->esp_human = TRUE;
-        if (have_flag(flgs, TR_ESP_EVIL))
-            creature_ptr->esp_evil = TRUE;
         if (have_flag(flgs, TR_ESP_GOOD))
             creature_ptr->esp_good = TRUE;
         if (have_flag(flgs, TR_ESP_NONLIVING))