From: deskull Date: Fri, 28 Aug 2020 11:10:16 +0000 (+0900) Subject: [Refactor] #40514 has_immune_elec() を BIT_FLAGS 返り値持ちに仕様変更. / has_immune_elec() was... X-Git-Tag: vmacos3.0.0-alpha52~517^2~324 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f5e9b7f728b965544d7011695705d29c39dcddaa;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40514 has_immune_elec() を BIT_FLAGS 返り値持ちに仕様変更. / has_immune_elec() was changed specifications to return BIT_FLAGS value. --- diff --git a/src/player/player-damage.c b/src/player/player-damage.c index d073f100d..6d3811b0d 100644 --- a/src/player/player-damage.c +++ b/src/player/player-damage.c @@ -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!")); } diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index ab8a995c5..bd0632903 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -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) diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index a4e391211..4a0fbe132 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -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); diff --git a/src/player/player-status.c b/src/player/player-status.c index 1d082a5ca..3e8d6c307 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -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); diff --git a/src/player/player-status.h b/src/player/player-status.h index d823bd3c2..60e761926 100644 --- a/src/player/player-status.h +++ b/src/player/player-status.h @@ -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 */