OSDN Git Service

[Refactor] #40514 has_resist_acid() を BIT_FLAGS 返り値持ちに仕様変更. / has_resist_acid() was...
authordeskull <deskull@users.sourceforge.jp>
Fri, 28 Aug 2020 11:22:19 +0000 (20:22 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Fri, 28 Aug 2020 11:24:25 +0000 (20:24 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c
src/player/player-status.h

index f47e57c..7deca89 100644 (file)
@@ -915,44 +915,35 @@ void has_extra_blow(player_type *creature_ptr)
     }
 }
 
-void has_resist_acid(player_type *creature_ptr)
+BIT_FLAGS has_resist_acid(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
-    creature_ptr->resist_acid = FALSE;
+    BIT_FLAGS result = 0L;
 
     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
-        creature_ptr->resist_acid = TRUE;
+        result |= FLAG_CAUSE_RACE;
     }
 
     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
-        creature_ptr->resist_acid = TRUE;
+        result |= FLAG_CAUSE_RACE;
     }
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
-        creature_ptr->resist_acid = TRUE;
+        result |= FLAG_CAUSE_RACE;
     }
 
-    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
-        creature_ptr->resist_acid = TRUE;
+    if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
+        result |= FLAG_CAUSE_BATTLE_FORM;
     }
 
-    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
-        creature_ptr->resist_acid = TRUE;
+    if (creature_ptr->ult_res) {
+        result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
     }
 
-    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-        o_ptr = &creature_ptr->inventory_list[i];
-        if (!o_ptr->k_idx)
-            continue;
+    result |= has_immune_acid(creature_ptr);
 
-        object_flags(creature_ptr, o_ptr, flgs);
-        if (has_flag(flgs, TR_RES_ACID))
-            creature_ptr->resist_acid = TRUE;
-    }
+    result |= check_equipment_flags(creature_ptr, TR_RES_ACID);
+    return result;
 
-    if (creature_ptr->immune_acid)
-        creature_ptr->resist_acid = TRUE;
 }
 
 void has_resist_elec(player_type *creature_ptr)
@@ -969,11 +960,11 @@ void has_resist_elec(player_type *creature_ptr)
         creature_ptr->resist_elec = TRUE;
     }
 
-    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+    if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
         creature_ptr->resist_elec = TRUE;
     }
 
-    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res) {
         creature_ptr->resist_elec = TRUE;
     }
 
index d9b9899..6f5d1c9 100644 (file)
@@ -70,7 +70,7 @@ BIT_FLAGS has_regenerate(player_type *creature_ptr);
 void has_curses(player_type *creature_ptr);
 BIT_FLAGS has_impact(player_type *creature_ptr);
 void has_extra_blow(player_type *creature_ptr);
-void has_resist_acid(player_type *creature_ptr);
+BIT_FLAGS has_resist_acid(player_type *creature_ptr);
 void has_resist_elec(player_type *creature_ptr);
 void has_resist_fire(player_type *creature_ptr);
 void has_resist_cold(player_type *creature_ptr);
index 56dea6b..a05c4d4 100644 (file)
@@ -371,7 +371,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->immune_elec = has_immune_elec(creature_ptr);
     creature_ptr->immune_fire = has_immune_fire(creature_ptr);
     creature_ptr->immune_cold = has_immune_cold(creature_ptr);
-    has_resist_acid(creature_ptr);
+    creature_ptr->resist_acid = has_resist_acid(creature_ptr);
     has_resist_elec(creature_ptr);
     has_resist_fire(creature_ptr);
     has_resist_cold(creature_ptr);
index b88d1ba..efb6d8f 100644 (file)
@@ -371,8 +371,8 @@ typedef struct player_type {
     BIT_FLAGS immune_fire; /* Immunity to fire */
     BIT_FLAGS immune_cold; /* Immunity to cold */
 
-    bool resist_acid; /* Resist acid */
-    bool resist_elec; /* Resist lightning */
+    BIT_FLAGS resist_acid; /* Resist acid */
+    BIT_FLAGS resist_elec; /* Resist lightning */
     bool resist_fire; /* Resist fire */
     bool resist_cold; /* Resist cold */
     bool resist_pois; /* Resist poison */