From: deskull Date: Sun, 26 Jul 2020 07:13:32 +0000 (+0900) Subject: [Refactor] #40514 have_esp_animal() を calc_bonuses() から分離. / Separated have_esp_anima... X-Git-Tag: vmacos3.0.0-alpha52~772 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c3c52bc10a772c9f7455a61c62197258908dcef1;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40514 have_esp_animal() を calc_bonuses() から分離. / Separated have_esp_animal() from calc_bonuses(). --- diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 1ca5e4b7f..abbce95e6 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -99,3 +99,22 @@ void have_esp_evil(player_type *creature_ptr) creature_ptr->esp_evil = TRUE; } } + +void have_esp_animal(player_type *creature_ptr) +{ + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + + creature_ptr->esp_animal = FALSE; + + for (int 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 (have_flag(flgs, TR_ESP_ANIMAL)) + creature_ptr->esp_animal = TRUE; + } +} diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index 73abdfcd9..1537cdc6d 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -4,5 +4,6 @@ void have_pass_wall(player_type *creature_ptr); void have_kill_wall(player_type *creature_ptr); void have_xtra_might(player_type *creature_ptr); void have_esp_evil(player_type *creature_ptr); +void have_esp_animal(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index 07908c564..303dfeb82 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -578,7 +578,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->levitation = FALSE; creature_ptr->hold_exp = FALSE; creature_ptr->telepathy = FALSE; - creature_ptr->esp_animal = FALSE; creature_ptr->esp_undead = FALSE; creature_ptr->esp_demon = FALSE; creature_ptr->esp_orc = FALSE; @@ -711,6 +710,7 @@ void calc_bonuses(player_type *creature_ptr) have_kill_wall(creature_ptr); have_xtra_might(creature_ptr); have_esp_evil(creature_ptr); + have_esp_animal(creature_ptr); calc_race_status(creature_ptr); @@ -4704,8 +4704,6 @@ void calc_equipment_status(player_type *creature_ptr) creature_ptr->regenerate = TRUE; if (have_flag(flgs, TR_TELEPATHY)) creature_ptr->telepathy = TRUE; - if (have_flag(flgs, TR_ESP_ANIMAL)) - creature_ptr->esp_animal = TRUE; if (have_flag(flgs, TR_ESP_UNDEAD)) creature_ptr->esp_undead = TRUE; if (have_flag(flgs, TR_ESP_DEMON))