From dc594aecf753be6bcb09c2b882ed9bc999ac810b Mon Sep 17 00:00:00 2001 From: Hourier Date: Thu, 9 Jan 2020 23:40:58 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20o=5Fpop()=E3=80=81drop=5Fn?= =?utf8?q?ear()=E3=80=81inven=5Fdrop()=20=E3=81=ABplayer=5Ftype=20*?= =?utf8?q?=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0=20(=E3=82=B3?= =?utf8?q?=E3=83=BC=E3=83=AB=E3=83=81=E3=82=A7=E3=83=BC=E3=83=B3=E3=81=8C?= =?utf8?q?=E9=95=B7=E3=81=84=E3=81=AE=E3=81=A7=E3=81=9D=E3=81=AE=E4=BB=96?= =?utf8?q?=E7=9C=81=E7=95=A5)=20/=20Added=20player=5Ftype=20*=20argument?= =?utf8?q?=20to=20o=5Fpop(),=20drop=5Fnear()=20and=20inven=5Fdrop()=20(Not?= =?utf8?q?es:=20Omitted=20description=20about=20other=20functions=20becaus?= =?utf8?q?e=20call=20chains=20were=20too=20long)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/artifact.c | 5 +- src/artifact.h | 2 +- src/autopick.c | 10 ++-- src/autopick.h | 2 +- src/birth.c | 7 +-- src/bldg.c | 18 ++++--- src/chest.c | 4 +- src/cmd/cmd-basic.c | 8 +-- src/cmd/cmd-dump.c | 21 ++++---- src/cmd/cmd-eat.c | 2 +- src/cmd/cmd-item.c | 2 +- src/cmd/cmd-read.c | 8 +-- src/combat/melee1.c | 2 +- src/combat/shoot.c | 6 +-- src/core.c | 10 ++-- src/dungeon-file.c | 21 ++++---- src/dungeon-file.h | 2 +- src/files.c | 4 +- src/floor-generate.c | 12 +++-- src/floor-save.c | 2 +- src/floor-streams.c | 2 +- src/floor.c | 6 +-- src/init.c | 12 ++--- src/init.h | 3 +- src/load.c | 6 +-- src/main-win.c | 2 +- src/monster-process.c | 6 +-- src/monster1.c | 57 ++++++++++------------ src/monster2.c | 6 +-- src/object.h | 18 ++++--- src/object2.c | 130 ++++++++++++++++++++++--------------------------- src/patron.c | 8 +-- src/player-inventory.c | 4 +- src/player-move.c | 4 +- src/player-status.c | 18 +++---- src/quest.c | 28 +++++------ src/quest.h | 2 +- src/realm-nature.c | 2 +- src/spells-floor.c | 83 +++++++++++++++---------------- src/spells-object.c | 12 +++-- src/spells-object.h | 4 +- src/spells-status.c | 2 +- src/spells1.c | 6 +-- src/spells2.c | 6 +-- src/spells3.c | 23 ++++----- src/targeting.c | 4 +- src/wild.c | 42 ++++++++-------- src/wild.h | 4 +- src/wizard2.c | 16 +++--- 49 files changed, 333 insertions(+), 331 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index c780e6cd4..6d69e6be9 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -2045,6 +2045,7 @@ void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr) /*! * @brief フロアの指定された位置に固定アーティファクトを生成する。 / Create the artifact of the specified number * @details 固定アーティファクト構造体から基本ステータスをコピーした後、所定の座標でdrop_item()で落とす。 + * @param player_ptr プレーヤーへの参照ポインタ * @param a_idx 生成する固定アーティファクト構造体のID * @param y アイテムを落とす地点のy座標 * @param x アイテムを落とす地点のx座標 @@ -2053,7 +2054,7 @@ void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr) * 仮に2個以上存在可能かつ装備品以外の固定アーティファクトが作成されれば * drop_near()関数の返り値は信用できなくなる. */ -bool create_named_art(ARTIFACT_IDX a_idx, POSITION y, POSITION x) +bool create_named_art(player_type *player_ptr, ARTIFACT_IDX a_idx, POSITION y, POSITION x) { object_type forge; object_type *q_ptr; @@ -2096,7 +2097,7 @@ bool create_named_art(ARTIFACT_IDX a_idx, POSITION y, POSITION x) random_artifact_resistance(q_ptr, a_ptr); /* Drop the artifact from heaven */ - return drop_near(q_ptr, -1, y, x) ? TRUE : FALSE; + return drop_near(player_ptr, q_ptr, -1, y, x) ? TRUE : FALSE; } /*対邪平均ダメージの計算処理*/ diff --git a/src/artifact.h b/src/artifact.h index f2750b4ef..6114b7f0a 100644 --- a/src/artifact.h +++ b/src/artifact.h @@ -78,7 +78,7 @@ extern bool become_random_artifact(object_type *o_ptr, bool a_scroll); extern int activation_index(object_type *o_ptr); extern const activation_type* find_activation_info(object_type *o_ptr); extern void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr); -extern bool create_named_art(ARTIFACT_IDX a_idx, POSITION y, POSITION x); +extern bool create_named_art(player_type *player_ptr, ARTIFACT_IDX a_idx, POSITION y, POSITION x); extern bool make_artifact(object_type *o_ptr); extern bool make_artifact_special(object_type *o_ptr); diff --git a/src/autopick.c b/src/autopick.c index 1788ba91e..f31aa92aa 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -1636,7 +1636,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx) /* * Auto-destroy marked item */ -static void autopick_delayed_alter_aux(INVENTORY_IDX item) +static void autopick_delayed_alter_aux(floor_type *floor_ptr, INVENTORY_IDX item) { object_type *o_ptr; @@ -1659,7 +1659,7 @@ static void autopick_delayed_alter_aux(INVENTORY_IDX item) /* Eliminate the item (from the floor) */ else { - delete_object_idx(0 - item); + delete_object_idx(floor_ptr, 0 - item); } msg_format(_("%sを自動破壊します。", "Auto-destroying %s."), o_name); @@ -1670,7 +1670,7 @@ static void autopick_delayed_alter_aux(INVENTORY_IDX item) /* * Auto-destroy marked items in inventry and on floor */ -void autopick_delayed_alter(void) +void autopick_delayed_alter(floor_type *floor_ptr) { INVENTORY_IDX item; @@ -1679,14 +1679,14 @@ void autopick_delayed_alter(void) * skipping after inven_item_optimize() */ for (item = INVEN_TOTAL - 1; item >= 0 ; item--) - autopick_delayed_alter_aux(item); + autopick_delayed_alter_aux(floor_ptr, item); /* Scan the pile of objects */ item = p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; while (item) { OBJECT_IDX next = p_ptr->current_floor_ptr->o_list[item].next_o_idx; - autopick_delayed_alter_aux(-item); + autopick_delayed_alter_aux(floor_ptr, -item); item = next; } } diff --git a/src/autopick.h b/src/autopick.h index 169a36758..0bab06d4f 100644 --- a/src/autopick.h +++ b/src/autopick.h @@ -33,7 +33,7 @@ extern errr process_autopick_file_command(char *buf); extern concptr autopick_line_from_entry(autopick_type *entry); extern int is_autopick(object_type *o_ptr); extern void autopick_alter_item(INVENTORY_IDX item, bool destroy); -extern void autopick_delayed_alter(void); +extern void autopick_delayed_alter(floor_type *floor_ptr); extern void autopick_pickup_items(grid_type *g_ptr); extern bool autopick_autoregister(object_type *o_ptr); extern void do_cmd_edit_autopick(player_type *player_ptr); diff --git a/src/birth.c b/src/birth.c index 10a554aa8..98ed0a7de 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1877,6 +1877,7 @@ static void player_wipe_without_name(player_type *creature_ptr) /*! * @brief ダンジョン内部のクエストを初期化する / Initialize random quests and final quests + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし */ static void init_dungeon_quests(player_type *creature_ptr) @@ -1888,7 +1889,7 @@ static void init_dungeon_quests(player_type *creature_ptr) init_flags = INIT_ASSIGN; creature_ptr->current_floor_ptr->inside_quest = MIN_RANDOM_QUEST; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); creature_ptr->current_floor_ptr->inside_quest = 0; @@ -1912,13 +1913,13 @@ static void init_dungeon_quests(player_type *creature_ptr) init_flags = INIT_ASSIGN; creature_ptr->current_floor_ptr->inside_quest = QUEST_OBERON; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); quest[QUEST_OBERON].status = QUEST_STATUS_TAKEN; creature_ptr->current_floor_ptr->inside_quest = QUEST_SERPENT; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); quest[QUEST_SERPENT].status = QUEST_STATUS_TAKEN; creature_ptr->current_floor_ptr->inside_quest = 0; diff --git a/src/bldg.c b/src/bldg.c index 1b628ddf7..74c67c9a9 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -2098,11 +2098,12 @@ static bool inn_comm(player_type *customer_ptr, int cmd) /*! * @brief クエスト情報を表示しつつ処理する。/ Display quest information + * @param player_ptr プレーヤーへの参照ポインタ * @param questnum クエストのID * @param do_init クエストの開始処理(TRUE)、結果処理か(FALSE) * @return なし */ -static void get_questinfo(IDX questnum, bool do_init) +static void get_questinfo(player_type *player_ptr, IDX questnum, bool do_init) { int i; QUEST_IDX old_quest; @@ -2124,7 +2125,7 @@ static void get_questinfo(IDX questnum, bool do_init) init_flags = INIT_SHOW_TEXT; if (do_init) init_flags |= INIT_ASSIGN; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(player_ptr, "q_info.txt", 0, 0, 0, 0); /* Reset the old quest number */ p_ptr->current_floor_ptr->inside_quest = old_quest; @@ -2144,9 +2145,10 @@ static void get_questinfo(IDX questnum, bool do_init) /*! * @brief クエスト処理のメインルーチン / Request a quest from the Lord. + * @param player_ptr プレーヤーへの参照ポインタ * @return なし */ -static void castle_quest(void) +static void castle_quest(player_type *player_ptr) { QUEST_IDX q_index = 0; monster_race *r_ptr; @@ -2157,7 +2159,7 @@ static void castle_quest(void) clear_bldg(4, 18); /* Current quest of the building */ - q_index = p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special; + q_index = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special; /* Is there a quest available at the building? */ if (!q_index) @@ -2174,14 +2176,14 @@ static void castle_quest(void) /* Rewarded quest */ q_ptr->status = QUEST_STATUS_REWARDED; - get_questinfo(q_index, FALSE); + get_questinfo(player_ptr, q_index, FALSE); reinit_wilderness = TRUE; } /* Failed quest */ else if (q_ptr->status == QUEST_STATUS_FAILED) { - get_questinfo(q_index, FALSE); + get_questinfo(player_ptr, q_index, FALSE); /* Mark quest as done (but failed) */ q_ptr->status = QUEST_STATUS_FAILED_DONE; @@ -2234,7 +2236,7 @@ static void castle_quest(void) } else { - get_questinfo(q_index, TRUE); + get_questinfo(player_ptr, q_index, TRUE); } } } @@ -3899,7 +3901,7 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i race_legends(p_ptr); break; case BACT_QUEST: - castle_quest(); + castle_quest(player_ptr); break; case BACT_KING_LEGENDS: case BACT_ARENA_LEGENDS: diff --git a/src/chest.c b/src/chest.c index ce47b3c40..0a80e1393 100644 --- a/src/chest.c +++ b/src/chest.c @@ -102,14 +102,14 @@ void chest_death(player_type *owner_ptr, bool scatter, POSITION y, POSITION x, O if (!cave_empty_bold(owner_ptr->current_floor_ptr, y, x)) continue; /* Place the object there. */ - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(owner_ptr, q_ptr, -1, y, x); /* Done. */ break; } } /* Normally, drop object near the chest. */ - else (void)drop_near(q_ptr, -1, y, x); + else (void)drop_near(owner_ptr, q_ptr, -1, y, x); } /* Reset the object level */ diff --git a/src/cmd/cmd-basic.c b/src/cmd/cmd-basic.c index 4e86d5e2c..dc2d78696 100644 --- a/src/cmd/cmd-basic.c +++ b/src/cmd/cmd-basic.c @@ -228,7 +228,7 @@ void do_cmd_go_up(player_type *creature_ptr) if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) { init_flags = INIT_ASSIGN; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); } quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN; } @@ -375,7 +375,7 @@ void do_cmd_go_down(player_type *creature_ptr) if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) { init_flags = INIT_ASSIGN; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); } quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN; } @@ -2799,11 +2799,11 @@ bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_ID { if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT)) { - (void)drop_near(q_ptr, j, y, x); + (void)drop_near(creature_ptr, q_ptr, j, y, x); } else { - (void)drop_near(q_ptr, j, prev_y, prev_x); + (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x); } } diff --git a/src/cmd/cmd-dump.c b/src/cmd/cmd-dump.c index 63f649115..3c367d2cf 100644 --- a/src/cmd/cmd-dump.c +++ b/src/cmd/cmd-dump.c @@ -431,7 +431,7 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note) /* Get the quest text */ init_flags = INIT_NAME_ONLY; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); /* Reset the old quest number */ creature_ptr->current_floor_ptr->inside_quest = old_quest; @@ -6348,7 +6348,7 @@ static void do_cmd_knowledge_quests_current(player_type *creature_ptr, FILE *fff /* Get the quest text */ init_flags = INIT_SHOW_TEXT; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); /* Reset the old quest number */ creature_ptr->current_floor_ptr->inside_quest = old_quest; @@ -6483,12 +6483,13 @@ static void do_cmd_knowledge_quests_current(player_type *creature_ptr, FILE *fff } -static bool do_cmd_knowledge_quests_aux(FILE *fff, floor_type *floor_ptr, IDX q_idx) +static bool do_cmd_knowledge_quests_aux(player_type *player_ptr, FILE *fff, IDX q_idx) { char tmp_str[120]; char playtime_str[16]; quest_type* const q_ptr = &quest[q_idx]; + floor_type *floor_ptr = player_ptr->current_floor_ptr; if (is_fixed_quest_idx(q_idx)) { /* Set the quest number temporary */ @@ -6499,7 +6500,7 @@ static bool do_cmd_knowledge_quests_aux(FILE *fff, floor_type *floor_ptr, IDX q_ /* Get the quest */ init_flags = INIT_NAME_ONLY; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(player_ptr, "q_info.txt", 0, 0, 0, 0); /* Reset the old quest number */ floor_ptr->inside_quest = old_quest; @@ -6562,7 +6563,7 @@ void do_cmd_knowledge_quests_completed(player_type *creature_ptr, FILE *fff, QUE QUEST_IDX q_idx = quest_num[i]; quest_type* const q_ptr = &quest[q_idx]; - if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(fff, creature_ptr->current_floor_ptr, q_idx)) + if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx)) { ++total; } @@ -6589,7 +6590,7 @@ void do_cmd_knowledge_quests_failed(player_type *creature_ptr, FILE *fff, QUEST_ quest_type* const q_ptr = &quest[q_idx]; if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) && - do_cmd_knowledge_quests_aux(fff, creature_ptr->current_floor_ptr, q_idx)) + do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx)) { ++total; } @@ -6678,10 +6679,12 @@ static void do_cmd_knowledge_quests(player_type *creature_ptr) /* * List my home + * @param player_ptr プレーヤーへの参照ポインタ + * @return なし */ -static void do_cmd_knowledge_home(void) +static void do_cmd_knowledge_home(player_type *player_ptr) { - process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); /* Open a new file */ FILE *fff; @@ -6926,7 +6929,7 @@ void do_cmd_knowledge(player_type *creature_ptr) do_cmd_knowledge_pets(creature_ptr); break; case '8': /* Home */ - do_cmd_knowledge_home(); + do_cmd_knowledge_home(creature_ptr); break; case '9': /* Resist list */ do_cmd_knowledge_inven(creature_ptr); diff --git a/src/cmd/cmd-eat.c b/src/cmd/cmd-eat.c index 31c2b09c2..7287e265b 100644 --- a/src/cmd/cmd-eat.c +++ b/src/cmd/cmd-eat.c @@ -433,7 +433,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item) object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval)); /* Drop the object from heaven */ - (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x); + (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x); } else { diff --git a/src/cmd/cmd-item.c b/src/cmd/cmd-item.c index 6d4aaf519..ef3ac8323 100644 --- a/src/cmd/cmd-item.c +++ b/src/cmd/cmd-item.c @@ -592,7 +592,7 @@ void do_cmd_drop(player_type *creature_ptr) take_turn(creature_ptr, 50); /* Drop (some of) the item */ - inven_drop(item, amt); + inven_drop(creature_ptr, item, amt); if (item >= INVEN_RARM) { diff --git a/src/cmd/cmd-read.c b/src/cmd/cmd-read.c index c9c114eb1..ee7ac5f72 100644 --- a/src/cmd/cmd-read.c +++ b/src/cmd/cmd-read.c @@ -431,14 +431,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known) case SV_SCROLL_ACQUIREMENT: { - acquirement(creature_ptr->y, creature_ptr->x, 1, TRUE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, 1, TRUE, FALSE, FALSE); ident = TRUE; break; } case SV_SCROLL_STAR_ACQUIREMENT: { - acquirement(creature_ptr->y, creature_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE); ident = TRUE; break; } @@ -505,14 +505,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known) case SV_SCROLL_AMUSEMENT: { ident = TRUE; - amusement(creature_ptr->y, creature_ptr->x, 1, FALSE); + amusement(creature_ptr, creature_ptr->y, creature_ptr->x, 1, FALSE); break; } case SV_SCROLL_STAR_AMUSEMENT: { ident = TRUE; - amusement(creature_ptr->y, creature_ptr->x, randint1(2) + 1, FALSE); + amusement(creature_ptr, creature_ptr->y, creature_ptr->x, randint1(2) + 1, FALSE); break; } } diff --git a/src/combat/melee1.c b/src/combat/melee1.c index 162c46a54..f0f0061ed 100644 --- a/src/combat/melee1.c +++ b/src/combat/melee1.c @@ -3013,7 +3013,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx) msg_format("%sour %s (%c) was stolen!", ((o_ptr->number > 1) ? "One of y" : "Y"), o_name, index_to_label(i)); #endif chg_virtue(target_ptr, V_SACRIFICE, 1); - o_idx = o_pop(); + o_idx = o_pop(target_ptr->current_floor_ptr); /* Success */ if (o_idx) diff --git a/src/combat/shoot.c b/src/combat/shoot.c index 32c0b87a2..59b613dff 100644 --- a/src/combat/shoot.c +++ b/src/combat/shoot.c @@ -831,7 +831,7 @@ void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, { MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx; monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx]; - OBJECT_IDX o_idx = o_pop(); + OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr); if (!o_idx) { @@ -864,12 +864,12 @@ void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT)) { /* Drop (or break) near that location */ - (void)drop_near(q_ptr, j, y, x); + (void)drop_near(shooter_ptr, q_ptr, j, y, x); } else { /* Drop (or break) near that location */ - (void)drop_near(q_ptr, j, prev_y, prev_x); + (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x); } /* Sniper - Repeat shooting when double shots */ diff --git a/src/core.c b/src/core.c index b61126218..886d0fbdf 100644 --- a/src/core.c +++ b/src/core.c @@ -2579,7 +2579,7 @@ static void process_world_aux_mutation(player_type *creature_ptr) if (slot && !object_is_cursed(o_ptr)) { msg_print(_("武器を落としてしまった!", "You drop your weapon!")); - inven_drop(slot, 1); + inven_drop(creature_ptr, slot, 1); } } @@ -4325,7 +4325,7 @@ static void pack_overflow(player_type *owner_ptr) msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK)); /* Drop it (carefully) near the player */ - (void)drop_near(o_ptr, 0, owner_ptr->y, owner_ptr->x); + (void)drop_near(owner_ptr, o_ptr, 0, owner_ptr->y, owner_ptr->x); vary_item(INVEN_PACK, -255); handle_stuff(); @@ -5312,7 +5312,7 @@ void play_game(player_type *player_ptr, bool new_game) highscore_fd = fd_open(buf, O_RDWR); /* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */ - process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); /* Handle score, show Top scores */ success = send_world_score(player_ptr, TRUE); @@ -5497,9 +5497,9 @@ void play_game(player_type *player_ptr, bool new_game) /* Initialize the town-buildings if necessary */ if (!player_ptr->current_floor_ptr->dun_level && !player_ptr->current_floor_ptr->inside_quest) { - process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); init_flags = INIT_ONLY_BUILDINGS; - process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID); + process_dungeon_file(player_ptr, "t_info.txt", 0, 0, MAX_HGT, MAX_WID); select_floor_music(player_ptr); } diff --git a/src/dungeon-file.c b/src/dungeon-file.c index 260322fc2..3da00f08a 100644 --- a/src/dungeon-file.c +++ b/src/dungeon-file.c @@ -3857,12 +3857,12 @@ static errr parse_line_building(char *buf) * @param x 配置先X座標 * @return エラーコード */ -static void drop_here(object_type *j_ptr, POSITION y, POSITION x) +static void drop_here(floor_type *floor_ptr, object_type *j_ptr, POSITION y, POSITION x) { grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; object_type *o_ptr; - OBJECT_IDX o_idx = o_pop(); + OBJECT_IDX o_idx = o_pop(floor_ptr); /* Access new object */ o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; @@ -3886,6 +3886,7 @@ static void drop_here(object_type *j_ptr, POSITION y, POSITION x) /*! * @brief クエスト用固定ダンジョンをフロアに生成する * Parse a sub-file of the "extra info" + * @param player_ptr プレーヤーへの参照ポインタ * @param buf 文字列 * @param ymin 詳細不明 * @param xmin 詳細不明 @@ -3895,7 +3896,7 @@ static void drop_here(object_type *j_ptr, POSITION y, POSITION x) * @param x 詳細不明 * @return エラーコード */ -static errr process_dungeon_file_aux(floor_type *floor_ptr, char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x) +static errr process_dungeon_file_aux(player_type *player_ptr, char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x) { int i; char *zz[33]; @@ -3917,9 +3918,10 @@ static errr process_dungeon_file_aux(floor_type *floor_ptr, char *buf, int ymin, if (buf[0] == '%') { /* Attempt to Process the given file */ - return (process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax)); + return (process_dungeon_file(player_ptr, buf + 2, ymin, xmin, ymax, xmax)); } + floor_type *floor_ptr = player_ptr->current_floor_ptr; /* Process "F:::::::::" -- info for dungeon grid */ if (buf[0] == 'F') { @@ -4071,7 +4073,7 @@ static errr process_dungeon_file_aux(floor_type *floor_ptr, char *buf, int ymin, /* Apply magic (no messages, no artifacts) */ apply_magic(o_ptr, floor_ptr->base_level, AM_NO_FIXED_ART | AM_GOOD); - drop_here(o_ptr, *y, *x); + drop_here(floor_ptr, o_ptr, *y, *x); } /* Artifact */ @@ -4084,11 +4086,11 @@ static errr process_dungeon_file_aux(floor_type *floor_ptr, char *buf, int ymin, object_type *q_ptr = &forge; object_prep(q_ptr, k_idx); - drop_here(q_ptr, *y, *x); + drop_here(floor_ptr, q_ptr, *y, *x); } else { - if (create_named_art(artifact_index, *y, *x)) + if (create_named_art(player_ptr, artifact_index, *y, *x)) a_info[artifact_index].cur_num = 1; } } @@ -4901,6 +4903,7 @@ void write_r_info_txt(void) /*! * @brief クエスト用固定ダンジョン生成時のメインルーチン * Helper function for "process_dungeon_file()" + * @param player_ptr プレーヤーへの参照ポインタ * @param name ファイル名 * @param ymin 詳細不明 * @param xmin 詳細不明 @@ -4908,7 +4911,7 @@ void write_r_info_txt(void) * @param xmax 詳細不明 * @return エラーコード */ -errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax) +errr process_dungeon_file(player_type *player_ptr, concptr name, int ymin, int xmin, int ymax, int xmax) { FILE *fp; char buf[1024]; @@ -4963,7 +4966,7 @@ errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax) if (bypass) continue; /* Process the line */ - err = process_dungeon_file_aux(p_ptr->current_floor_ptr, buf, ymin, xmin, ymax, xmax, &y, &x); + err = process_dungeon_file_aux(player_ptr, buf, ymin, xmin, ymax, xmax, &y, &x); if (err) break; } diff --git a/src/dungeon-file.h b/src/dungeon-file.h index 909afa1ed..ca7ccb8b1 100644 --- a/src/dungeon-file.h +++ b/src/dungeon-file.h @@ -40,7 +40,7 @@ struct dungeon_grid #define PARSE_ERROR_MAX 11 extern concptr err_str[PARSE_ERROR_MAX]; -extern errr process_dungeon_file(concptr name, int ymin, int xmin, int ymax, int xmax); +extern errr process_dungeon_file(player_type *player_ptr, concptr name, int ymin, int xmin, int ymax, int xmax); extern errr init_v_info(void); extern errr init_buildings(void); diff --git a/src/files.c b/src/files.c index 22808ba16..f0ddc98c9 100644 --- a/src/files.c +++ b/src/files.c @@ -3974,7 +3974,7 @@ void display_player(player_type *creature_ptr, int mode) /* Bewere that INIT_ASSIGN resets the cur_num. */ init_flags = INIT_NAME_ONLY; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); #ifdef JP sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[creature_ptr->current_floor_ptr->inside_quest].name, creature_ptr->died_from); @@ -4010,7 +4010,7 @@ void display_player(player_type *creature_ptr, int mode) /* Get the quest text */ init_flags = INIT_NAME_ONLY; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[creature_ptr->current_floor_ptr->inside_quest].name); } diff --git a/src/floor-generate.c b/src/floor-generate.c index 981998c2a..3b4989a57 100644 --- a/src/floor-generate.c +++ b/src/floor-generate.c @@ -1221,13 +1221,15 @@ static void generate_gambling_arena(floor_type *floor_ptr, player_type *creature /*! * @brief 固定マップクエストのフロア生成 / Generate a quest level + * @param player_ptr プレーヤーへの参照ポインタ * @return なし */ -static void generate_fixed_floor(floor_type *floor_ptr) +static void generate_fixed_floor(player_type *player_ptr) { POSITION x, y; /* Start with perm walls */ + floor_type *floor_ptr = player_ptr->current_floor_ptr; for (y = 0; y < floor_ptr->height; y++) { for (x = 0; x < floor_ptr->width; x++) @@ -1247,7 +1249,7 @@ static void generate_fixed_floor(floor_type *floor_ptr) init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file("q_info.txt", 0, 0, MAX_HGT, MAX_WID); + process_dungeon_file(player_ptr, "q_info.txt", 0, 0, MAX_HGT, MAX_WID); } /*! @@ -1448,15 +1450,15 @@ void generate_floor(player_type *player_ptr) else if (floor_ptr->inside_quest) { - generate_fixed_floor(floor_ptr); + generate_fixed_floor(player_ptr); } /* Build the town */ else if (!floor_ptr->dun_level) { /* Make the wilderness */ - if (player_ptr->wild_mode) wilderness_gen_small(player_ptr, floor_ptr); - else wilderness_gen(player_ptr, floor_ptr); + if (player_ptr->wild_mode) wilderness_gen_small(player_ptr); + else wilderness_gen(player_ptr); } /* Build a real level */ diff --git a/src/floor-save.c b/src/floor-save.c index 47f6db1d1..88fa00824 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -1272,7 +1272,7 @@ void change_floor(player_type *creature_ptr) if (a_info[o_ptr->name1].floor_id != new_floor_id) { /* Disappear from here */ - delete_object_idx(i); + delete_object_idx(creature_ptr->current_floor_ptr, i); } else { diff --git a/src/floor-streams.c b/src/floor-streams.c index faa4573ae..bb1ec1fcc 100644 --- a/src/floor-streams.c +++ b/src/floor-streams.c @@ -329,7 +329,7 @@ void build_streamer(floor_type *floor_ptr, FEAT_IDX feat, int chance) } } - delete_object(ty, tx); + delete_object(floor_ptr, ty, tx); } /* Clear previous contents, add proper vein type */ diff --git a/src/floor.c b/src/floor.c index 1f763c4b0..78c5fe27d 100644 --- a/src/floor.c +++ b/src/floor.c @@ -1632,7 +1632,7 @@ void place_object(floor_type *floor_ptr, POSITION y, POSITION x, BIT_FLAGS mode) /* Make an object (if possible) */ if (!make_object(q_ptr, mode)) return; - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); /* Success */ if (o_idx) @@ -1700,7 +1700,7 @@ void place_gold(floor_type *floor_ptr, POSITION y, POSITION x) /* Make some gold */ if (!make_gold(q_ptr)) return; - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); /* Success */ if (o_idx) @@ -1900,7 +1900,7 @@ void compact_objects(floor_type *floor_ptr, int size) /* Apply the saving throw */ if (randint0(100) < chance) continue; - delete_object_idx(i); + delete_object_idx(floor_ptr, i); /* Count it */ num++; diff --git a/src/init.c b/src/init.c index 73550b73a..f2e8b4c26 100644 --- a/src/init.c +++ b/src/init.c @@ -867,14 +867,12 @@ static errr init_m_info(void) /*! * @brief 基本情報読み込みのメインルーチン / * Initialize misc. values + * @param player_ptr プレーヤーへの参照ポインタ * @return エラーコード */ -static errr init_misc(void) +static errr init_misc(player_type *player_ptr) { - /* Initialize the values */ - process_dungeon_file("misc.txt", 0, 0, 0, 0); - - return 0; + return process_dungeon_file(player_ptr, "misc.txt", 0, 0, 0, 0); } @@ -1702,7 +1700,7 @@ static void init_angband_aux(concptr why) * if needed, in the first (?) pass through "TERM_XTRA_REACT". * */ -void init_angband(void) +void init_angband(player_type *player_ptr) { int fd = -1; @@ -1799,7 +1797,7 @@ void init_angband(void) /* Initialize misc. values */ note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]")); - if (init_misc()) quit(_("その他の変数を初期化できません", "Cannot initialize misc. values")); + if (init_misc(player_ptr)) quit(_("その他の変数を初期化できません", "Cannot initialize misc. values")); /* Initialize feature info */ #ifdef JP diff --git a/src/init.h b/src/init.h index 1bcbf0120..bdfe456dd 100644 --- a/src/init.h +++ b/src/init.h @@ -117,7 +117,6 @@ extern errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line); #ifdef ALLOW_TEMPLATES -extern errr parse_z_info(char *buf, header *head); extern errr parse_v_info(char *buf, header *head); extern errr parse_f_info(char *buf, header *head); extern void retouch_f_info(header *head); @@ -157,6 +156,6 @@ extern header g_head; extern s16b f_tag_to_index(concptr str); extern s16b f_tag_to_index_in_init(concptr str); -extern void init_angband(void); +extern void init_angband(player_type *player_ptr); extern concptr get_check_sum(void); extern void init_file_paths(char *path); diff --git a/src/load.c b/src/load.c index 9e6a369ad..faec6b0de 100644 --- a/src/load.c +++ b/src/load.c @@ -2865,7 +2865,7 @@ static errr rd_dungeon_old(floor_type *floor_ptr) /* Get a new record */ - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); if (i != o_idx) { @@ -3179,7 +3179,7 @@ static errr rd_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr) /* Get a new record */ - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); if (i != o_idx) return 152; @@ -3647,7 +3647,7 @@ static errr rd_savefile_new_aux(player_type *creature_ptr) init_flags = INIT_ASSIGN; creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)i; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); creature_ptr->current_floor_ptr->inside_quest = old_inside_quest; } } diff --git a/src/main-win.c b/src/main-win.c index 15e116c6d..e03e1998c 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -5755,7 +5755,7 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, signals_init(); Term_activate(term_screen); - init_angband(); + init_angband(p_ptr); /* We are now initialized */ initialized = TRUE; diff --git a/src/monster-process.c b/src/monster-process.c index 393b2e7b5..86b64e2b7 100644 --- a/src/monster-process.c +++ b/src/monster-process.c @@ -1411,7 +1411,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx) msg_print(_("地面に落とされた。", "You have fallen from riding pet.")); } - check_quest_completion(m_ptr); + check_quest_completion(target_ptr, m_ptr); delete_monster_idx(m_idx); return; } @@ -2304,7 +2304,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx) } /* Excise the object */ - excise_object_idx(this_o_idx); + excise_object_idx(target_ptr->current_floor_ptr, this_o_idx); /* Forget mark */ o_ptr->marked &= OM_TOUCHED; @@ -2333,7 +2333,7 @@ void process_monster(player_type *target_ptr, MONSTER_IDX m_idx) msg_format(_("%^sが%sを破壊した。", "%^s destroys %s."), m_name, o_name); } - delete_object_idx(this_o_idx); + delete_object_idx(target_ptr->current_floor_ptr, this_o_idx); } } } diff --git a/src/monster1.c b/src/monster1.c index c9b909eb9..340059660 100644 --- a/src/monster1.c +++ b/src/monster1.c @@ -2218,7 +2218,7 @@ void set_friendly(monster_type *m_ptr) */ void set_pet(monster_type *m_ptr) { - check_quest_completion(m_ptr); + check_quest_completion(p_ptr, m_ptr); m_ptr->smart |= SM_PET; if (!(r_info[m_ptr->r_idx].flags3 & (RF3_EVIL | RF3_GOOD))) @@ -2584,7 +2584,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) r_ptr = &r_info[m_ptr->r_idx]; } - check_quest_completion(m_ptr); + check_quest_completion(p_ptr, m_ptr); /* Handle the possibility of player vanquishing arena combatant -KMW- */ if (p_ptr->current_floor_ptr->inside_arena && !is_pet(m_ptr)) @@ -2607,7 +2607,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Prepare to make a prize */ object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval)); apply_magic(q_ptr, p_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++; @@ -2668,7 +2668,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) apply_magic(q_ptr, p_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART); q_ptr->pval = m_ptr->r_idx; - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } /* Drop objects being carried */ @@ -2713,7 +2713,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS)); apply_magic(q_ptr, p_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART | mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2731,7 +2731,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a book */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2805,7 +2805,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) a_ptr = &a_info[a_idx]; } while (a_ptr->cur_num); - if (create_named_art(a_idx, y, x)) + if (create_named_art(p_ptr, a_idx, y, x)) { a_ptr->cur_num = 1; @@ -2828,7 +2828,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Mega-Hack -- Actually create "Grond" */ apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); q_ptr = &forge; /* Mega-Hack -- Prepare to make "Chaos" */ @@ -2839,7 +2839,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Mega-Hack -- Actually create "Chaos" */ apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); break; case MON_B_DEATH_SWORD: @@ -2849,7 +2849,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Prepare to make a broken sword */ object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2))); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2864,7 +2864,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME)); apply_magic(q_ptr, p_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2891,7 +2891,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a cloak */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2906,7 +2906,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a poleweapon */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2921,7 +2921,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a hard armor */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2936,7 +2936,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a hafted weapon */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; @@ -2951,7 +2951,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) /* Make a sword */ make_object(q_ptr, mo_mode); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } break; } @@ -2977,7 +2977,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) if (!a_ptr->cur_num) { - if (create_named_art(a_idx, y, x)) + if (create_named_art(p_ptr, a_idx, y, x)) { a_ptr->cur_num = 1; @@ -3000,7 +3000,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) if (!a_ptr->cur_num) { - if (create_named_art(a_idx, y, x)) + if (create_named_art(p_ptr, a_idx, y, x)) { a_ptr->cur_num = 1; @@ -3022,7 +3022,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) object_prep(q_ptr, k_idx); apply_magic(q_ptr, p_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART | AM_GOOD); - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"), d_name + d_info[p_ptr->dungeon_idx].name); } @@ -3068,7 +3068,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) if (!make_object(q_ptr, mo_mode)) continue; dump_item++; } - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(p_ptr, q_ptr, -1, y, x); } /* Reset the object level */ @@ -3120,22 +3120,17 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) concptr extract_note_dies(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; - /* Some monsters get "destroyed" */ - if (!monster_living(r_idx)) - { - int i; + if (monster_living(r_idx)) return _("は死んだ。", " dies."); - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) + { + if (r_ptr->blow[i].method == RBM_EXPLODE) { - if (r_ptr->blow[i].method == RBM_EXPLODE) - { - return _("は爆発して粉々になった。", " explodes into tiny shreds."); - } + return _("は爆発して粉々になった。", " explodes into tiny shreds."); } - return _("を倒した。", " is destroyed."); } - return _("は死んだ。", " dies."); + return _("を倒した。", " is destroyed."); } /* diff --git a/src/monster2.c b/src/monster2.c index 1ca5e8ff0..4359ab57f 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -159,7 +159,7 @@ void delete_monster_idx(MONSTER_IDX i) * to prevent calling lite_spot() */ - delete_object_idx(this_o_idx); + delete_object_idx(p_ptr->current_floor_ptr, this_o_idx); } (void)WIPE(m_ptr, monster_type); @@ -4032,10 +4032,10 @@ void monster_drop_carried_objects(monster_type *m_ptr) /* Forget monster */ q_ptr->held_m_idx = 0; - delete_object_idx(this_o_idx); + delete_object_idx(p_ptr->current_floor_ptr, this_o_idx); /* Drop it */ - (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx); + (void)drop_near(p_ptr, q_ptr, -1, m_ptr->fy, m_ptr->fx); } /* Forget objects */ diff --git a/src/object.h b/src/object.h index dfca5d6e2..7f85698bd 100644 --- a/src/object.h +++ b/src/object.h @@ -274,7 +274,6 @@ struct object_type #define TV_ARMOR_END TV_DRAG_ARMOR OBJECT_TYPE_VALUE tval; /* Item type (from kind) */ - OBJECT_SUBTYPE_VALUE sval; /* Item sub-type (from kind) */ PARAMETER_VALUE pval; /* Item extra-parameter */ @@ -428,12 +427,17 @@ extern bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concpt extern int bow_tval_ammo(object_type *o_ptr); +/*! +* todo ここに置くとコンパイルは通る (このファイルの冒頭やobject2.cでincludeするとコンパイルエラー)、しかし圧倒的にダメなので要調整 +*/ +#include "floor.h" + /* object2.c */ -extern void excise_object_idx(OBJECT_IDX o_idx); -extern void delete_object_idx(OBJECT_IDX o_idx); -extern void delete_object(POSITION y, POSITION x); +extern void excise_object_idx(floor_type *floor_ptr, OBJECT_IDX o_idx); +extern void delete_object_idx(floor_type *floor_ptr, OBJECT_IDX o_idx); +extern void delete_object(floor_type *floor_ptr, POSITION y, POSITION x); -extern OBJECT_IDX o_pop(void); +extern OBJECT_IDX o_pop(floor_type *floor_ptr); extern OBJECT_IDX get_obj_num(DEPTH level, BIT_FLAGS mode); extern void object_known(object_type *o_ptr); extern void object_aware(object_type *o_ptr); @@ -484,7 +488,7 @@ extern OBJECT_SUBTYPE_VALUE coin_type; extern bool make_object(object_type *j_ptr, BIT_FLAGS mode); extern bool make_gold(object_type *j_ptr); -extern OBJECT_IDX drop_near(object_type *o_ptr, PERCENTAGE chance, POSITION y, POSITION x); +extern OBJECT_IDX drop_near(player_type *owner_type, object_type *o_ptr, PERCENTAGE chance, POSITION y, POSITION x); extern void vary_item(INVENTORY_IDX item, ITEM_NUMBER num); extern void inven_item_charges(INVENTORY_IDX item); extern void inven_item_describe(INVENTORY_IDX item); @@ -498,7 +502,7 @@ extern bool inven_carry_okay(object_type *o_ptr); extern bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr); extern s16b inven_carry(player_type *owner_ptr, object_type *o_ptr); extern INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt); -extern void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt); +extern void inven_drop(player_type *owner_type, INVENTORY_IDX item, ITEM_NUMBER amt); extern void combine_pack(player_type *owner_ptr); extern void reorder_pack(void); extern void display_koff(KIND_OBJECT_IDX k_idx); diff --git a/src/object2.c b/src/object2.c index b9fa942ad..e6e875860 100644 --- a/src/object2.c +++ b/src/object2.c @@ -88,7 +88,7 @@ OBJECT_SUBTYPE_VALUE coin_type; /* Hack -- force coin type */ * @param o_idx 削除対象のオブジェクト構造体ポインタ * @return なし */ -void excise_object_idx(OBJECT_IDX o_idx) +void excise_object_idx(floor_type *floor_ptr, OBJECT_IDX o_idx) { object_type *j_ptr; @@ -96,18 +96,18 @@ void excise_object_idx(OBJECT_IDX o_idx) OBJECT_IDX prev_o_idx = 0; /* Object */ - j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; + j_ptr = &floor_ptr->o_list[o_idx]; if (OBJECT_IS_HELD_MONSTER(j_ptr)) { monster_type *m_ptr; - m_ptr = &p_ptr->current_floor_ptr->m_list[j_ptr->held_m_idx]; + m_ptr = &floor_ptr->m_list[j_ptr->held_m_idx]; /* Scan all objects in the grid */ for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; + o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; if (this_o_idx == o_idx) @@ -125,7 +125,7 @@ void excise_object_idx(OBJECT_IDX o_idx) object_type *k_ptr; /* Previous object */ - k_ptr = &p_ptr->current_floor_ptr->o_list[prev_o_idx]; + k_ptr = &floor_ptr->o_list[prev_o_idx]; /* Remove from list */ k_ptr->next_o_idx = next_o_idx; @@ -150,13 +150,13 @@ void excise_object_idx(OBJECT_IDX o_idx) POSITION y = j_ptr->iy; POSITION x = j_ptr->ix; - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Scan all objects in the grid */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; + o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; if (this_o_idx == o_idx) @@ -174,7 +174,7 @@ void excise_object_idx(OBJECT_IDX o_idx) object_type *k_ptr; /* Previous object */ - k_ptr = &p_ptr->current_floor_ptr->o_list[prev_o_idx]; + k_ptr = &floor_ptr->o_list[prev_o_idx]; /* Remove from list */ k_ptr->next_o_idx = next_o_idx; @@ -202,15 +202,15 @@ void excise_object_idx(OBJECT_IDX o_idx) * @details * Handle "stacks" of objects correctly. */ -void delete_object_idx(OBJECT_IDX o_idx) +void delete_object_idx(floor_type *floor_ptr, OBJECT_IDX o_idx) { object_type *j_ptr; /* Excise */ - excise_object_idx(o_idx); + excise_object_idx(floor_ptr, o_idx); /* Object */ - j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; + j_ptr = &floor_ptr->o_list[o_idx]; /* Dungeon floor */ if (!OBJECT_IS_HELD_MONSTER(j_ptr)) @@ -222,8 +222,7 @@ void delete_object_idx(OBJECT_IDX o_idx) } object_wipe(j_ptr); - /* Count objects */ - p_ptr->current_floor_ptr->o_cnt--; + floor_ptr->o_cnt--; } @@ -235,31 +234,27 @@ void delete_object_idx(OBJECT_IDX o_idx) * @param x 削除したフロアマスのX座標 * @return なし */ -void delete_object(POSITION y, POSITION x) +void delete_object(floor_type *floor_ptr, POSITION y, POSITION x) { grid_type *g_ptr; OBJECT_IDX this_o_idx, next_o_idx = 0; /* Refuse "illegal" locations */ - if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return; + if (!in_bounds(floor_ptr, y, x)) return; - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Scan all objects in the grid */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; + o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; object_wipe(o_ptr); - - /* Count objects */ - p_ptr->current_floor_ptr->o_cnt--; + floor_ptr->o_cnt--; } - /* Objects are gone */ g_ptr->o_idx = 0; - lite_spot(y, x); } @@ -273,48 +268,43 @@ void delete_object(POSITION y, POSITION x) * This routine should almost never fail, but in case it does, * we must be sure to handle "failure" of this routine. */ -OBJECT_IDX o_pop(void) +OBJECT_IDX o_pop(floor_type *floor_ptr) { OBJECT_IDX i; /* Initial allocation */ - if (p_ptr->current_floor_ptr->o_max < current_world_ptr->max_o_idx) + if (floor_ptr->o_max < current_world_ptr->max_o_idx) { /* Get next space */ - i = p_ptr->current_floor_ptr->o_max; + i = floor_ptr->o_max; /* Expand object array */ - p_ptr->current_floor_ptr->o_max++; - - /* Count objects */ - p_ptr->current_floor_ptr->o_cnt++; + floor_ptr->o_max++; + floor_ptr->o_cnt++; /* Use this object */ - return (i); + return i; } /* Recycle dead objects */ - for (i = 1; i < p_ptr->current_floor_ptr->o_max; i++) + for (i = 1; i < floor_ptr->o_max; i++) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[i]; + o_ptr = &floor_ptr->o_list[i]; /* Skip live objects */ if (o_ptr->k_idx) continue; - - /* Count objects */ - p_ptr->current_floor_ptr->o_cnt++; + floor_ptr->o_cnt++; /* Use this object */ - return (i); + return i; } - /* Warn the player (except during dungeon creation) */ if (current_world_ptr->character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!")); - return (0); + return 0; } @@ -349,8 +339,7 @@ static errr get_obj_num_prep(void) } } - /* Success */ - return (0); + return 0; } @@ -4193,7 +4182,7 @@ bool make_gold(object_type *j_ptr) /*! * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。 * Let an object fall to the ground at or near a location. - * @param floo_ptr 現在フロアへの参照ポインタ + * @param owner_ptr プレーヤーへの参照ポインタ * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ * @param chance ドロップの消滅率(%) * @param y 配置したいフロアのY座標 @@ -4213,7 +4202,7 @@ bool make_gold(object_type *j_ptr) * the object can combine, stack, or be placed. Artifacts will try very\n * hard to be placed, including "teleporting" to a useful grid if needed.\n */ -OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION x) +OBJECT_IDX drop_near(player_type *owner_type, object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION x) { int i, k, d, s; @@ -4265,7 +4254,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /* Default */ by = y; bx = x; - + floor_type *floor_ptr = owner_type->current_floor_ptr; /* Scan local grids */ for (dy = -3; dy <= 3; dy++) { @@ -4283,16 +4272,16 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION ty = y + dy; tx = x + dx; - if (!in_bounds(p_ptr->current_floor_ptr, ty, tx)) continue; + if (!in_bounds(floor_ptr, ty, tx)) continue; /* Require line of projection */ - if (!projectable(p_ptr->current_floor_ptr, y, x, ty, tx)) continue; + if (!projectable(floor_ptr, y, x, ty, tx)) continue; /* Obtain grid */ - g_ptr = &p_ptr->current_floor_ptr->grid_array[ty][tx]; + g_ptr = &floor_ptr->grid_array[ty][tx]; /* Require floor space */ - if (!cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) continue; + if (!cave_drop_bold(floor_ptr, ty, tx)) continue; /* No objects */ k = 0; @@ -4301,7 +4290,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; + o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Check for possible combination */ @@ -4338,7 +4327,6 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION } } - /* Handle lack of space */ if (!flag && !object_is_artifact(j_ptr)) { @@ -4362,14 +4350,14 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION ty = rand_spread(by, 1); tx = rand_spread(bx, 1); - if (!in_bounds(p_ptr->current_floor_ptr, ty, tx)) continue; + if (!in_bounds(floor_ptr, ty, tx)) continue; /* Bounce to that location */ by = ty; bx = tx; /* Require floor space */ - if (!cave_drop_bold(p_ptr->current_floor_ptr, by, bx)) continue; + if (!cave_drop_bold(floor_ptr, by, bx)) continue; flag = TRUE; } @@ -4379,12 +4367,12 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION { int candidates = 0, pick; - for (ty = 1; ty < p_ptr->current_floor_ptr->height - 1; ty++) + for (ty = 1; ty < floor_ptr->height - 1; ty++) { - for (tx = 1; tx < p_ptr->current_floor_ptr->width - 1; tx++) + for (tx = 1; tx < floor_ptr->width - 1; tx++) { /* A valid space found */ - if (cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) candidates++; + if (cave_drop_bold(floor_ptr, ty, tx)) candidates++; } } @@ -4417,11 +4405,11 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /* Choose a random one */ pick = randint1(candidates); - for (ty = 1; ty < p_ptr->current_floor_ptr->height - 1; ty++) + for (ty = 1; ty < floor_ptr->height - 1; ty++) { - for (tx = 1; tx < p_ptr->current_floor_ptr->width - 1; tx++) + for (tx = 1; tx < floor_ptr->width - 1; tx++) { - if (cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) + if (cave_drop_bold(floor_ptr, ty, tx)) { pick--; @@ -4438,13 +4426,13 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION } - g_ptr = &p_ptr->current_floor_ptr->grid_array[by][bx]; + g_ptr = &floor_ptr->grid_array[by][bx]; /* Scan objects in that grid for combination */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; + o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Check for combination */ @@ -4459,9 +4447,8 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION } } - if (!done) o_idx = o_pop(); + if (!done) o_idx = o_pop(floor_ptr); - /* Failure */ if (!done && !o_idx) { #ifdef JP @@ -4478,18 +4465,17 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION a_info[j_ptr->name1].cur_num = 0; } - /* Failure */ - return (0); + return 0; } /* Stack */ if (!done) { /* Structure copy */ - object_copy(&p_ptr->current_floor_ptr->o_list[o_idx], j_ptr); + object_copy(&floor_ptr->o_list[o_idx], j_ptr); /* Access new object */ - j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; + j_ptr = &floor_ptr->o_list[o_idx]; /* Locate */ j_ptr->iy = by; @@ -4513,12 +4499,12 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /* Mega-Hack -- no message if "dropped" by player */ /* Message when an object falls under the player */ - if (chance && player_bold(p_ptr, by, bx)) + if (chance && player_bold(owner_type, by, bx)) { msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet.")); } - return (o_idx); + return o_idx; } @@ -4839,7 +4825,7 @@ void floor_item_optimize(INVENTORY_IDX item) /* Only optimize empty items */ if (o_ptr->number) return; - delete_object_idx(item); + delete_object_idx(p_ptr->current_floor_ptr, item); } @@ -5177,7 +5163,7 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt) * @details * The object will be dropped "near" the current location */ -void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) +void inven_drop(player_type *owner_ptr, INVENTORY_IDX item, ITEM_NUMBER amt) { object_type forge; object_type *q_ptr; @@ -5186,7 +5172,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) GAME_TEXT o_name[MAX_NLEN]; /* Access original object */ - o_ptr = &p_ptr->inventory_list[item]; + o_ptr = &owner_ptr->inventory_list[item]; /* Error check */ if (amt <= 0) return; @@ -5201,7 +5187,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) item = inven_takeoff(item, amt); /* Access original object */ - o_ptr = &p_ptr->inventory_list[item]; + o_ptr = &owner_ptr->inventory_list[item]; } q_ptr = &forge; @@ -5221,7 +5207,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item)); /* Drop it near the player */ - (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x); + (void)drop_near(owner_ptr, q_ptr, 0, owner_ptr->y, owner_ptr->x); vary_item(item, -amt); } diff --git a/src/patron.c b/src/patron.c index 400c42f16..6719ee14c 100644 --- a/src/patron.c +++ b/src/patron.c @@ -334,7 +334,7 @@ void gain_level_reward(player_type *creature_ptr, int chosen_reward) msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[creature_ptr->chaos_patron]); msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'")); - acquirement(creature_ptr->y, creature_ptr->x, 1, FALSE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, 1, FALSE, FALSE, FALSE); reward = _("上質なアイテムを手に入れた。", "a good item"); break; @@ -343,7 +343,7 @@ void gain_level_reward(player_type *creature_ptr, int chosen_reward) msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[creature_ptr->chaos_patron]); msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'")); - acquirement(creature_ptr->y, creature_ptr->x, 1, TRUE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, 1, TRUE, FALSE, FALSE); reward = _("高級品のアイテムを手に入れた。", "an excellent item"); break; @@ -359,7 +359,7 @@ void gain_level_reward(player_type *creature_ptr, int chosen_reward) msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[creature_ptr->chaos_patron]); msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'")); - acquirement(creature_ptr->y, creature_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE); reward = _("上質なアイテムを手に入れた。", "good items"); break; @@ -368,7 +368,7 @@ void gain_level_reward(player_type *creature_ptr, int chosen_reward) msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[creature_ptr->chaos_patron]); msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'")); - acquirement(creature_ptr->y, creature_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE); reward = _("高級品のアイテムを手に入れた。", "excellent items"); break; diff --git a/src/player-inventory.c b/src/player-inventory.c index 00735d5b7..841cd9c05 100644 --- a/src/player-inventory.c +++ b/src/player-inventory.c @@ -2525,7 +2525,7 @@ bool get_item_floor(player_type *creature_ptr, COMMAND_CODE *cp, concptr pmt, co if (!(o_idx && creature_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) break; /* Remove the first object from the list. */ - excise_object_idx(o_idx); + excise_object_idx(creature_ptr->current_floor_ptr, o_idx); /* Find end of the list. */ i = g_ptr->o_idx; @@ -3017,7 +3017,7 @@ void py_pickup_floor(player_type *creature_ptr, bool pickup) creature_ptr->window |= (PW_PLAYER); /* Delete the gold */ - delete_object_idx(this_o_idx); + delete_object_idx(creature_ptr->current_floor_ptr, this_o_idx); /* Check the next object */ continue; diff --git a/src/player-move.c b/src/player-move.c index 25e5cf07e..ed8f22f0d 100644 --- a/src/player-move.c +++ b/src/player-move.c @@ -295,7 +295,7 @@ void py_pickup_aux(player_type *owner_ptr, OBJECT_IDX o_idx) /* Get the object again */ o_ptr = &owner_ptr->inventory_list[slot]; - delete_object_idx(o_idx); + delete_object_idx(owner_ptr->current_floor_ptr, o_idx); if (owner_ptr->pseikaku == SEIKAKU_MUNCHKIN) { @@ -407,7 +407,7 @@ void carry(player_type *creature_ptr, bool pickup) int value = (long)o_ptr->pval; /* Delete the gold */ - delete_object_idx(this_o_idx); + delete_object_idx(creature_ptr->current_floor_ptr, this_o_idx); msg_format(_(" $%ld の価値がある%sを見つけた。", "You collect %ld gold pieces worth of %s."), (long)value, o_name); diff --git a/src/player-status.c b/src/player-status.c index a073e5584..e5bf50941 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -4986,11 +4986,11 @@ void update_creature(player_type *creature_ptr) { if (!creature_ptr->update) return; - /* Actually do auto-destroy */ + floor_type *floor_ptr = creature_ptr->current_floor_ptr; if (creature_ptr->update & (PU_AUTODESTROY)) { creature_ptr->update &= ~(PU_AUTODESTROY); - autopick_delayed_alter(); + autopick_delayed_alter(floor_ptr); } if (creature_ptr->update & (PU_COMBINE)) { @@ -5045,28 +5045,27 @@ void update_creature(player_type *creature_ptr) if (creature_ptr->update & (PU_UN_LITE)) { creature_ptr->update &= ~(PU_UN_LITE); - forget_lite(p_ptr->current_floor_ptr); + forget_lite(floor_ptr); } if (creature_ptr->update & (PU_UN_VIEW)) { creature_ptr->update &= ~(PU_UN_VIEW); - forget_view(creature_ptr->current_floor_ptr); + forget_view(floor_ptr); } if (creature_ptr->update & (PU_VIEW)) { creature_ptr->update &= ~(PU_VIEW); - update_view(creature_ptr, p_ptr->current_floor_ptr); + update_view(creature_ptr, floor_ptr); } if (creature_ptr->update & (PU_LITE)) { creature_ptr->update &= ~(PU_LITE); - update_lite(creature_ptr, p_ptr->current_floor_ptr); + update_lite(creature_ptr, floor_ptr); } - if (creature_ptr->update & (PU_FLOW)) { creature_ptr->update &= ~(PU_FLOW); @@ -5086,7 +5085,7 @@ void update_creature(player_type *creature_ptr) if (creature_ptr->update & (PU_MON_LITE)) { creature_ptr->update &= ~(PU_MON_LITE); - update_mon_lite(p_ptr, p_ptr->current_floor_ptr); + update_mon_lite(creature_ptr, floor_ptr); } /* @@ -5096,7 +5095,7 @@ void update_creature(player_type *creature_ptr) if (creature_ptr->update & (PU_DELAY_VIS)) { creature_ptr->update &= ~(PU_DELAY_VIS); - delayed_visual_update(creature_ptr->current_floor_ptr); + delayed_visual_update(floor_ptr); } if (creature_ptr->update & (PU_MONSTERS)) @@ -5106,6 +5105,7 @@ void update_creature(player_type *creature_ptr) } } + /*! * @brief プレイヤーが魔道書を一冊も持っていないかを判定する * @return 魔道書を一冊も持っていないならTRUEを返す diff --git a/src/quest.c b/src/quest.c index d98ade2d5..8c558195d 100644 --- a/src/quest.c +++ b/src/quest.c @@ -113,13 +113,13 @@ void complete_quest(QUEST_IDX quest_num) /*! * @brief 特定の敵を倒した際にクエスト達成処理 / * Check for "Quest" completion when a quest monster is killed or charmed. + * @param player_ptr プレーヤーへの参照ポインタ * @param m_ptr 撃破したモンスターの構造体参照ポインタ * @return なし */ -void check_quest_completion(monster_type *m_ptr) +void check_quest_completion(player_type *player_ptr, monster_type *m_ptr) { POSITION y, x; - QUEST_IDX quest_num; bool create_stairs = FALSE; bool reward = FALSE; @@ -130,8 +130,8 @@ void check_quest_completion(monster_type *m_ptr) y = m_ptr->fy; x = m_ptr->fx; - /* Inside a quest */ - quest_num = p_ptr->current_floor_ptr->inside_quest; + floor_type *floor_ptr = player_ptr->current_floor_ptr; + QUEST_IDX quest_num = floor_ptr->inside_quest; /* Search for an active quest on this dungeon level */ if (!quest_num) @@ -151,7 +151,7 @@ void check_quest_completion(monster_type *m_ptr) continue; /* Quest is not on this level */ - if ((q_ptr->level != p_ptr->current_floor_ptr->dun_level) && + if ((q_ptr->level != floor_ptr->dun_level) && (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL)) continue; @@ -201,7 +201,7 @@ void check_quest_completion(monster_type *m_ptr) { if (!is_hostile(m_ptr)) break; - if (count_all_hostile_monsters(p_ptr->current_floor_ptr) == 1) + if (count_all_hostile_monsters(floor_ptr) == 1) { if (q_ptr->flags & QUEST_FLAG_SILENT) { @@ -230,7 +230,7 @@ void check_quest_completion(monster_type *m_ptr) if (!(q_ptr->flags & QUEST_FLAG_PRESET)) { create_stairs = TRUE; - p_ptr->current_floor_ptr->inside_quest = 0; + floor_ptr->inside_quest = 0; } /* Finish the two main quests without rewarding */ @@ -261,7 +261,7 @@ void check_quest_completion(monster_type *m_ptr) { if (!is_hostile(m_ptr)) break; - if (count_all_hostile_monsters(p_ptr->current_floor_ptr) == 1) + if (count_all_hostile_monsters(floor_ptr) == 1) { q_ptr->status = QUEST_STATUS_STAGE_COMPLETED; @@ -284,10 +284,10 @@ void check_quest_completion(monster_type *m_ptr) POSITION ny, nx; /* Stagger around */ - while (cave_perma_bold(p_ptr->current_floor_ptr, y, x) || p_ptr->current_floor_ptr->grid_array[y][x].o_idx || (p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_OBJECT)) + while (cave_perma_bold(floor_ptr, y, x) || floor_ptr->grid_array[y][x].o_idx || (floor_ptr->grid_array[y][x].info & CAVE_OBJECT)) { /* Pick a location */ - scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, 1, 0); + scatter(floor_ptr, &ny, &nx, y, x, 1, 0); /* Stagger */ y = ny; x = nx; @@ -297,10 +297,10 @@ void check_quest_completion(monster_type *m_ptr) msg_print(_("魔法の階段が現れた...", "A magical staircase appears...")); /* Create stairs down */ - cave_set_feat(p_ptr->current_floor_ptr, y, x, feat_down_stair); + cave_set_feat(floor_ptr, y, x, feat_down_stair); /* Remember to update everything */ - p_ptr->update |= (PU_FLOW); + player_ptr->update |= (PU_FLOW); } /* @@ -310,14 +310,14 @@ void check_quest_completion(monster_type *m_ptr) { int i; - for (i = 0; i < (p_ptr->current_floor_ptr->dun_level / 15) + 1; i++) + for (i = 0; i < (floor_ptr->dun_level / 15) + 1; i++) { o_ptr = &forge; object_wipe(o_ptr); /* Make a great object */ make_object(o_ptr, AM_GOOD | AM_GREAT); - (void)drop_near(o_ptr, -1, y, x); + (void)drop_near(player_ptr, o_ptr, -1, y, x); } } } diff --git a/src/quest.h b/src/quest.h index f95117256..7390caaad 100644 --- a/src/quest.h +++ b/src/quest.h @@ -87,7 +87,7 @@ extern int leaving_quest; extern void determine_random_questor(quest_type *q_ptr); extern void complete_quest(QUEST_IDX quest_num); -extern void check_quest_completion(monster_type *m_ptr); +extern void check_quest_completion(player_type *player_ptr, monster_type *m_ptr); extern void check_find_art_quest_completion(object_type *o_ptr); extern void quest_discovery(QUEST_IDX q_idx); extern QUEST_IDX quest_number(DEPTH level); diff --git a/src/realm-nature.c b/src/realm-nature.c index 03a100c8c..47a393bf7 100644 --- a/src/realm-nature.c +++ b/src/realm-nature.c @@ -104,7 +104,7 @@ concptr do_nature_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION)); /* Drop the object from heaven */ - (void)drop_near(q_ptr, -1, caster_ptr->y, caster_ptr->x); + (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x); } } break; diff --git a/src/spells-floor.c b/src/spells-floor.c index 81bd19d8a..437a97b12 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -268,8 +268,8 @@ void stair_creation(player_type *caster_ptr) /* No effect out of standard dungeon floor */ if (!floor_ptr->dun_level || (!up && !down) || - (caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) || - caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) + (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || + floor_ptr->inside_arena || caster_ptr->phase_out) { /* arena or quest */ msg_print(_("効果がありません!", "There is no effect!")); @@ -277,14 +277,14 @@ void stair_creation(player_type *caster_ptr) } /* Artifacts resists */ - if (!cave_valid_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x)) + if (!cave_valid_bold(floor_ptr, caster_ptr->y, caster_ptr->x)) { msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell.")); return; } /* Destroy all objects in the grid */ - delete_object(caster_ptr->y, caster_ptr->x); + delete_object(floor_ptr, caster_ptr->y, caster_ptr->x); /* Extract current floor data */ saved_floor_type *sf_ptr; @@ -355,13 +355,13 @@ void stair_creation(player_type *caster_ptr) /* Create a staircase */ if (up) { - cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, + cave_set_feat(floor_ptr, caster_ptr->y, caster_ptr->x, (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= floor_ptr->dun_level - 2)) ? feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair); } else { - cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, + cave_set_feat(floor_ptr, caster_ptr->y, caster_ptr->x, (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= floor_ptr->dun_level + 2)) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair); } @@ -564,7 +564,7 @@ bool destroy_area(player_type *caster_ptr, POSITION y1, POSITION x1, POSITION r, } } - delete_object(y, x); + delete_object(floor_ptr, y, x); /* Destroy "non-permanent" grids */ if (cave_perma_grid(g_ptr)) continue; @@ -728,7 +728,8 @@ bool destroy_area(player_type *caster_ptr, POSITION y1, POSITION x1, POSITION r, bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx) { /* Prevent destruction of quest levels and town */ - if ((caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) || !caster_ptr->current_floor_ptr->dun_level) + floor_type *floor_ptr = caster_ptr->current_floor_ptr; + if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level) { return FALSE; } @@ -758,12 +759,12 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M yy = cy + dy; xx = cx + dx; - if (!in_bounds(caster_ptr->current_floor_ptr, yy, xx)) continue; + if (!in_bounds(floor_ptr, yy, xx)) continue; /* Skip distant grids */ if (distance(cy, cx, yy, xx) > r) continue; grid_type *g_ptr; - g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx]; + g_ptr = &floor_ptr->grid_array[yy][xx]; /* Lose room and vault / Lose light and knowledge */ g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE); @@ -795,12 +796,12 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M x = caster_ptr->x + ddx_ddd[i]; /* Skip non-empty grids */ - if (!cave_empty_bold(caster_ptr->current_floor_ptr, y, x)) continue; + if (!cave_empty_bold(floor_ptr, y, x)) continue; /* Important -- Skip "quake" grids */ if (map[16 + y - cy][16 + x - cx]) continue; - if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) continue; + if (floor_ptr->grid_array[y][x].m_idx) continue; /* Count "safe" grids */ sn++; @@ -817,17 +818,17 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M { case 1: { - msg_print(_("ダンジョンの壁が崩れた!", "The caster_ptr->current_floor_ptr->grid_array ceiling collapses!")); + msg_print(_("ダンジョンの壁が崩れた!", "The dungeon's ceiling collapses!")); break; } case 2: { - msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The caster_ptr->current_floor_ptr->grid_array floor twists in an unnatural way!")); + msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The dungeon's floor twists in an unnatural way!")); break; } default: { - msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The caster_ptr->current_floor_ptr->grid_array quakes! You are pummeled with debris!")); + msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The dungeon quakes! You are pummeled with debris!")); break; } } @@ -882,7 +883,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M if (m_idx) { GAME_TEXT m_name[MAX_NLEN]; - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx]; + monster_type *m_ptr = &floor_ptr->m_list[m_idx]; monster_desc(m_name, m_ptr, MD_WRONGDOER_NAME); killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name); } @@ -907,14 +908,14 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M if (!map[16 + yy - cy][16 + xx - cx]) continue; grid_type *g_ptr; - g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx]; + g_ptr = &floor_ptr->grid_array[yy][xx]; if (g_ptr->m_idx == caster_ptr->riding) continue; /* Process monsters */ if (!g_ptr->m_idx) continue; - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]; + monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; /* Quest monsters */ @@ -944,11 +945,11 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M x = xx + ddx_ddd[i]; /* Skip non-empty grids */ - if (!cave_empty_bold(caster_ptr->current_floor_ptr, y, x)) continue; + if (!cave_empty_bold(floor_ptr, y, x)) continue; /* Hack -- no safety on glyph of warding */ - if (is_glyph_grid(&caster_ptr->current_floor_ptr->grid_array[y][x])) continue; - if (is_explosive_rune_grid(&caster_ptr->current_floor_ptr->grid_array[y][x])) continue; + if (is_glyph_grid(&floor_ptr->grid_array[y][x])) continue; + if (is_explosive_rune_grid(&floor_ptr->grid_array[y][x])) continue; /* ... nor on the Pattern */ if (pattern_tile(y, x)) continue; @@ -956,7 +957,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M /* Important -- Skip "quake" grids */ if (map[16 + y - cy][16 + x - cx]) continue; - if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) continue; + if (floor_ptr->grid_array[y][x].m_idx) continue; if (player_bold(caster_ptr, y, x)) continue; /* Count "safe" grids */ @@ -992,7 +993,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M if (g_ptr->m_idx) { - if (record_named_pet && is_pet(&caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]) && caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx].nickname) + if (record_named_pet && is_pet(&floor_ptr->m_list[g_ptr->m_idx]) && floor_ptr->m_list[g_ptr->m_idx].nickname) { char m2_name[MAX_NLEN]; @@ -1001,7 +1002,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M } } - delete_monster(caster_ptr->current_floor_ptr, yy, xx); + delete_monster(floor_ptr, yy, xx); sn = 0; } @@ -1009,13 +1010,13 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M /* Hack -- Escape from the rock */ if (sn == 0) continue; - IDX m_idx_aux = caster_ptr->current_floor_ptr->grid_array[yy][xx].m_idx; + IDX m_idx_aux = floor_ptr->grid_array[yy][xx].m_idx; /* Update the old location */ - caster_ptr->current_floor_ptr->grid_array[yy][xx].m_idx = 0; + floor_ptr->grid_array[yy][xx].m_idx = 0; /* Update the new location */ - caster_ptr->current_floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux; + floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux; /* Move the monster */ m_ptr->fy = sy; @@ -1028,7 +1029,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M } /* Lose monster light */ - clear_mon_lite(caster_ptr->current_floor_ptr); + clear_mon_lite(floor_ptr); /* Examine the quaked region */ for (dy = -r; dy <= r; dy++) @@ -1042,39 +1043,39 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M if (!map[16 + yy - cy][16 + xx - cx]) continue; grid_type *g_ptr; - g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx]; + g_ptr = &floor_ptr->grid_array[yy][xx]; /* Destroy location (if valid) */ - if (!cave_valid_bold(caster_ptr->current_floor_ptr, yy, xx)) continue; + if (!cave_valid_bold(floor_ptr, yy, xx)) continue; - delete_object(yy, xx); + delete_object(floor_ptr, yy, xx); /* Wall (or floor) type */ - int t = cave_have_flag_bold(caster_ptr->current_floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200; + int t = cave_have_flag_bold(floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200; /* Create granite wall */ if (t < 20) { - cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_granite); + cave_set_feat(floor_ptr, yy, xx, feat_granite); continue; } /* Create quartz vein */ if (t < 70) { - cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_quartz_vein); + cave_set_feat(floor_ptr, yy, xx, feat_quartz_vein); continue; } /* Create magma vein */ if (t < 100) { - cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_magma_vein); + cave_set_feat(floor_ptr, yy, xx, feat_magma_vein); continue; } /* Create floor */ - cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_ground_type[randint0(100)]); + cave_set_feat(floor_ptr, yy, xx, feat_ground_type[randint0(100)]); } } @@ -1086,12 +1087,12 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M yy = cy + dy; xx = cx + dx; - if (!in_bounds(caster_ptr->current_floor_ptr, yy, xx)) continue; + if (!in_bounds(floor_ptr, yy, xx)) continue; /* Skip distant grids */ if (distance(cy, cx, yy, xx) > r) continue; grid_type *g_ptr; - g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx]; + g_ptr = &floor_ptr->grid_array[yy][xx]; if (is_mirror_grid(g_ptr)) { @@ -1109,8 +1110,8 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M { yyy = yy + ddy_ddd[ii]; xxx = xx + ddx_ddd[ii]; - if (!in_bounds2(caster_ptr->current_floor_ptr, yyy, xxx)) continue; - cc_ptr = &caster_ptr->current_floor_ptr->grid_array[yyy][xxx]; + if (!in_bounds2(floor_ptr, yyy, xxx)) continue; + cc_ptr = &floor_ptr->grid_array[yyy][xxx]; if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW)) { g_ptr->info |= CAVE_GLOW; @@ -1127,7 +1128,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M if (caster_ptr->special_defense & NINJA_S_STEALTH) { - if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE); + if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE); } /* Success */ diff --git a/src/spells-object.c b/src/spells-object.c index aa1fa7ae9..fd5c7c970 100644 --- a/src/spells-object.c +++ b/src/spells-object.c @@ -331,13 +331,14 @@ bool import_magic_device(player_type *user_ptr) /*! * @brief 誰得ドロップを行う。 + * @param creature_ptr プレーヤーへの参照ポインタ * @param y1 配置したいフロアのY座標 * @param x1 配置したいフロアのX座標 * @param num 誰得の処理回数 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる * @return なし */ -void amusement(POSITION y1, POSITION x1, int num, bool known) +void amusement(player_type *creature_ptr, POSITION y1, POSITION x1, int num, bool known) { int t = 0; for (int n = 0; amuse_info[n].tval != 0; n++) @@ -408,7 +409,7 @@ void amusement(POSITION y1, POSITION x1, int num, bool known) /* Paranoia - reroll if nothing */ if (!(i_ptr->k_idx)) continue; - (void)drop_near(i_ptr, -1, y1, x1); + (void)drop_near(creature_ptr, i_ptr, -1, y1, x1); num--; } @@ -418,6 +419,7 @@ void amusement(POSITION y1, POSITION x1, int num, bool known) /*! * @brief 獲得ドロップを行う。 * Scatter some "great" objects near the player + * @param caster_ptr プレーヤーへの参照ポインタ * @param y1 配置したいフロアのY座標 * @param x1 配置したいフロアのX座標 * @param num 獲得の処理回数 @@ -426,7 +428,7 @@ void amusement(POSITION y1, POSITION x1, int num, bool known) * @param known TRUEならばオブジェクトが必ず*鑑定*済になる * @return なし */ -void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known) +void acquirement(player_type *caster_ptr, POSITION y1, POSITION x1, int num, bool great, bool special, bool known) { object_type *i_ptr; object_type object_type_body; @@ -447,7 +449,7 @@ void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bo object_known(i_ptr); } - (void)drop_near(i_ptr, -1, y1, x1); + (void)drop_near(caster_ptr, i_ptr, -1, y1, x1); } } @@ -550,7 +552,7 @@ void acquire_chaos_weapon(player_type *creature_ptr) q_ptr->to_d = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10; one_resistance(q_ptr); q_ptr->name2 = EGO_CHAOTIC; - (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x); + (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x); } diff --git a/src/spells-object.h b/src/spells-object.h index 8a195011d..972697ff6 100644 --- a/src/spells-object.h +++ b/src/spells-object.h @@ -2,8 +2,8 @@ extern bool create_ammo(player_type *creature_ptr); extern bool import_magic_device(player_type *creature_ptr); -extern void amusement(POSITION y1, POSITION x1, int num, bool known); -extern void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known); +extern void amusement(player_type *creature_ptr, POSITION y1, POSITION x1, int num, bool known); +extern void acquirement(player_type *caster_ptr, POSITION y1, POSITION x1, int num, bool great, bool special, bool known); extern void acquire_chaos_weapon(player_type *creature_ptr); extern bool curse_armor(player_type *owner_ptr); extern bool curse_weapon_object(player_type *creature_ptr, bool force, object_type *o_ptr); diff --git a/src/spells-status.c b/src/spells-status.c index 159e7a464..e1ab47122 100644 --- a/src/spells-status.c +++ b/src/spells-status.c @@ -474,7 +474,7 @@ bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr) object_copy(&forge, o_ptr); inven_item_increase(inv, (0 - o_ptr->number)); inven_item_optimize(inv); - OBJECT_IDX o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x); + OBJECT_IDX o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x); o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx]; GAME_TEXT o_name[MAX_NLEN]; diff --git a/src/spells1.c b/src/spells1.c index dd0ec9ff1..9855bf73a 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -1052,7 +1052,7 @@ static bool project_o(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSI k_idx = o_ptr->k_idx; is_potion = object_is_potion(o_ptr); - delete_object_idx(this_o_idx); + delete_object_idx(caster_ptr->current_floor_ptr, this_o_idx); /* Potions produce effects when 'shattered' */ if (is_potion) @@ -1066,7 +1066,7 @@ static bool project_o(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSI } /* Return "Anything seen?" */ - return (obvious); + return obvious; } @@ -3959,7 +3959,7 @@ static bool project_m(player_type *caster_ptr, floor_type *floor_ptr, MONSTER_ID /* Mark the item as fully known */ q_ptr->ident |= (IDENT_MENTAL); - (void)drop_near(q_ptr, -1, caster_ptr->y, caster_ptr->x); + (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x); } /* Track it */ diff --git a/src/spells2.c b/src/spells2.c index 77f354ffb..0c5b2686c 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -3041,7 +3041,7 @@ bool kawarimi(player_type *caster_ptr, bool success) object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE)); q_ptr->pval = MON_NINJA; - (void)drop_near(q_ptr, -1, y, x); + (void)drop_near(caster_ptr, q_ptr, -1, y, x); if (success) msg_print(_("攻撃を受ける前に素早く身をひるがえした。", "You have turned around just before the attack hit you.")); else msg_print(_("失敗!攻撃を受けてしまった。", "Failed! You are hit by the attack.")); @@ -4413,7 +4413,7 @@ bool android_inside_weapon(player_type *creature_ptr) } -bool create_ration(player_type *crature_ptr) +bool create_ration(player_type *creature_ptr) { object_type *q_ptr; object_type forge; @@ -4423,7 +4423,7 @@ bool create_ration(player_type *crature_ptr) object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION)); /* Drop the object from heaven */ - (void)drop_near(q_ptr, -1, crature_ptr->y, crature_ptr->x); + (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x); msg_print(_("食事を料理して作った。", "You cook some food.")); return TRUE; } diff --git a/src/spells3.c b/src/spells3.c index ef6745b5c..7b17fbacf 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -744,7 +744,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx) } monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx]; - check_quest_completion(m_ptr); + check_quest_completion(creature_ptr, m_ptr); if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) { char m2_name[MAX_NLEN]; @@ -2723,14 +2723,15 @@ static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx) */ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x) { - grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x]; - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]; + floor_type *floor_ptr = caster_ptr->current_floor_ptr; + grid_type *g_ptr = &floor_ptr->grid_array[y][x]; + monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx]; MONRACE_IDX new_r_idx; MONRACE_IDX old_r_idx = m_ptr->r_idx; bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE; bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE; - if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) return FALSE; + if (floor_ptr->inside_arena || caster_ptr->phase_out) return FALSE; if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return FALSE; /* Memorize the monster before polymorphing */ @@ -2761,9 +2762,9 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x) bool polymorphed = FALSE; if (place_monster_aux(0, y, x, new_r_idx, mode)) { - caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname; - caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx; - caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx; + floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname; + floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx; + floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx; /* Success */ polymorphed = TRUE; @@ -2773,7 +2774,7 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x) /* Placing the new monster failed */ if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN))) { - caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii] = back_m; + floor_ptr->m_list[hack_m_idx_ii] = back_m; /* Re-initialize monster process */ mproc_init(); @@ -2786,7 +2787,7 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x) { for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { - object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[this_o_idx]; + object_type *o_ptr = &floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Held by new monster */ @@ -2797,8 +2798,8 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x) { for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { - next_o_idx = caster_ptr->current_floor_ptr->o_list[this_o_idx].next_o_idx; - delete_object_idx(this_o_idx); + next_o_idx = floor_ptr->o_list[this_o_idx].next_o_idx; + delete_object_idx(floor_ptr, this_o_idx); } } diff --git a/src/targeting.c b/src/targeting.c index 7a7ac8cc2..eeb21d353 100644 --- a/src/targeting.c +++ b/src/targeting.c @@ -810,7 +810,7 @@ static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue; /* Remove the first object from the list. */ - excise_object_idx(o_idx); + excise_object_idx(subject_ptr->current_floor_ptr, o_idx); /* Find end of the list. */ i = g_ptr->o_idx; @@ -910,7 +910,7 @@ static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT /* Get the quest text */ init_flags = INIT_NAME_ONLY; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0); name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"), quest[g_ptr->special].name, quest[g_ptr->special].level); diff --git a/src/wild.c b/src/wild.c index b1d658525..c97e0cbd5 100644 --- a/src/wild.c +++ b/src/wild.c @@ -324,6 +324,7 @@ static void generate_wilderness_area(floor_type *floor_ptr, int terrain, u32b se /*! * @brief 荒野フロア生成のメインルーチン / * Load a town or generate a terrain level using "plasma" fractals. + * @param player_ptr プレーヤーへの参照ポインタ * @param y 広域Y座標 * @param x 広域X座標 * @param border 広域マップの辺部分としての生成ならばTRUE @@ -339,14 +340,15 @@ static void generate_wilderness_area(floor_type *floor_ptr, int terrain, u32b se * If corner is set then only the corners of the area are needed. * */ -static void generate_area(floor_type *floor_ptr, POSITION y, POSITION x, bool border, bool corner) +static void generate_area(player_type *player_ptr, POSITION y, POSITION x, bool border, bool corner) { POSITION x1, y1; /* Number of the town (if any) */ - p_ptr->town_num = wilderness[y][x].town; + player_ptr->town_num = wilderness[y][x].town; /* Set the base level */ + floor_type *floor_ptr = player_ptr->current_floor_ptr; floor_ptr->base_level = wilderness[y][x].level; /* Set the dungeon level */ @@ -360,7 +362,7 @@ static void generate_area(floor_type *floor_ptr, POSITION y, POSITION x, bool bo /* Create the town */ - if (p_ptr->town_num) + if (player_ptr->town_num) { /* Reset the buildings */ init_buildings(); @@ -371,9 +373,9 @@ static void generate_area(floor_type *floor_ptr, POSITION y, POSITION x, bool bo else init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID); + process_dungeon_file(player_ptr, "t_info.txt", 0, 0, MAX_HGT, MAX_WID); - if (!corner && !border) p_ptr->visit |= (1L << (p_ptr->town_num - 1)); + if (!corner && !border) player_ptr->visit |= (1L << (player_ptr->town_num - 1)); } else { @@ -468,9 +470,10 @@ static border_type border; * @brief 広域マップの生成 / * Build the wilderness area outside of the town. * @todo 広域マップは恒常生成にする予定、player_typeによる処理分岐は最終的に排除する。 + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし */ -void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) +void wilderness_gen(player_type *creature_ptr) { int i, lim; POSITION y, x; @@ -478,6 +481,7 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) feature_type *f_ptr; /* Big town */ + floor_type *floor_ptr = creature_ptr->current_floor_ptr; floor_ptr->height = MAX_HGT; floor_ptr->width = MAX_WID; @@ -485,13 +489,13 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) panel_row_min = floor_ptr->height; panel_col_min = floor_ptr->width; - process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + process_dungeon_file(creature_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); x = creature_ptr->wilderness_x; y = creature_ptr->wilderness_y; get_mon_num_prep(get_monster_hook(), NULL); /* North border */ - generate_area(floor_ptr, y - 1, x, TRUE, FALSE); + generate_area(creature_ptr, y - 1, x, TRUE, FALSE); for (i = 1; i < MAX_WID - 1; i++) { @@ -499,7 +503,7 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) } /* South border */ - generate_area(floor_ptr, y + 1, x, TRUE, FALSE); + generate_area(creature_ptr, y + 1, x, TRUE, FALSE); for (i = 1; i < MAX_WID - 1; i++) { @@ -507,7 +511,7 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) } /* West border */ - generate_area(floor_ptr, y, x - 1, TRUE, FALSE); + generate_area(creature_ptr, y, x - 1, TRUE, FALSE); for (i = 1; i < MAX_HGT - 1; i++) { @@ -515,7 +519,7 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) } /* East border */ - generate_area(floor_ptr, y, x + 1, TRUE, FALSE); + generate_area(creature_ptr, y, x + 1, TRUE, FALSE); for (i = 1; i < MAX_HGT - 1; i++) { @@ -523,25 +527,24 @@ void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr) } /* North west corner */ - generate_area(floor_ptr, y - 1, x - 1, FALSE, TRUE); + generate_area(creature_ptr, y - 1, x - 1, FALSE, TRUE); border.north_west = floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat; /* North east corner */ - generate_area(floor_ptr, y - 1, x + 1, FALSE, TRUE); + generate_area(creature_ptr, y - 1, x + 1, FALSE, TRUE); border.north_east = floor_ptr->grid_array[MAX_HGT - 2][1].feat; /* South west corner */ - generate_area(floor_ptr, y + 1, x - 1, FALSE, TRUE); + generate_area(creature_ptr, y + 1, x - 1, FALSE, TRUE); border.south_west = floor_ptr->grid_array[1][MAX_WID - 2].feat; /* South east corner */ - generate_area(floor_ptr, y + 1, x + 1, FALSE, TRUE); + generate_area(creature_ptr, y + 1, x + 1, FALSE, TRUE); border.south_east = floor_ptr->grid_array[1][1].feat; /* Create terrain of the current area */ - generate_area(floor_ptr, y, x, FALSE, FALSE); - + generate_area(creature_ptr, y, x, FALSE, FALSE); /* Special boundary walls -- North */ for (i = 0; i < MAX_WID; i++) @@ -709,8 +712,9 @@ static s16b conv_terrain2feat[MAX_WILDERNESS]; * Build the wilderness area. -DG- * @return なし */ -void wilderness_gen_small(player_type *creature_ptr, floor_type *floor_ptr) +void wilderness_gen_small(player_type *creature_ptr) { + floor_type *floor_ptr = creature_ptr->current_floor_ptr; int i, j; /* To prevent stupid things */ @@ -720,7 +724,7 @@ void wilderness_gen_small(player_type *creature_ptr, floor_type *floor_ptr) floor_ptr->grid_array[j][i].feat = feat_permanent; } - process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + process_dungeon_file(creature_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); /* Fill the map */ for (i = 0; i < current_world_ptr->max_wild_x; i++) diff --git a/src/wild.h b/src/wild.h index 7e46d078a..37da8d452 100644 --- a/src/wild.h +++ b/src/wild.h @@ -26,8 +26,8 @@ /* wild.c */ extern void set_floor_and_wall(DUNGEON_IDX type); -extern void wilderness_gen(player_type *creature_ptr, floor_type *floor_ptr); -extern void wilderness_gen_small(player_type *creature_ptr, floor_type *floor_ptr); +extern void wilderness_gen(player_type *creature_ptr); +extern void wilderness_gen_small(player_type *creature_ptr); extern errr init_wilderness(void); extern void init_wilderness_terrains(void); extern void seed_wilderness(void); diff --git a/src/wizard2.c b/src/wizard2.c index 2f5afec5f..523b7a77a 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -178,7 +178,7 @@ static void wiz_create_named_art(player_type *caster_ptr) if (a_idx < 0) a_idx = 0; if (a_idx >= max_a_idx) a_idx = 0; - (void)create_named_art(a_idx, caster_ptr->y, caster_ptr->x); + (void)create_named_art(caster_ptr, a_idx, caster_ptr->y, caster_ptr->x); /* All done */ msg_print("Allocated."); @@ -1326,7 +1326,7 @@ static void wiz_create_item(player_type *caster_ptr) if (a_info[i].sval != k_info[k_idx].sval) continue; /* Create this artifact */ - (void)create_named_art(i, caster_ptr->y, caster_ptr->x); + (void)create_named_art(caster_ptr, i, caster_ptr->y, caster_ptr->x); /* All done */ msg_print("Allocated(INSTA_ART)."); @@ -1343,7 +1343,7 @@ static void wiz_create_item(player_type *caster_ptr) apply_magic(q_ptr, caster_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART); /* Drop the object from heaven */ - (void)drop_near(q_ptr, -1, caster_ptr->y, caster_ptr->x); + (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x); /* All done */ msg_print("Allocated."); @@ -1799,7 +1799,7 @@ void do_cmd_debug(player_type *creature_ptr) /* Good Objects */ case 'g': if (command_arg <= 0) command_arg = 1; - acquirement(creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE); break; /* Hitpoint rerating */ @@ -1892,7 +1892,7 @@ void do_cmd_debug(player_type *creature_ptr) if (tmp_int >= max_q_idx) break; creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)tmp_int; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); quest[tmp_int].status = QUEST_STATUS_TAKEN; creature_ptr->current_floor_ptr->inside_quest = 0; } @@ -1939,7 +1939,7 @@ void do_cmd_debug(player_type *creature_ptr) /* Special(Random Artifact) Objects */ case 'S': if (command_arg <= 0) command_arg = 1; - acquirement(creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE); break; /* Teleport */ @@ -1955,7 +1955,7 @@ void do_cmd_debug(player_type *creature_ptr) /* Very Good Objects */ case 'v': if (command_arg <= 0) command_arg = 1; - acquirement(creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE); + acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE); break; /* Wizard Light the Level */ @@ -1989,7 +1989,7 @@ void do_cmd_debug(player_type *creature_ptr) INVENTORY_IDX i; for (i = INVEN_TOTAL - 1; i >= 0; i--) { - if (creature_ptr->inventory_list[i].k_idx) inven_drop(i, 999); + if (creature_ptr->inventory_list[i].k_idx) inven_drop(creature_ptr, i, 999); } player_outfit(creature_ptr); break; -- 2.11.0