OSDN Git Service

[Refactor] #40514 has_sustain_con() を BIT_FLAGS 返り値持ちに仕様変更. / has_sustain_con() was...
authordeskull <deskull@users.sourceforge.jp>
Thu, 27 Aug 2020 15:26:29 +0000 (00:26 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Thu, 27 Aug 2020 15:26:29 +0000 (00:26 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c
src/player/player-status.h

index fc75fe6..74d6cc9 100644 (file)
@@ -650,32 +650,27 @@ BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
     return result;
 }
 
-void has_sustain_con(player_type *creature_ptr)
+BIT_FLAGS has_sustain_con(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
-    creature_ptr->sustain_con = FALSE;
+    BIT_FLAGS result = 0L;
     if (creature_ptr->pclass == CLASS_BERSERKER) {
-        creature_ptr->sustain_con = TRUE;
+        result |= FLAG_CAUSE_CLASS;
     }
 
     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
-        creature_ptr->sustain_con = TRUE;
+        result |= FLAG_CAUSE_RACE;
     }
 
-    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
-        creature_ptr->sustain_con = 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;
-
-        object_flags(creature_ptr, o_ptr, flgs);
-        if (has_flag(flgs, TR_SUST_CON))
-            creature_ptr->sustain_con = TRUE;
+    if (creature_ptr->special_defense & KATA_MUSOU) {
+        result |= FLAG_CAUSE_BATTLE_FORM;
     }
+
+    result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
+    return result;
 }
 
 void has_sustain_chr(player_type *creature_ptr)
index 57a2fbf..304cd11 100644 (file)
@@ -61,7 +61,7 @@ BIT_FLAGS has_sustain_str(player_type *creature_ptr);
 BIT_FLAGS has_sustain_int(player_type *creature_ptr);
 BIT_FLAGS has_sustain_wis(player_type *creature_ptr);
 BIT_FLAGS has_sustain_dex(player_type *creature_ptr);
-void has_sustain_con(player_type *creature_ptr);
+BIT_FLAGS has_sustain_con(player_type *creature_ptr);
 void has_sustain_chr(player_type *creature_ptr);
 void has_levitation(player_type *creature_ptr);
 void has_can_swim(player_type *creature_ptr);
index b02a9f2..0df1018 100644 (file)
@@ -358,7 +358,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->sustain_int = has_sustain_int(creature_ptr);
     creature_ptr->sustain_wis = has_sustain_wis(creature_ptr);
     creature_ptr->sustain_dex = has_sustain_dex(creature_ptr);
-    has_sustain_con(creature_ptr);
+    creature_ptr->sustain_con = has_sustain_con(creature_ptr);
     has_sustain_chr(creature_ptr);
     has_levitation(creature_ptr);
     has_can_swim(creature_ptr);
index e994cee..a311b1e 100644 (file)
@@ -403,7 +403,7 @@ typedef struct player_type {
     BIT_FLAGS sustain_int; /* Keep intelligence */
     BIT_FLAGS sustain_wis; /* Keep wisdom */
     BIT_FLAGS sustain_dex; /* Keep dexterity */
-    bool sustain_con; /* Keep constitution */
+    BIT_FLAGS sustain_con; /* Keep constitution */
     bool sustain_chr; /* Keep charisma */
 
     BIT_FLAGS cursed; /* Player is cursed */