From 653e9a21b54b4638bbf100d55616c9c1c72c003b Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 4 Jan 2020 00:14:05 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20delete=5Fmonster()=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=20delete=5Fmonster().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/dungeon-file.c | 2 +- src/floor-streams.c | 2 +- src/floor.c | 25 ++++++++++++++++++++++--- src/floor.h | 1 + src/grid.h | 22 +++++++++++----------- src/monster.h | 1 - src/monster2.c | 19 ------------------- src/spells-floor.c | 6 +++--- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/dungeon-file.c b/src/dungeon-file.c index 39b44a375..260322fc2 100644 --- a/src/dungeon-file.c +++ b/src/dungeon-file.c @@ -4244,7 +4244,7 @@ static errr process_dungeon_file_aux(floor_type *floor_ptr, char *buf, int ymin, POSITION py, px; /* Delete the monster (if any) */ - delete_monster(p_ptr->y, p_ptr->x); + delete_monster(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x); py = atoi(zz[0]); px = atoi(zz[1]); diff --git a/src/floor-streams.c b/src/floor-streams.c index 66b762971..3d386b2e4 100644 --- a/src/floor-streams.c +++ b/src/floor-streams.c @@ -295,7 +295,7 @@ void build_streamer(floor_type *floor_ptr, FEAT_IDX feat, int chance) if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[floor_ptr->m_list[g_ptr->m_idx].r_idx], 0))) { /* Delete the monster (if any) */ - delete_monster(ty, tx); + delete_monster(floor_ptr, ty, tx); } if (g_ptr->o_idx && !have_flag(streamer_ptr->flags, FF_DROP)) diff --git a/src/floor.c b/src/floor.c index 49a47b479..87bd7666d 100644 --- a/src/floor.c +++ b/src/floor.c @@ -43,7 +43,7 @@ void place_locked_door(floor_type *floor_ptr, POSITION y, POSITION x) { set_cave_feat(floor_ptr, y, x, feat_locked_door_random((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR)); floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); - delete_monster(y, x); + delete_monster(floor_ptr, y, x); } } @@ -92,7 +92,7 @@ void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type) } g_ptr->info &= ~(CAVE_FLOOR); - delete_monster(y, x); + delete_monster(floor_ptr, y, x); } } @@ -840,7 +840,7 @@ void place_random_door(floor_type *floor_ptr, POSITION y, POSITION x, bool room) } } - delete_monster(y, x); + delete_monster(floor_ptr, y, x); } @@ -1721,3 +1721,22 @@ void place_gold(floor_type *floor_ptr, POSITION y, POSITION x) lite_spot(y, x); } } + + +/*! + * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location + * @param x 削除位置x座標 + * @param y 削除位置y座標 + * @return なし + */ +void delete_monster(floor_type *floor_ptr, POSITION y, POSITION x) +{ + grid_type *g_ptr; + if (!in_bounds(floor_ptr, y, x)) return; + + /* Check the grid */ + g_ptr = &floor_ptr->grid_array[y][x]; + + /* Delete the monster (if any) */ + if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx); +} diff --git a/src/floor.h b/src/floor.h index 38db90d27..15ba01e6c 100644 --- a/src/floor.h +++ b/src/floor.h @@ -425,3 +425,4 @@ extern sint project_path(floor_type *floor_ptr, u16b *gp, POSITION range, POSITI extern void set_floor(floor_type *floor_ptr, POSITION x, POSITION y); extern void place_object(floor_type *floor_ptr, POSITION y, POSITION x, BIT_FLAGS mode); extern void place_gold(floor_type *floor_ptr, POSITION y, POSITION x); +extern void delete_monster(floor_type *floor_ptr, POSITION y, POSITION x); diff --git a/src/grid.h b/src/grid.h index e308c92df..c5e3b62b1 100644 --- a/src/grid.h +++ b/src/grid.h @@ -122,7 +122,7 @@ typedef struct set_cave_feat((F), Y,X,feat_ground_type[randint0(100)]); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,CAVE_FLOOR); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_floor_grid(C) \ @@ -138,7 +138,7 @@ typedef struct set_cave_feat((F), Y,X,feat_wall_type[randint0(100)]); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,CAVE_EXTRA); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_extra_grid(C) \ @@ -154,7 +154,7 @@ typedef struct set_cave_feat(F, Y, X,feat_permanent); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info(F, Y, X, CAVE_EXTRA); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_extra_perm_grid(C) \ @@ -181,7 +181,7 @@ typedef struct set_cave_feat((F), Y, X, feat_wall_inner); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y, X, CAVE_INNER); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_inner_grid(C) \ @@ -197,7 +197,7 @@ typedef struct set_cave_feat(F, Y,X,feat_permanent); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,CAVE_INNER); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_inner_perm_grid(C) \ @@ -213,7 +213,7 @@ typedef struct set_cave_feat((F), Y, X, feat_wall_outer); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,CAVE_OUTER); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_outer_grid(C) \ @@ -229,7 +229,7 @@ typedef struct set_cave_feat(F, Y, X, feat_permanent); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,CAVE_OUTER); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_outer_perm_grid(C) \ @@ -247,7 +247,7 @@ typedef struct else set_cave_feat((F), Y,X,feat_wall_outer); \ (F)->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info((F), Y,X,(CAVE_OUTER | CAVE_VAULT)); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_outer_noperm_grid(C) \ @@ -265,7 +265,7 @@ typedef struct set_cave_feat(F,Y,X,feat_wall_solid); \ F->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info(F,Y,X,CAVE_SOLID); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_solid_grid(C) \ @@ -281,7 +281,7 @@ typedef struct set_cave_feat(F, Y, X, feat_permanent); \ F->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info(F, Y, X, CAVE_SOLID); \ - delete_monster(Y, X); \ + delete_monster(F, Y, X); \ } #define place_solid_perm_grid(C) \ @@ -300,7 +300,7 @@ typedef struct else set_cave_feat(p_ptr->current_floor_ptr, Y,X,feat_wall_solid); \ p_ptr->current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \ add_cave_info(p_ptr->current_floor_ptr, Y,X,CAVE_SOLID); \ - delete_monster(Y, X); \ + delete_monster(p_ptr->current_floor_ptr, Y, X); \ } #define place_solid_noperm_grid(C) \ diff --git a/src/monster.h b/src/monster.h index 512af56aa..91b48661b 100644 --- a/src/monster.h +++ b/src/monster.h @@ -469,7 +469,6 @@ extern void reset_target(monster_type *m_ptr); extern monster_race *real_r_ptr(monster_type *m_ptr); extern MONRACE_IDX real_r_idx(monster_type *m_ptr); extern void delete_monster_idx(MONSTER_IDX i); -extern void delete_monster(POSITION y, POSITION x); extern void compact_monsters(int size); extern void wipe_m_list(void); extern MONSTER_IDX m_pop(void); diff --git a/src/monster2.c b/src/monster2.c index 9fce310b9..dc6f6aa5b 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -176,25 +176,6 @@ void delete_monster_idx(MONSTER_IDX i) /*! - * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location - * @param x 削除位置x座標 - * @param y 削除位置y座標 - * @return なし - */ -void delete_monster(POSITION y, POSITION x) -{ - grid_type *g_ptr; - if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return; - - /* Check the grid */ - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; - - /* Delete the monster (if any) */ - if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx); -} - - -/*! * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list * @param i1 配列移動元添字 * @param i2 配列移動先添字 diff --git a/src/spells-floor.c b/src/spells-floor.c index 86f257cc6..d38d46f53 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -527,7 +527,7 @@ bool destroy_area(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION r, b if (in_generate) /* In generation */ { /* Delete the monster (if any) */ - delete_monster(y, x); + delete_monster(floor_ptr, y, x); } else if (r_ptr->flags1 & RF1_QUESTOR) { @@ -548,7 +548,7 @@ bool destroy_area(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION r, b } /* Delete the monster (if any) */ - delete_monster(y, x); + delete_monster(floor_ptr, y, x); } } @@ -1020,7 +1020,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M } } - delete_monster(yy, xx); + delete_monster(caster_ptr->current_floor_ptr, yy, xx); /* No longer safe */ sn = 0; -- 2.11.0