OSDN Git Service

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

index 74d6cc9..44ad46e 100644 (file)
@@ -673,25 +673,21 @@ BIT_FLAGS has_sustain_con(player_type *creature_ptr)
     return result;
 }
 
-void has_sustain_chr(player_type *creature_ptr)
+BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
     creature_ptr->sustain_chr = FALSE;
 
-    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
-        creature_ptr->sustain_chr = 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_CHR))
-            creature_ptr->sustain_chr = TRUE;
+    if (creature_ptr->special_defense & KATA_MUSOU) {
+        result |= FLAG_CAUSE_BATTLE_FORM;
     }
+
+    result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
+    return result;
 }
 
 void has_levitation(player_type *creature_ptr)
index 304cd11..bd65daa 100644 (file)
@@ -62,7 +62,7 @@ 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);
 BIT_FLAGS has_sustain_con(player_type *creature_ptr);
-void has_sustain_chr(player_type *creature_ptr);
+BIT_FLAGS has_sustain_chr(player_type *creature_ptr);
 void has_levitation(player_type *creature_ptr);
 void has_can_swim(player_type *creature_ptr);
 void has_slow_digest(player_type *creature_ptr);
index 0df1018..83d0a58 100644 (file)
@@ -359,7 +359,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->sustain_wis = has_sustain_wis(creature_ptr);
     creature_ptr->sustain_dex = has_sustain_dex(creature_ptr);
     creature_ptr->sustain_con = has_sustain_con(creature_ptr);
-    has_sustain_chr(creature_ptr);
+    creature_ptr->sustain_chr = has_sustain_chr(creature_ptr);
     has_levitation(creature_ptr);
     has_can_swim(creature_ptr);
     has_slow_digest(creature_ptr);
index a311b1e..9e79f24 100644 (file)
@@ -404,7 +404,7 @@ typedef struct player_type {
     BIT_FLAGS sustain_wis; /* Keep wisdom */
     BIT_FLAGS sustain_dex; /* Keep dexterity */
     BIT_FLAGS sustain_con; /* Keep constitution */
-    bool sustain_chr; /* Keep charisma */
+    BIT_FLAGS sustain_chr; /* Keep charisma */
 
     BIT_FLAGS cursed; /* Player is cursed */