From 3647bad365e0ead7a2693fc30fa8652a6054aa0d Mon Sep 17 00:00:00 2001 From: Hourier Date: Mon, 13 Jan 2020 13:19:54 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20choose=5Fwarning=5Fitem()?= =?utf8?q?=20=E3=81=ABplayer=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=20/=20Added=20player=5Ftype=20*=20argument=20?= =?utf8?q?to=20choose=5Fwarning=5Fitem()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/monster2.c | 2 +- src/warning.c | 14 ++++++-------- src/warning.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/monster2.c b/src/monster2.c index a6a4eb619..fc7fb9030 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -2810,7 +2810,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I else color = _("白く", "white"); - o_ptr = choose_warning_item(); + o_ptr = choose_warning_item(p_ptr); if (o_ptr) { object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); diff --git a/src/warning.c b/src/warning.c index 94b0f6625..9772da35a 100644 --- a/src/warning.c +++ b/src/warning.c @@ -1,5 +1,4 @@  - #include "angband.h" #include "util.h" @@ -25,20 +24,20 @@ * Calculate spell damages * @return 警告を行う */ -object_type *choose_warning_item(void) +object_type *choose_warning_item(player_type *creature_ptr) { int i; int choices[INVEN_TOTAL - INVEN_RARM]; int number = 0; /* Paranoia -- Player has no warning ability */ - if (!p_ptr->warning) return NULL; + if (!creature_ptr->warning) return NULL; /* Search Inventory */ for (i = INVEN_RARM; i < INVEN_TOTAL; i++) { BIT_FLAGS flgs[TR_FLAG_SIZE]; - object_type *o_ptr = &p_ptr->inventory_list[i]; + object_type *o_ptr = &creature_ptr->inventory_list[i]; object_flags(o_ptr, flgs); if (have_flag(flgs, TR_WARNING)) @@ -49,7 +48,7 @@ object_type *choose_warning_item(void) } /* Choice one of them */ - return number ? &p_ptr->inventory_list[choices[randint0(number)]] : NULL; + return number ? &creature_ptr->inventory_list[choices[randint0(number)]] : NULL; } /*! @@ -501,7 +500,7 @@ bool process_warning(player_type *creature_ptr, POSITION xx, POSITION yy) if (dam_max > creature_ptr->chp / 2) { - object_type *o_ptr = choose_warning_item(); + object_type *o_ptr = choose_warning_item(creature_ptr); if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); @@ -519,7 +518,7 @@ bool process_warning(player_type *creature_ptr, POSITION xx, POSITION yy) if (((!easy_disarm && is_trap(g_ptr->feat)) || (g_ptr->mimic && is_trap(g_ptr->feat))) && !one_in_(13)) { - object_type *o_ptr = choose_warning_item(); + object_type *o_ptr = choose_warning_item(creature_ptr); if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); @@ -532,4 +531,3 @@ bool process_warning(player_type *creature_ptr, POSITION xx, POSITION yy) return TRUE; } - diff --git a/src/warning.h b/src/warning.h index c76e3ff29..44a41d02f 100644 --- a/src/warning.h +++ b/src/warning.h @@ -1,4 +1,4 @@ #pragma once -extern object_type *choose_warning_item(void); +extern object_type *choose_warning_item(player_type *creature_ptr); extern bool process_warning(player_type *creature_ptr, POSITION xx, POSITION yy); -- 2.11.0