From c527295390a60df4046625de9887cc0ac42ae5ba Mon Sep 17 00:00:00 2001 From: deskull Date: Thu, 19 Sep 2019 21:07:28 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20alloc=5Fobject()=20?= =?utf8?q?=E3=81=AB=20floor=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=20floor=5Ftype=20*=20argum?= =?utf8?q?ent=20to=20alloc=5Fobject().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/floor-generate.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/floor-generate.c b/src/floor-generate.c index a346f5542..95827e500 100644 --- a/src/floor-generate.c +++ b/src/floor-generate.c @@ -303,7 +303,7 @@ static bool alloc_stairs(FEAT_IDX feat, int num, int walls) * @param num 配置したい数 * @return 規定数通りに生成に成功したらTRUEを返す。 */ -static void alloc_object(int set, EFFECT_ID typ, int num) +static void alloc_object(floor_type *floor_ptr, int set, EFFECT_ID typ, int num) { POSITION y = 0, x = 0; int k; @@ -311,7 +311,7 @@ static void alloc_object(int set, EFFECT_ID typ, int num) grid_type *g_ptr; /* A small level has few objects. */ - num = num * current_floor_ptr->height * current_floor_ptr->width / (MAX_HGT*MAX_WID) +1; + num = num * floor_ptr->height * floor_ptr->width / (MAX_HGT*MAX_WID) +1; /* Place some objects */ for (k = 0; k < num; k++) @@ -323,10 +323,10 @@ static void alloc_object(int set, EFFECT_ID typ, int num) dummy++; - y = randint0(current_floor_ptr->height); - x = randint0(current_floor_ptr->width); + y = randint0(floor_ptr->height); + x = randint0(floor_ptr->width); - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Require "naked" floor grid */ if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx) continue; @@ -335,7 +335,7 @@ static void alloc_object(int set, EFFECT_ID typ, int num) if (player_bold(y, x)) continue; /* Check for "room" */ - room = (current_floor_ptr->grid_array[y][x].info & CAVE_ROOM) ? TRUE : FALSE; + room = (floor_ptr->grid_array[y][x].info & CAVE_ROOM) ? TRUE : FALSE; /* Require corridor? */ if ((set == ALLOC_SET_CORR) && room) continue; @@ -360,14 +360,14 @@ static void alloc_object(int set, EFFECT_ID typ, int num) case ALLOC_TYP_RUBBLE: { place_rubble(y, x); - current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); + floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); break; } case ALLOC_TYP_TRAP: { place_trap(y, x); - current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); + floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); break; } @@ -946,10 +946,10 @@ static bool cave_gen(dungeon_type* dungeon_ptr, floor_type *floor_ptr) } /* Place some traps in the dungeon */ - alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_TRAP, randint1(k)); + alloc_object(floor_ptr, ALLOC_SET_BOTH, ALLOC_TYP_TRAP, randint1(k)); /* Put some rubble in corridors (except NO_CAVE dungeon (Castle)) */ - if (!(dungeon_ptr->flags1 & DF1_NO_CAVE)) alloc_object(ALLOC_SET_CORR, ALLOC_TYP_RUBBLE, randint1(k)); + if (!(dungeon_ptr->flags1 & DF1_NO_CAVE)) alloc_object(floor_ptr, ALLOC_SET_CORR, ALLOC_TYP_RUBBLE, randint1(k)); /* Mega Hack -- No object at first level of deeper dungeon */ if (p_ptr->enter_dungeon && floor_ptr->dun_level > 1) @@ -959,11 +959,11 @@ static bool cave_gen(dungeon_type* dungeon_ptr, floor_type *floor_ptr) } /* Put some objects in rooms */ - alloc_object(ALLOC_SET_ROOM, ALLOC_TYP_OBJECT, randnor(DUN_AMT_ROOM, 3)); + alloc_object(floor_ptr, ALLOC_SET_ROOM, ALLOC_TYP_OBJECT, randnor(DUN_AMT_ROOM, 3)); /* Put some objects/gold in the dungeon */ - alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_OBJECT, randnor(DUN_AMT_ITEM, 3)); - alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3)); + alloc_object(floor_ptr, ALLOC_SET_BOTH, ALLOC_TYP_OBJECT, randnor(DUN_AMT_ITEM, 3)); + alloc_object(floor_ptr, ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3)); /* Set back to default */ floor_ptr->object_level = floor_ptr->base_level; -- 2.11.0