From eb39e45c5f6a8d1170f624b56b04cf692291573f Mon Sep 17 00:00:00 2001 From: deskull Date: Wed, 18 Dec 2019 23:59:46 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20chest=5Fdeath()=20?= =?utf8?q?=E3=81=AB=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E=20/=20Add=20player=5Ftype=20*=20argu?= =?utf8?q?ment=20to=20chest=5Fdeath().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/chest.c | 14 +++++++------- src/chest.h | 2 +- src/cmd/cmd-basic.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/chest.c b/src/chest.c index 53f0456f4..989c41aec 100644 --- a/src/chest.c +++ b/src/chest.c @@ -32,7 +32,7 @@ * on the level on which the chest is generated. * */ -void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) +void chest_death(player_type *owner_ptr, bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) { int number; @@ -42,7 +42,7 @@ void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) object_type forge; object_type *q_ptr; - object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; + object_type *o_ptr = &owner_ptr->current_floor_ptr->o_list[o_idx]; /* Small chests often hold "gold" */ @@ -56,12 +56,12 @@ void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) number = 5; small = FALSE; mode |= AM_GREAT; - p_ptr->current_floor_ptr->object_level = o_ptr->xtra3; + owner_ptr->current_floor_ptr->object_level = o_ptr->xtra3; } else { /* Determine the "value" of the items */ - p_ptr->current_floor_ptr->object_level = ABS(o_ptr->pval) + 10; + owner_ptr->current_floor_ptr->object_level = ABS(o_ptr->pval) + 10; } /* Zero pval means empty chest */ @@ -99,7 +99,7 @@ void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) x = randint0(MAX_WID); /* Must be an empty floor. */ - if (!cave_empty_bold(p_ptr->current_floor_ptr, y, x)) continue; + if (!cave_empty_bold(owner_ptr->current_floor_ptr, y, x)) continue; /* Place the object there. */ (void)drop_near(q_ptr, -1, y, x); @@ -113,7 +113,7 @@ void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) } /* Reset the object level */ - p_ptr->current_floor_ptr->object_level = p_ptr->current_floor_ptr->base_level; + owner_ptr->current_floor_ptr->object_level = owner_ptr->current_floor_ptr->base_level; /* Empty */ o_ptr->pval = 0; @@ -328,7 +328,7 @@ void chest_trap(player_type *target_ptr, POSITION y, POSITION x, OBJECT_IDX o_id if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx) { msg_print(_("宝箱の中身はダンジョンじゅうに散乱した!", "The contents of the chest scatter all over the dungeon!")); - chest_death(TRUE, y, x, o_idx); + chest_death(target_ptr, TRUE, y, x, o_idx); o_ptr->pval = 0; } } diff --git a/src/chest.h b/src/chest.h index f7a4993f5..7677063f0 100644 --- a/src/chest.h +++ b/src/chest.h @@ -1,4 +1,4 @@  -extern void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx); +extern void chest_death(player_type *owner_ptr, bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx); extern void chest_trap(player_type *target_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx); diff --git a/src/cmd/cmd-basic.c b/src/cmd/cmd-basic.c index add4a17b3..09f32d954 100644 --- a/src/cmd/cmd-basic.c +++ b/src/cmd/cmd-basic.c @@ -607,7 +607,7 @@ static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OB chest_trap(creature_ptr, y, x, o_idx); /* Let the Chest drop items */ - chest_death(FALSE, y, x, o_idx); + chest_death(creature_ptr, FALSE, y, x, o_idx); } return (more); } -- 2.11.0