From 877335c88df10c79908af5a72b20f5027497b2b6 Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 26 Jul 2020 16:29:00 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20have=5Fesp=5Forc()=20?= =?utf8?q?=E3=82=92=20calc=5Fbonuses()=E3=80=80=E3=81=8B=E3=82=89=E5=88=86?= =?utf8?q?=E9=9B=A2=EF=BC=8E=20/=20Separated=20have=5Fesp=5Forc()=20from?= =?utf8?q?=20calc=5Fbonuses().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/player/player-status-flags.c | 19 +++++++++++++++++++ src/player/player-status-flags.h | 2 ++ src/player/player-status.c | 4 +--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 3f12802c7..ecaa62ce9 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -157,3 +157,22 @@ void have_esp_demon(player_type *creature_ptr) } } +void have_esp_orc(player_type *creature_ptr) +{ + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + + creature_ptr->esp_orc = 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_ORC)) + creature_ptr->esp_orc = TRUE; + } +} + diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index 31cc2b546..98977dbb6 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -6,5 +6,7 @@ void have_xtra_might(player_type *creature_ptr); void have_esp_evil(player_type *creature_ptr); void have_esp_animal(player_type *creature_ptr); void have_esp_undead(player_type *creature_ptr); +void have_esp_demon(player_type *creature_ptr); +void have_esp_orc(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index 63098609b..a04d35f02 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_orc = FALSE; creature_ptr->esp_troll = FALSE; creature_ptr->esp_giant = FALSE; creature_ptr->esp_dragon = FALSE; @@ -711,6 +710,7 @@ void calc_bonuses(player_type *creature_ptr) have_esp_animal(creature_ptr); have_esp_undead(creature_ptr); have_esp_demon(creature_ptr); + have_esp_orc(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_ORC)) - creature_ptr->esp_orc = TRUE; if (have_flag(flgs, TR_ESP_TROLL)) creature_ptr->esp_troll = TRUE; if (have_flag(flgs, TR_ESP_GIANT)) -- 2.11.0