OSDN Git Service

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

index d073f10..6d3811b 100644 (file)
@@ -723,10 +723,13 @@ static void process_aura_damage(monster_type *m_ptr, player_type *touched_ptr, b
  */
 void touch_zap_player(monster_type *m_ptr, player_type *touched_ptr)
 {
-    process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE, fire_dam,
+    process_aura_damage(m_ptr, touched_ptr, (bool)touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
+        fire_dam,
         _("突然とても熱くなった!", "You are suddenly very hot!"));
-    process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD, cold_dam,
+    process_aura_damage(m_ptr, touched_ptr, (bool)touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
+        cold_dam,
         _("突然とても寒くなった!", "You are suddenly very cold!"));
-    process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC, elec_dam,
+    process_aura_damage(m_ptr, touched_ptr, (bool)touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
+               elec_dam,
         _("電撃をくらった!", "You get zapped!"));
 }
index ab8a995..bd06329 100644 (file)
@@ -1533,25 +1533,17 @@ BIT_FLAGS has_immune_acid(player_type *creature_ptr)
     return result;
 }
 
-void has_immune_elec(player_type *creature_ptr)
+BIT_FLAGS has_immune_elec(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
-    creature_ptr->immune_elec = FALSE;
-    if (creature_ptr->ele_immune) {
+    BIT_FLAGS result = 0L;
+
+       if (creature_ptr->ele_immune) {
         if (creature_ptr->special_defense & DEFENSE_ELEC)
-            creature_ptr->immune_elec = TRUE;
+            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_IM_ELEC))
-            creature_ptr->immune_elec = TRUE;
-    }
+    result |= check_equipment_flags(creature_ptr, TR_IM_ELEC);
+    return result;
 }
 
 void has_immune_fire(player_type *creature_ptr)
index a4e3912..4a0fbe1 100644 (file)
@@ -89,7 +89,7 @@ void has_resist_time(player_type *creature_ptr);
 void has_resist_water(player_type *creature_ptr);
 void has_resist_fear(player_type *creature_ptr);
 BIT_FLAGS has_immune_acid(player_type *creature_ptr);
-void has_immune_elec(player_type *creature_ptr);
+BIT_FLAGS has_immune_elec(player_type *creature_ptr);
 void has_immune_fire(player_type *creature_ptr);
 void has_immune_cold(player_type *creature_ptr);
 bool has_right_hand_weapon(player_type *creature_ptr);
index 1d082a5..3e8d6c3 100644 (file)
@@ -368,7 +368,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->impact = has_impact(creature_ptr);
     has_extra_blow(creature_ptr);
     creature_ptr->immune_acid = has_immune_acid(creature_ptr);
-    has_immune_elec(creature_ptr);
+    creature_ptr->immune_elec = has_immune_elec(creature_ptr);
     has_immune_fire(creature_ptr);
     has_immune_cold(creature_ptr);
     has_resist_acid(creature_ptr);
index d823bd3..60e7619 100644 (file)
@@ -367,7 +367,7 @@ typedef struct player_type {
     bool level_up_message;
 
     BIT_FLAGS immune_acid; /* Immunity to acid */
-    bool immune_elec; /* Immunity to lightning */
+    BIT_FLAGS immune_elec; /* Immunity to lightning */
     bool immune_fire; /* Immunity to fire */
     bool immune_cold; /* Immunity to cold */