From 3199125aad47e5dd808e2ac7d28817c0420eaac3 Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 30 Aug 2020 16:25:00 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20has=5Fresist=5Fneth()=20?= =?utf8?q?=E3=82=92=20BIT=5FFLAGS=20=E8=BF=94=E3=82=8A=E5=80=A4=E6=8C=81?= =?utf8?q?=E3=81=A1=E3=81=AB=E4=BB=95=E6=A7=98=E5=A4=89=E6=9B=B4.=20/=20ha?= =?utf8?q?s=5Fresist=5Fneth()=E3=80=80was=20changed=20specifications=20to?= =?utf8?q?=20return=20BIT=5FFLAGS=20value.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/player/player-status-flags.c | 29 ++++++++++------------------- src/player/player-status-flags.h | 2 +- src/player/player-status.c | 2 +- src/player/player-status.h | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index ea2317489..e7f2b4e7f 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -1278,38 +1278,29 @@ BIT_FLAGS has_resist_blind(player_type *creature_ptr) return result; } -void has_resist_neth(player_type *creature_ptr) +BIT_FLAGS has_resist_neth(player_type *creature_ptr) { - object_type *o_ptr; - BIT_FLAGS flgs[TR_FLAG_SIZE]; + BIT_FLAGS result = 0L; if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) { - creature_ptr->resist_neth = TRUE; + result |= FLAG_CAUSE_RACE; } if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_BALROG)) - creature_ptr->resist_neth = TRUE; + result |= FLAG_CAUSE_RACE; - if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { - creature_ptr->resist_neth = TRUE; + if (creature_ptr->special_defense & KATA_MUSOU) { + result |= FLAG_CAUSE_BATTLE_FORM; } - if (creature_ptr->tim_res_nether) { - creature_ptr->resist_neth = TRUE; + if (creature_ptr->ult_res || creature_ptr->tim_res_nether) { + 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_RES_NETHER)) - creature_ptr->resist_neth = TRUE; - } + result |= check_equipment_flags(creature_ptr, TR_RES_NETHER); + return result; } void has_resist_time(player_type *creature_ptr) diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index c66d95a65..a0abd94d8 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -84,7 +84,7 @@ BIT_FLAGS has_resist_disen(player_type *creature_ptr); BIT_FLAGS has_resist_shard(player_type *creature_ptr); BIT_FLAGS has_resist_nexus(player_type *creature_ptr); BIT_FLAGS has_resist_blind(player_type *creature_ptr); -void has_resist_neth(player_type *creature_ptr); +BIT_FLAGS has_resist_neth(player_type *creature_ptr); void has_resist_time(player_type *creature_ptr); void has_resist_water(player_type *creature_ptr); void has_resist_fear(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index cc57e3a65..fa7c3faf8 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -385,7 +385,7 @@ void calc_bonuses(player_type *creature_ptr) creature_ptr->resist_shard = has_resist_shard(creature_ptr); creature_ptr->resist_nexus = has_resist_nexus(creature_ptr); creature_ptr->resist_blind = has_resist_blind(creature_ptr); - has_resist_neth(creature_ptr); + creature_ptr->resist_neth = has_resist_neth(creature_ptr); has_resist_time(creature_ptr); has_resist_fear(creature_ptr); diff --git a/src/player/player-status.h b/src/player/player-status.h index 33e21584b..1fa71deb8 100644 --- a/src/player/player-status.h +++ b/src/player/player-status.h @@ -386,7 +386,7 @@ typedef struct player_type { BIT_FLAGS resist_shard; /* Resist shards */ BIT_FLAGS resist_nexus; /* Resist nexus */ BIT_FLAGS resist_blind; /* Resist blindness */ - bool resist_neth; /* Resist nether */ + BIT_FLAGS resist_neth; /* Resist nether */ bool resist_fear; /* Resist fear */ bool resist_time; /* Resist time */ bool resist_water; /* Resist water */ -- 2.11.0