From d9fd0aa46e57dea3c71e1a912353f5dce8f016de Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 11 Jan 2020 22:56:22 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20quest=5Fnumber()=20?= =?utf8?q?=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=20floor=5Ftype=20*=20argument=20t?= =?utf8?q?o=20quest=5Fnumber()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd/cmd-dump.c | 2 +- src/core.c | 4 ++-- src/dungeon-file.c | 4 ++-- src/floor-events.c | 2 +- src/floor-generate.c | 25 ++++++++++++++----------- src/floor-save.c | 2 +- src/floor.c | 15 +++++++++------ src/floor.h | 6 +++--- src/load.c | 8 +++++--- src/monster2.c | 4 ++-- src/player-damage.c | 2 +- src/quest.c | 10 +++++----- src/quest.h | 2 +- src/rooms-normal.c | 13 ++++++------- src/rooms-vault.c | 4 ++-- src/rooms.c | 8 ++++---- src/spells-floor.c | 2 +- src/spells1.c | 2 +- src/spells3.c | 4 ++-- src/trap.c | 10 ++++++---- src/trap.h | 4 ++-- 21 files changed, 71 insertions(+), 62 deletions(-) diff --git a/src/cmd/cmd-dump.c b/src/cmd/cmd-dump.c index 91e091ae8..045f06da2 100644 --- a/src/cmd/cmd-dump.c +++ b/src/cmd/cmd-dump.c @@ -455,7 +455,7 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note) return (-1); } - q_idx = quest_number(creature_ptr->current_floor_ptr->dun_level); + q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level); if (write_level) { diff --git a/src/core.c b/src/core.c index 770502400..bb0bbd66c 100644 --- a/src/core.c +++ b/src/core.c @@ -3072,7 +3072,7 @@ static void process_world_aux_movement(player_type *creature_ptr) disturb(creature_ptr, FALSE, TRUE); /* Determine the level */ - if (!quest_number(floor_ptr->dun_level) && floor_ptr->dun_level) + if (!quest_number(creature_ptr, floor_ptr->dun_level) && floor_ptr->dun_level) { msg_print(_("世界が変わった!", "The world changes!")); @@ -4939,7 +4939,7 @@ static void dungeon(player_type *player_ptr, bool load_game) disturb(player_ptr, TRUE, TRUE); /* Get index of current quest (if any) */ - quest_num = quest_number(player_ptr->current_floor_ptr->dun_level); + quest_num = quest_number(player_ptr, player_ptr->current_floor_ptr->dun_level); /* Inside a quest? */ if (quest_num) diff --git a/src/dungeon-file.c b/src/dungeon-file.c index 872134c0f..0fe170cf2 100644 --- a/src/dungeon-file.c +++ b/src/dungeon-file.c @@ -3928,7 +3928,7 @@ static errr process_dungeon_file_aux(player_type *player_ptr, char *buf, int ymi } else { - place_trap(floor_ptr, *y, *x); + place_trap(player_ptr, *y, *x); } floor_ptr->object_level = floor_ptr->base_level; @@ -3950,7 +3950,7 @@ static errr process_dungeon_file_aux(player_type *player_ptr, char *buf, int ymi /* Random trap */ else if (random & RANDOM_TRAP) { - place_trap(floor_ptr, *y, *x); + place_trap(player_ptr, *y, *x); } /* Hidden trap (or door) */ else if (letter[idx].trap) diff --git a/src/floor-events.c b/src/floor-events.c index 72ceaa357..ee8a6e555 100644 --- a/src/floor-events.c +++ b/src/floor-events.c @@ -292,7 +292,7 @@ void update_dungeon_feeling(player_type *subject_ptr, floor_type *floor_ptr) if (current_world_ptr->game_turn < subject_ptr->feeling_turn + delay && !cheat_xtra) return; /* Extract quest number (if any) */ - quest_num = quest_number(floor_ptr->dun_level); + quest_num = quest_number(subject_ptr, floor_ptr->dun_level); /* No feeling in a quest */ if (quest_num && diff --git a/src/floor-generate.c b/src/floor-generate.c index 19a6563fa..700f36b6f 100644 --- a/src/floor-generate.c +++ b/src/floor-generate.c @@ -184,18 +184,20 @@ static bool alloc_stairs_aux(floor_type *floor_ptr, POSITION y, POSITION x, int /*! * @brief 外壁に隣接させて階段を生成する / Places some staircases near walls + * @param owner_ptr プレーヤーへの参照ポインタ * @param feat 配置したい地形ID * @param num 配置したい階段の数 * @param walls 最低減隣接させたい外壁の数 * @return 規定数通りに生成に成功したらTRUEを返す。 */ -static bool alloc_stairs(floor_type *floor_ptr, FEAT_IDX feat, int num, int walls) +static bool alloc_stairs(player_type *owner_ptr, FEAT_IDX feat, int num, int walls) { int i; int shaft_num = 0; feature_type *f_ptr = &f_info[feat]; + floor_type *floor_ptr = owner_ptr->current_floor_ptr; if (have_flag(f_ptr->flags, FF_LESS)) { /* No up stairs in town or in ironman mode */ @@ -206,7 +208,7 @@ static bool alloc_stairs(floor_type *floor_ptr, FEAT_IDX feat, int num, int wall } else if (have_flag(f_ptr->flags, FF_MORE)) { - QUEST_IDX q_idx = quest_number(floor_ptr->dun_level); + QUEST_IDX q_idx = quest_number(owner_ptr, floor_ptr->dun_level); /* No downstairs on quest levels */ if (floor_ptr->dun_level > 1 && q_idx) @@ -221,7 +223,7 @@ static bool alloc_stairs(floor_type *floor_ptr, FEAT_IDX feat, int num, int wall /* No downstairs at the bottom */ if (floor_ptr->dun_level >= d_info[floor_ptr->dungeon_idx].maxdepth) return TRUE; - if ((floor_ptr->dun_level < d_info[floor_ptr->dungeon_idx].maxdepth-1) && !quest_number(floor_ptr->dun_level+1)) + if ((floor_ptr->dun_level < d_info[floor_ptr->dungeon_idx].maxdepth-1) && !quest_number(owner_ptr, floor_ptr->dun_level+1)) shaft_num = (randint1(num)+1)/2; } else return FALSE; @@ -368,7 +370,7 @@ static void alloc_object(player_type *owner_ptr, int set, EFFECT_ID typ, int num case ALLOC_TYP_TRAP: { - place_trap(floor_ptr, y, x); + place_trap(owner_ptr, y, x); floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR); break; } @@ -487,8 +489,9 @@ bool place_quest_monsters(floor_type *floor_ptr, player_type *creature_ptr) * @details There were moved from cave_gen(). * @return なし */ -static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, floor_type *floor_ptr) +static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, player_type *owner_ptr) { + floor_type *floor_ptr = owner_ptr->current_floor_ptr; #ifdef ALLOW_CAVERNS_AND_LAKES /* Possible "destroyed" level */ if ((floor_ptr->dun_level > 30) && one_in_(DUN_DEST*2) && (small_levels) && (dungeon_ptr->flags1 & DF1_DESTROY)) @@ -566,7 +569,7 @@ static void gen_caverns_and_lakes(dungeon_type *dungeon_ptr, floor_type *floor_p #endif /* ALLOW_CAVERNS_AND_LAKES */ /* Hack -- No destroyed "quest" levels */ - if (quest_number(floor_ptr->dun_level)) dun->destroyed = FALSE; + if (quest_number(owner_ptr, floor_ptr->dun_level)) dun->destroyed = FALSE; } @@ -670,7 +673,7 @@ static bool cave_gen(player_type *player_ptr) } /* Generate various caverns and lakes */ - gen_caverns_and_lakes(dungeon_ptr, floor_ptr); + gen_caverns_and_lakes(dungeon_ptr, player_ptr); /* Build maze */ if (dungeon_ptr->flags1 & DF1_MAZE) @@ -678,10 +681,10 @@ static bool cave_gen(player_type *player_ptr) build_maze_vault(player_ptr, floor_ptr->width/2-1, floor_ptr->height/2-1, floor_ptr->width-4, floor_ptr->height-4, FALSE); /* Place 3 or 4 down stairs near some walls */ - if (!alloc_stairs(floor_ptr, feat_down_stair, rand_range(2, 3), 3)) return FALSE; + if (!alloc_stairs(player_ptr, feat_down_stair, rand_range(2, 3), 3)) return FALSE; /* Place 1 or 2 up stairs near some walls */ - if (!alloc_stairs(floor_ptr, feat_up_stair, 1, 3)) return FALSE; + if (!alloc_stairs(player_ptr, feat_up_stair, 1, 3)) return FALSE; } /* Build some rooms */ @@ -876,10 +879,10 @@ static bool cave_gen(player_type *player_ptr) } /* Place 3 or 4 down stairs near some walls */ - if (!alloc_stairs(floor_ptr, feat_down_stair, rand_range(3, 4), 3)) return FALSE; + if (!alloc_stairs(player_ptr, feat_down_stair, rand_range(3, 4), 3)) return FALSE; /* Place 1 or 2 up stairs near some walls */ - if (!alloc_stairs(floor_ptr, feat_up_stair, rand_range(1, 2), 3)) return FALSE; + if (!alloc_stairs(player_ptr, feat_up_stair, rand_range(1, 2), 3)) return FALSE; } if (!dun->laketype) diff --git a/src/floor-save.c b/src/floor-save.c index 88fa00824..155345e7c 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -1338,7 +1338,7 @@ void change_floor(player_type *creature_ptr) /*** Create connected stairs ***/ /* No stairs down from Quest */ - if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr->current_floor_ptr->dun_level)) + if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level)) { g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair; } diff --git a/src/floor.c b/src/floor.c index 39745dd71..786b393b0 100644 --- a/src/floor.c +++ b/src/floor.c @@ -257,18 +257,19 @@ void add_door(floor_type* floor_ptr, POSITION x, POSITION y) * @param x 配置を試みたいマスのX座標 * @return なし */ -void place_random_stairs(floor_type *floor_ptr, POSITION y, POSITION x) +void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x) { bool up_stairs = TRUE; bool down_stairs = TRUE; grid_type *g_ptr; + floor_type *floor_ptr = player_ptr->current_floor_ptr; g_ptr = &floor_ptr->grid_array[y][x]; if (!is_floor_grid(g_ptr) || g_ptr->o_idx) return; if (!floor_ptr->dun_level) up_stairs = FALSE; if (ironman_downward) up_stairs = FALSE; if (floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) down_stairs = FALSE; - if (quest_number(floor_ptr->dun_level) && (floor_ptr->dun_level > 1)) down_stairs = FALSE; + if (quest_number(player_ptr, floor_ptr->dun_level) && (floor_ptr->dun_level > 1)) down_stairs = FALSE; /* We can't place both */ if (down_stairs && up_stairs) @@ -979,7 +980,7 @@ void place_closed_door(floor_type *floor_ptr, POSITION y, POSITION x, int type) * @details * Only really called by some of the "vault" routines. */ -void vault_trap_aux(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd) +void vault_trap_aux(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd) { int count = 0, y1 = y, x1 = x; int dummy = 0; @@ -987,6 +988,7 @@ void vault_trap_aux(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, grid_type *g_ptr; /* Place traps */ + floor_type *floor_ptr = player_ptr->current_floor_ptr; for (count = 0; count <= 5; count++) { /* Get a location */ @@ -1009,7 +1011,7 @@ void vault_trap_aux(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx) continue; /* Place the trap */ - place_trap(floor_ptr, y1, x1); + place_trap(player_ptr, y1, x1); break; } @@ -1928,6 +1930,7 @@ void compact_objects(floor_type *floor_ptr, int size) /*! * @brief 特殊な部屋向けに各種アイテムを配置する(メインルーチン) / Place some traps with a given displacement of given location + * @param player_ptr プレーヤーへの参照ポインタ * @param y トラップを配置したいマスの中心Y座標 * @param x トラップを配置したいマスの中心X座標 * @param yd Y方向の配置分散マス数 @@ -1937,13 +1940,13 @@ void compact_objects(floor_type *floor_ptr, int size) * @details * Only really called by some of the "vault" routines. */ -void vault_traps(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num) +void vault_traps(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num) { int i; for (i = 0; i < num; i++) { - vault_trap_aux(floor_ptr, y, x, yd, xd); + vault_trap_aux(player_ptr, y, x, yd, xd); } } diff --git a/src/floor.h b/src/floor.h index 347e0df56..c9b75c9c0 100644 --- a/src/floor.h +++ b/src/floor.h @@ -380,7 +380,7 @@ extern void add_door(floor_type *floor_ptr, POSITION x, POSITION y); extern void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type); extern void place_locked_door(floor_type *floor_ptr, POSITION y, POSITION x); extern void forget_flow(floor_type *floor_ptr); -extern void place_random_stairs(floor_type *floor_ptr, POSITION y, POSITION x); +extern void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x); extern bool los(floor_type* floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2); extern bool projectable(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2); @@ -393,7 +393,7 @@ extern void place_random_door(floor_type *floor_ptr, POSITION y, POSITION x, boo extern void place_closed_door(floor_type *floor_ptr, POSITION y, POSITION x, int type); extern void wipe_o_list(floor_type *floor_ptr); -extern void vault_trap_aux(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd); +extern void vault_trap_aux(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd); extern bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y); extern void try_door(floor_type *floor_ptr, POSITION y, POSITION x); @@ -427,5 +427,5 @@ extern void place_object(player_type *owner_ptr, POSITION y, POSITION x, BIT_FLA extern void place_gold(floor_type *floor_ptr, POSITION y, POSITION x); extern void delete_monster(floor_type *floor_ptr, POSITION y, POSITION x); extern void compact_objects(floor_type *floor_ptr, int size); -extern void vault_traps(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num); +extern void vault_traps(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num); extern void scatter(floor_type *floor_ptr, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode); diff --git a/src/load.c b/src/load.c index d9c876986..4d52d7c9e 100644 --- a/src/load.c +++ b/src/load.c @@ -2560,12 +2560,13 @@ static void rd_messages(void) /*! * @brief メッセージログを読み込む / Read the dungeon (old method) + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし * @details * The monsters/objects must be loaded in the same order * that they were stored, since the actual indexes matter. */ -static errr rd_dungeon_old(floor_type *floor_ptr) +static errr rd_dungeon_old(player_type *creature_ptr) { int i, y, x; int ymax, xmax; @@ -2580,6 +2581,7 @@ static errr rd_dungeon_old(floor_type *floor_ptr) /* Header info */ rd_s16b(&tmp16s); + floor_type *floor_ptr = creature_ptr->current_floor_ptr; floor_ptr->dun_level = (DEPTH)tmp16s; if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND; else @@ -2804,7 +2806,7 @@ static errr rd_dungeon_old(floor_type *floor_ptr) { g_ptr->info &= ~CAVE_TRAP; g_ptr->mimic = g_ptr->feat; - g_ptr->feat = choose_random_trap(floor_ptr); + g_ptr->feat = choose_random_trap(creature_ptr); } /* Another hidden trap */ @@ -3277,7 +3279,7 @@ static errr rd_dungeon(player_type *player_ptr) /* Older method */ if (h_older_than(1, 5, 0, 0)) { - err = rd_dungeon_old(player_ptr->current_floor_ptr); + err = rd_dungeon_old(player_ptr); /* Prepare floor_id of current floor */ if (player_ptr->dungeon_idx) diff --git a/src/monster2.c b/src/monster2.c index 82b93a65a..403d884a0 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -2547,9 +2547,9 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I } } - if (quest_number(p_ptr->current_floor_ptr->dun_level)) + if (quest_number(p_ptr, p_ptr->current_floor_ptr->dun_level)) { - int hoge = quest_number(p_ptr->current_floor_ptr->dun_level); + int hoge = quest_number(p_ptr, p_ptr->current_floor_ptr->dun_level); if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM)) { if(r_idx == quest[hoge].r_idx) diff --git a/src/player-damage.c b/src/player-damage.c index e6f3b4554..a896c29ce 100644 --- a/src/player-damage.c +++ b/src/player-damage.c @@ -508,7 +508,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp } else { - QUEST_IDX q_idx = quest_number(creature_ptr->current_floor_ptr->dun_level); + QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level); bool seppuku = streq(hit_from, "Seppuku"); bool winning_seppuku = current_world_ptr->total_winner && seppuku; diff --git a/src/quest.c b/src/quest.c index 820e3fc6a..9bf40f57d 100644 --- a/src/quest.c +++ b/src/quest.c @@ -397,13 +397,13 @@ void quest_discovery(QUEST_IDX q_idx) * @param level 検索対象になる階 * @return クエストIDを返す。該当がない場合0を返す。 */ -QUEST_IDX quest_number(DEPTH level) +QUEST_IDX quest_number(player_type *player_ptr, DEPTH level) { QUEST_IDX i; - /* Check quests */ - if (p_ptr->current_floor_ptr->inside_quest) - return (p_ptr->current_floor_ptr->inside_quest); + floor_type *floor_ptr = player_ptr->current_floor_ptr; + if (floor_ptr->inside_quest) + return (floor_ptr->inside_quest); for (i = 0; i < max_q_idx; i++) { @@ -412,7 +412,7 @@ QUEST_IDX quest_number(DEPTH level) if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) && !(quest[i].flags & QUEST_FLAG_PRESET) && (quest[i].level == level) && - (quest[i].dungeon == p_ptr->dungeon_idx)) + (quest[i].dungeon == player_ptr->dungeon_idx)) return (i); } diff --git a/src/quest.h b/src/quest.h index 70c24c461..602ea3bdd 100644 --- a/src/quest.h +++ b/src/quest.h @@ -90,7 +90,7 @@ extern void complete_quest(player_type *player_ptr, QUEST_IDX quest_num); extern void check_quest_completion(player_type *player_ptr, monster_type *m_ptr); extern void check_find_art_quest_completion(player_type *player_ptr, object_type *o_ptr); extern void quest_discovery(QUEST_IDX q_idx); -extern QUEST_IDX quest_number(DEPTH level); +extern QUEST_IDX quest_number(player_type *player_ptr, DEPTH level); extern QUEST_IDX random_quest_number(DEPTH level); extern void leave_quest_check(player_type *player_ptr); extern void leave_tower_check(void); diff --git a/src/rooms-normal.c b/src/rooms-normal.c index f0dab6e6c..d97a0567a 100644 --- a/src/rooms-normal.c +++ b/src/rooms-normal.c @@ -501,7 +501,7 @@ bool build_type3(player_type *player_ptr) vault_monsters(floor_ptr, yval, xval, randint0(2) + 3); /* Traps naturally */ - vault_traps(floor_ptr, yval, xval, 4, 4, randint0(3) + 2); + vault_traps(player_ptr, yval, xval, 4, 4, randint0(3) + 2); break; } @@ -724,11 +724,11 @@ bool build_type4(player_type *player_ptr) /* Stairs (20%) */ else { - place_random_stairs(floor_ptr, yval, xval); + place_random_stairs(player_ptr, yval, xval); } /* Traps to protect the treasure */ - vault_traps(floor_ptr, yval, xval, 4, 10, 2 + randint1(3)); + vault_traps(player_ptr, yval, xval, 4, 10, 2 + randint1(3)); break; } @@ -842,8 +842,8 @@ bool build_type4(player_type *player_ptr) vault_monsters(floor_ptr, yval, xval + 5, randint1(3)); /* Traps make them entertaining. */ - vault_traps(floor_ptr, yval, xval - 3, 2, 8, randint1(3)); - vault_traps(floor_ptr, yval, xval + 3, 2, 8, randint1(3)); + vault_traps(player_ptr, yval, xval - 3, 2, 8, randint1(3)); + vault_traps(player_ptr, yval, xval + 3, 2, 8, randint1(3)); /* Mazes should have some treasure too. */ vault_objects(player_ptr, yval, xval, 3); @@ -1044,9 +1044,8 @@ bool build_type12(player_type *player_ptr) vault_monsters(floor_ptr, y0, x0, randint0(2) + 3); /* Traps naturally */ - vault_traps(floor_ptr, y0, x0, 4, 4, randint0(3) + 2); + vault_traps(player_ptr, y0, x0, 4, 4, randint0(3) + 2); } return TRUE; } - diff --git a/src/rooms-vault.c b/src/rooms-vault.c index 81c26a703..24884f44b 100644 --- a/src/rooms-vault.c +++ b/src/rooms-vault.c @@ -410,7 +410,7 @@ static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, P } else { - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); } break; @@ -442,7 +442,7 @@ static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, P /* Trap */ case '^': - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); break; /* Black market in a dungeon */ diff --git a/src/rooms.c b/src/rooms.c index 1f3be33ed..50b1a46a4 100644 --- a/src/rooms.c +++ b/src/rooms.c @@ -1455,7 +1455,7 @@ void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y } else { - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); } } else if (value < 30) @@ -1464,7 +1464,7 @@ void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y floor_ptr->monster_level = floor_ptr->base_level + 5; place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP)); floor_ptr->monster_level = floor_ptr->base_level; - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); } else if (value < 40) { @@ -1485,7 +1485,7 @@ void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y else if (value < 50) { /* Trap */ - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); } else { @@ -1498,7 +1498,7 @@ void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y } else if (randint0(100) < 50) { - place_trap(floor_ptr, y, x); + place_trap(player_ptr, y, x); } else if (randint0(100) < 50) { diff --git a/src/spells-floor.c b/src/spells-floor.c index 437a97b12..43b2f3ae4 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -264,7 +264,7 @@ void stair_creation(player_type *caster_ptr) /* Forbid down staircases on quest level */ bool down = TRUE; floor_type *floor_ptr = caster_ptr->current_floor_ptr; - if (quest_number(floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth)) down = FALSE; + if (quest_number(caster_ptr, floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth)) down = FALSE; /* No effect out of standard dungeon floor */ if (!floor_ptr->dun_level || (!up && !down) || diff --git a/src/spells1.c b/src/spells1.c index 94002c033..543fff6aa 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -505,7 +505,7 @@ if (have_flag(f_ptr->flags, FF_TREE)) case GF_MAKE_TRAP: { - place_trap(floor_ptr, y, x); + place_trap(caster_ptr, y, x); break; } diff --git a/src/spells3.c b/src/spells3.c index ca5c3fb61..64fb30334 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -675,7 +675,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx) } /* Up only */ - else if (quest_number(creature_ptr->current_floor_ptr->dun_level) || (creature_ptr->current_floor_ptr->dun_level >= d_info[creature_ptr->dungeon_idx].maxdepth)) + else if (quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level) || (creature_ptr->current_floor_ptr->dun_level >= d_info[creature_ptr->dungeon_idx].maxdepth)) { #ifdef JP if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name); @@ -3514,7 +3514,7 @@ bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx) bool is_special_floor = floor_ptr->inside_arena || caster_ptr->phase_out || (floor_ptr->inside_quest && !random_quest_number(floor_ptr->dun_level)); bool is_invalid_floor = idx <= 0; - is_invalid_floor &= quest_number(floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth); + is_invalid_floor &= quest_number(caster_ptr, floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth); is_invalid_floor &= caster_ptr->current_floor_ptr->dun_level >= 1; is_invalid_floor &= ironman_downward; return is_special_floor || is_invalid_floor; diff --git a/src/trap.c b/src/trap.c index 590f4db3c..22d73a706 100644 --- a/src/trap.c +++ b/src/trap.c @@ -144,11 +144,12 @@ void init_normal_traps(void) * Actually, it is not this routine, but the "trap instantiation"\n * code, which should also check for "trap doors" on quest levels.\n */ -FEAT_IDX choose_random_trap(floor_type *floor_ptr) +FEAT_IDX choose_random_trap(player_type *trapped_ptr) { FEAT_IDX feat; /* Pick a trap */ + floor_type *floor_ptr = trapped_ptr->current_floor_ptr; while (TRUE) { /* Hack -- pick a trap */ @@ -158,7 +159,7 @@ FEAT_IDX choose_random_trap(floor_type *floor_ptr) if (!have_flag(f_info[feat].flags, FF_MORE)) break; /* Hack -- no trap doors on special levels */ - if (floor_ptr->inside_arena || quest_number(floor_ptr->dun_level)) continue; + if (floor_ptr->inside_arena || quest_number(trapped_ptr, floor_ptr->dun_level)) continue; /* Hack -- no trap doors on the deepest level */ if (floor_ptr->dun_level >= d_info[floor_ptr->dungeon_idx].maxdepth) continue; @@ -208,8 +209,9 @@ void disclose_grid(player_type *trapped_ptr, POSITION y, POSITION x) * when they are "discovered" (by detecting them or setting them off),\n * the trap is "instantiated" as a visible, "typed", trap.\n */ -void place_trap(floor_type *floor_ptr, POSITION y, POSITION x) +void place_trap(player_type *trapped_ptr, POSITION y, POSITION x) { + floor_type *floor_ptr = trapped_ptr->current_floor_ptr; grid_type *g_ptr = &floor_ptr->grid_array[y][x]; /* Paranoia -- verify location */ @@ -220,7 +222,7 @@ void place_trap(floor_type *floor_ptr, POSITION y, POSITION x) /* Place an invisible trap */ g_ptr->mimic = g_ptr->feat; - g_ptr->feat = choose_random_trap(floor_ptr); + g_ptr->feat = choose_random_trap(trapped_ptr); } diff --git a/src/trap.h b/src/trap.h index cc5d17b58..4982a848f 100644 --- a/src/trap.h +++ b/src/trap.h @@ -1,8 +1,8 @@  extern void init_normal_traps(void); -extern FEAT_IDX choose_random_trap(floor_type *floor_ptr); +extern FEAT_IDX choose_random_trap(player_type *trapped_ptr); extern void disclose_grid(player_type *trapped_ptr, POSITION y, POSITION x); -extern void place_trap(floor_type *floor_ptr, POSITION y, POSITION x); +extern void place_trap(player_type *trapped_ptr, POSITION y, POSITION x); extern void hit_trap(player_type *trapped_ptr, bool break_trap); extern const int chest_traps[64]; -- 2.11.0