OSDN Git Service

[Refactor] #40514 has_resist_chaos() を BIT_FLAGS 返り値持ちに仕様変更. / has_resist_chaos(...
authordeskull <deskull@users.sourceforge.jp>
Sat, 29 Aug 2020 16:10:41 +0000 (01:10 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sat, 29 Aug 2020 16:12:09 +0000 (01:12 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c
src/player/player-status.h

index f3f2948..222614c 100644 (file)
@@ -1167,36 +1167,30 @@ BIT_FLAGS has_resist_dark(player_type *creature_ptr)
     return result;
 }
 
-void has_resist_chaos(player_type *creature_ptr)
+BIT_FLAGS has_resist_chaos(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
-    creature_ptr->resist_chaos = FALSE;
+    BIT_FLAGS result = 0L;
 
     if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
-        creature_ptr->resist_chaos = TRUE;
+        result |= FLAG_CAUSE_CLASS;
 
     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
-        creature_ptr->resist_chaos = TRUE;
+        result |= FLAG_CAUSE_RACE;
     }
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
-        creature_ptr->resist_chaos = TRUE;
+        result |= FLAG_CAUSE_RACE;
 
-    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
-        creature_ptr->resist_chaos = TRUE;
+    if (creature_ptr->special_defense & KATA_MUSOU) {
+        result |= FLAG_CAUSE_BATTLE_FORM;
     }
 
-    for (inventory_slot_type 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 (has_flag(flgs, TR_RES_CHAOS))
-            creature_ptr->resist_chaos = TRUE;
+    if (creature_ptr->ult_res) {
+        result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
     }
+
+    result |= check_equipment_flags(creature_ptr, TR_RES_CHAOS);
+    return result;
 }
 
 void has_resist_disen(player_type *creature_ptr)
index 5eb3d66..7cc69e9 100644 (file)
@@ -79,7 +79,7 @@ BIT_FLAGS has_resist_conf(player_type *creature_ptr);
 BIT_FLAGS has_resist_sound(player_type *creature_ptr);
 BIT_FLAGS has_resist_lite(player_type *creature_ptr);
 BIT_FLAGS has_resist_dark(player_type *creature_ptr);
-void has_resist_chaos(player_type *creature_ptr);
+BIT_FLAGS has_resist_chaos(player_type *creature_ptr);
 void has_resist_disen(player_type *creature_ptr);
 void has_resist_shard(player_type *creature_ptr);
 void has_resist_nexus(player_type *creature_ptr);
index 6b26128..2272b10 100644 (file)
@@ -380,7 +380,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->resist_sound = has_resist_sound(creature_ptr);
     creature_ptr->resist_lite = has_resist_lite(creature_ptr);
     creature_ptr->resist_dark = has_resist_dark(creature_ptr);
-    has_resist_chaos(creature_ptr);
+    creature_ptr->resist_chaos = has_resist_chaos(creature_ptr);
     has_resist_disen(creature_ptr);
     has_resist_shard(creature_ptr);
     has_resist_nexus(creature_ptr);
index c454a0d..00b0179 100644 (file)
@@ -381,7 +381,7 @@ typedef struct player_type {
     BIT_FLAGS resist_sound; /* Resist sound */
     BIT_FLAGS resist_lite; /* Resist light */
     BIT_FLAGS resist_dark; /* Resist darkness */
-    bool resist_chaos; /* Resist chaos */
+    BIT_FLAGS resist_chaos; /* Resist chaos */
     bool resist_disen; /* Resist disenchant */
     bool resist_shard; /* Resist shards */
     bool resist_nexus; /* Resist nexus */