X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Ffloor-save.c;h=cf78a76fec1ffad8be00a11a4f270d3744daeba3;hb=973b86e0ff8420ac230a418c13fd751b688122d7;hp=5d25d84e3205f65593751ebfd30c9367c2ee2db8;hpb=7c0a703095f2b72e432f1ed9786ea8aa2946b4cb;p=hengband%2Fhengband.git diff --git a/src/floor-save.c b/src/floor-save.c index 5d25d84e3..cf78a76fe 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -45,9 +45,10 @@ #include "view-mainwindow.h" - static FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */ static u32b latest_visit_mark; /*!<フロアを渡った回数?(確認中) / Max number of visit_mark */ +#define MAX_PARTY_MON 21 /*!< フロア移動時に先のフロアに連れて行けるペットの最大数 Maximum number of preservable pets */ +static monster_type party_mon[MAX_PARTY_MON]; /*!< フロア移動に保存するペットモンスターの配列 */ /* * Number of floor_id used from birth @@ -55,18 +56,19 @@ static u32b latest_visit_mark; /*!<フロアを渡った回数?(確認中) / FLOOR_IDX max_floor_id; /* - * Sign for current process used in temporal files. + * Sign for current process used in temporary files. * Actually it is the start time of current process. */ u32b saved_floor_file_sign; /*! * @brief 保存フロア配列を初期化する / Initialize saved_floors array. - * @param force テンポラリファイルが残っていた場合も警告なしで強制的に削除する。 - * @details Make sure that old temporal files are not remaining as gurbages. + * @param creature_ptr プレーヤーへの参照ポインタ + * @param force テンポラリファイルが残っていた場合も警告なしで強制的に削除するフラグ + * @details Make sure that old temporary files are not remaining as gurbages. * @return なし */ -void init_saved_floors(bool force) +void init_saved_floors(player_type *creature_ptr, bool force) { char floor_savefile[1024]; int i; @@ -101,11 +103,11 @@ void init_saved_floors(bool force) { if (!force) { - msg_print(_("エラー:古いテンポラリ・ファイルが残っています。", "Error: There are old temporal files.")); + msg_print(_("エラー:古いテンポラリ・ファイルが残っています。", "Error: There are old temporary files.")); msg_print(_("変愚蛮怒を二重に起動していないか確認してください。", "Make sure you are not running two game processes simultaneously.")); - msg_print(_("過去に変愚蛮怒がクラッシュした場合は一時ファイルを", "If the temporal files are garbages of old crashed process, ")); + msg_print(_("過去に変愚蛮怒がクラッシュした場合は一時ファイルを", "If the temporary files are garbages of old crashed process, ")); msg_print(_("強制的に削除して実行を続けられます。", "you can delete it safely.")); - if (!get_check(_("強制的に削除してもよろしいですか?", "Do you delete old temporal files? "))) + if (!get_check(_("強制的に削除してもよろしいですか?", "Do you delete old temporary files? "))) quit(_("実行中止", "Aborted.")); force = TRUE; } @@ -119,7 +121,7 @@ void init_saved_floors(bool force) /* Grab permissions */ safe_setuid_grab(); - /* Simply kill the temporal file */ + /* Simply kill the temporary file */ (void)fd_kill(floor_savefile); /* Drop permissions */ @@ -134,14 +136,14 @@ void init_saved_floors(bool force) /* vist_mark is from 1 */ latest_visit_mark = 1; - /* A sign to mark temporal files */ + /* A sign to mark temporary files */ saved_floor_file_sign = (u32b)time(NULL); /* No next floor yet */ new_floor_id = 0; /* No change floor mode yet */ - p_ptr->change_floor_mode = 0; + creature_ptr->change_floor_mode = 0; #ifdef SET_UID # ifdef SECURE @@ -152,11 +154,12 @@ void init_saved_floors(bool force) } /*! - * @brief 保存フロア用テンポラリファイルを削除する / Kill temporal files + * @brief 保存フロア用テンポラリファイルを削除する / Kill temporary files * @details Should be called just before the game quit. + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし */ -void clear_saved_floor_files(void) +void clear_saved_floor_files(player_type *creature_ptr) { char floor_savefile[1024]; int i; @@ -172,9 +175,9 @@ void clear_saved_floor_files(void) { saved_floor_type *sf_ptr = &saved_floors[i]; - /* No temporal file */ + /* No temporary file */ if (!sf_ptr->floor_id) continue; - if (sf_ptr->floor_id == p_ptr->floor_id) continue; + if (sf_ptr->floor_id == creature_ptr->floor_id) continue; /* File name */ sprintf(floor_savefile, "%s.F%02d", savefile, i); @@ -182,7 +185,7 @@ void clear_saved_floor_files(void) /* Grab permissions */ safe_setuid_grab(); - /* Simply kill the temporal file */ + /* Simply kill the temporary file */ (void)fd_kill(floor_savefile); /* Drop permissions */ @@ -223,10 +226,11 @@ saved_floor_type *get_sf_ptr(FLOOR_IDX floor_id) /*! * @brief 参照ポインタ先の保存フロアを抹消する / kill a saved floor and get an empty space + * @param creature_ptr プレーヤーへの参照ポインタ * @param sf_ptr 保存フロアの参照ポインタ * @return なし */ -static void kill_saved_floor(saved_floor_type *sf_ptr) +static void kill_saved_floor(player_type *creature_ptr, saved_floor_type *sf_ptr) { char floor_savefile[1024]; if (!sf_ptr) return; @@ -234,12 +238,12 @@ static void kill_saved_floor(saved_floor_type *sf_ptr) /* Already empty */ if (!sf_ptr->floor_id) return; - if (sf_ptr->floor_id == p_ptr->floor_id) + if (sf_ptr->floor_id == creature_ptr->floor_id) { /* Kill current floor */ - p_ptr->floor_id = 0; + creature_ptr->floor_id = 0; - /* Current floor doesn't have temporal file */ + /* Current floor doesn't have temporary file */ } else { @@ -249,7 +253,7 @@ static void kill_saved_floor(saved_floor_type *sf_ptr) /* Grab permissions */ safe_setuid_grab(); - /* Simply kill the temporal file */ + /* Simply kill the temporary file */ (void)fd_kill(floor_savefile); /* Drop permissions */ @@ -263,11 +267,12 @@ static void kill_saved_floor(saved_floor_type *sf_ptr) /*! * @brief 新規に利用可能な保存フロアを返す / Initialize new saved floor and get its floor id. + * @param creature_ptr プレーヤーへの参照ポインタ * @return 利用可能な保存フロアID * @details * If number of saved floors are already MAX_SAVED_FLOORS, kill the oldest one. */ -FLOOR_IDX get_new_floor_id(void) +FLOOR_IDX get_new_floor_id(player_type *creature_ptr) { saved_floor_type *sf_ptr = NULL; FLOOR_IDX i; @@ -292,7 +297,7 @@ FLOOR_IDX get_new_floor_id(void) sf_ptr = &saved_floors[i]; /* Don't kill current floor */ - if (sf_ptr->floor_id == p_ptr->floor_id) continue; + if (sf_ptr->floor_id == creature_ptr->floor_id) continue; /* Don't kill newer */ if (sf_ptr->visit_mark > oldest_visit) continue; @@ -303,7 +308,7 @@ FLOOR_IDX get_new_floor_id(void) /* Kill oldest saved floor */ sf_ptr = &saved_floors[oldest]; - kill_saved_floor(sf_ptr); + kill_saved_floor(creature_ptr, sf_ptr); /* Use it */ i = oldest; @@ -318,7 +323,7 @@ FLOOR_IDX get_new_floor_id(void) sf_ptr->visit_mark = latest_visit_mark++; /* sf_ptr->dun_level may be changed later */ - sf_ptr->dun_level = p_ptr->current_floor_ptr->dun_level; + sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level; /* Increment number of floor_id */ @@ -333,30 +338,34 @@ FLOOR_IDX get_new_floor_id(void) /*! * @brief フロア切り替え時の処理フラグを追加する / Prepare mode flags of changing floor + * @param creature_ptr プレーヤーへの参照ポインタ * @param mode 追加したい所持フラグ * @return なし */ -void prepare_change_floor_mode(BIT_FLAGS mode) +void prepare_change_floor_mode(player_type *creature_ptr, BIT_FLAGS mode) { - p_ptr->change_floor_mode |= mode; + creature_ptr->change_floor_mode |= mode; } /*! * @brief 階段移動先のフロアが生成できない時に簡単な行き止まりマップを作成する / Builds the dead end * @return なし */ -static void build_dead_end(floor_type *floor_ptr) +static void build_dead_end(player_type *creature_ptr) { POSITION x, y; - clear_cave(floor_ptr); + clear_cave(creature_ptr); + + /* Mega-Hack -- no player yet */ + creature_ptr->x = creature_ptr->y = 0; /* Fill the arrays of floors and walls in the good proportions */ set_floor_and_wall(0); /* Smallest area */ - floor_ptr->height = SCREEN_HGT; - floor_ptr->width = SCREEN_WID; + creature_ptr->current_floor_ptr->height = SCREEN_HGT; + creature_ptr->current_floor_ptr->width = SCREEN_WID; /* Filled with permanent walls */ for (y = 0; y < MAX_HGT; y++) @@ -364,30 +373,27 @@ static void build_dead_end(floor_type *floor_ptr) for (x = 0; x < MAX_WID; x++) { /* Create "solid" perma-wall */ - place_solid_perm_bold(y, x); + place_bold(creature_ptr, y, x, solid_perm); } } /* Place at center of the floor */ - p_ptr->y = floor_ptr->height / 2; - p_ptr->x = floor_ptr->width / 2; + creature_ptr->y = creature_ptr->current_floor_ptr->height / 2; + creature_ptr->x = creature_ptr->current_floor_ptr->width / 2; /* Give one square */ - place_floor_bold(p_ptr->y, p_ptr->x); + place_bold(creature_ptr, creature_ptr->y, creature_ptr->x, floor); - wipe_generate_random_floor_flags(floor_ptr); + wipe_generate_random_floor_flags(creature_ptr->current_floor_ptr); } - -#define MAX_PARTY_MON 21 /*!< フロア移動時に先のフロアに連れて行けるペットの最大数 Maximum number of preservable pets */ -static monster_type party_mon[MAX_PARTY_MON]; /*!< フロア移動に保存するペットモンスターの配列 */ - /*! * @brief フロア移動時のペット保存処理 / Preserve_pets + * @param master_ptr プレーヤーへの参照ポインタ * @return なし */ -static void preserve_pet(void) +static void preserve_pet(player_type *master_ptr) { int num; MONSTER_IDX i; @@ -397,16 +403,16 @@ static void preserve_pet(void) party_mon[num].r_idx = 0; } - if (p_ptr->riding) + if (master_ptr->riding) { - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding]; + monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[master_ptr->riding]; /* Pet of other pet don't follow. */ if (m_ptr->parent_m_idx) { - p_ptr->riding = 0; - p_ptr->pet_extra_flags &= ~(PF_RYOUTE); - p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE; + master_ptr->riding = 0; + master_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); + master_ptr->riding_ryoute = master_ptr->old_riding_ryoute = FALSE; } else { @@ -414,7 +420,7 @@ static void preserve_pet(void) (void)COPY(&party_mon[0], m_ptr, monster_type); /* Delete from this floor */ - delete_monster_idx(p_ptr->riding); + delete_monster_idx(master_ptr, master_ptr->riding); } } @@ -422,15 +428,15 @@ static void preserve_pet(void) * If player is in wild mode, no pets are preserved * except a monster whom player riding */ - if (!p_ptr->wild_mode && !p_ptr->inside_arena && !p_ptr->phase_out) + if (!master_ptr->wild_mode && !master_ptr->current_floor_ptr->inside_arena && !master_ptr->phase_out) { - for (i = p_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--) + for (i = master_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--) { - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i]; + monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i]; if (!monster_is_valid(m_ptr)) continue; if (!is_pet(m_ptr)) continue; - if (i == p_ptr->riding) continue; + if (i == master_ptr->riding) continue; if (reinit_wilderness) { @@ -438,7 +444,7 @@ static void preserve_pet(void) } else { - POSITION dis = distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx); + POSITION dis = distance(master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx); /* Confused (etc.) monsters don't follow. */ if (MON_CONFUSED(m_ptr) || MON_STUNNED(m_ptr) || MON_CSLEEP(m_ptr)) continue; @@ -451,8 +457,8 @@ static void preserve_pet(void) * when you or the pet can see the other. */ if (m_ptr->nickname && - ((player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) || - (los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)))) + ((player_has_los_bold(master_ptr, m_ptr->fy, m_ptr->fx) && projectable(master_ptr, master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx)) || + (los(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x) && projectable(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x)))) { if (dis > 3) continue; } @@ -462,51 +468,51 @@ static void preserve_pet(void) } } - (void)COPY(&party_mon[num], &p_ptr->current_floor_ptr->m_list[i], monster_type); + (void)COPY(&party_mon[num], &master_ptr->current_floor_ptr->m_list[i], monster_type); num++; /* Delete from this floor */ - delete_monster_idx(i); + delete_monster_idx(master_ptr, i); } } if (record_named_pet) { - for (i = p_ptr->current_floor_ptr->m_max - 1; i >=1; i--) + for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--) { - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i]; + monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i]; GAME_TEXT m_name[MAX_NLEN]; if (!monster_is_valid(m_ptr)) continue; if (!is_pet(m_ptr)) continue; if (!m_ptr->nickname) continue; - if (p_ptr->riding == i) continue; + if (master_ptr->riding == i) continue; - monster_desc(m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE); - exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name); + monster_desc(master_ptr, m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE); + exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name); } } /* Pet of other pet may disappear. */ - for (i = p_ptr->current_floor_ptr->m_max - 1; i >=1; i--) + for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--) { - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i]; + monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i]; /* Are there its parent? */ - if (m_ptr->parent_m_idx && !p_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx) + if (m_ptr->parent_m_idx && !master_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx) { /* Its parent have gone, it also goes away. */ if (is_seen(m_ptr)) { GAME_TEXT m_name[MAX_NLEN]; - monster_desc(m_name, m_ptr, 0); + monster_desc(master_ptr, m_name, m_ptr, 0); msg_format(_("%sは消え去った!", "%^s disappears!"), m_name); } - delete_monster_idx(i); + delete_monster_idx(master_ptr, i); } } } @@ -514,15 +520,16 @@ static void preserve_pet(void) /*! * @brief フロア移動時にペットを伴った場合の準備処理 / Pre-calculate the racial counters of preserved pets + * @param master_ptr プレーヤーへの参照ポインタ * @return なし * @details * To prevent multiple generation of unique monster who is the minion of player */ -void precalc_cur_num_of_pet(void) +void precalc_cur_num_of_pet(player_type *player_ptr) { monster_type *m_ptr; int i; - int max_num = p_ptr->wild_mode ? 1 : MAX_PARTY_MON; + int max_num = player_ptr->wild_mode ? 1 : MAX_PARTY_MON; for (i = 0; i < max_num; i++) { @@ -538,6 +545,7 @@ void precalc_cur_num_of_pet(void) /*! * @brief 移動先のフロアに伴ったペットを配置する / Place preserved pet monsters on new floor + * @param master_ptr プレーヤーへの参照ポインタ * @return なし */ static void place_pet(player_type *master_ptr) @@ -554,7 +562,7 @@ static void place_pet(player_type *master_ptr) if (i == 0) { - m_idx = m_pop(); + m_idx = m_pop(master_ptr); master_ptr->riding = m_idx; if (m_idx) { @@ -571,20 +579,20 @@ static void place_pet(player_type *master_ptr) { for (j = 1000; j > 0; j--) { - scatter(&cy, &cx, master_ptr->y, master_ptr->x, d, 0); + scatter(master_ptr, &cy, &cx, master_ptr->y, master_ptr->x, d, 0); if (monster_can_enter(cy, cx, &r_info[party_mon[i].r_idx], 0)) break; } if (j) break; } - m_idx = (d == 6) ? 0 : m_pop(); + m_idx = (d == 6) ? 0 : m_pop(master_ptr); } if (m_idx) { - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx]; + monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[m_idx]; monster_race *r_ptr; - p_ptr->current_floor_ptr->grid_array[cy][cx].m_idx = m_idx; + master_ptr->current_floor_ptr->grid_array[cy][cx].m_idx = m_idx; m_ptr->r_idx = party_mon[i].r_idx; @@ -594,6 +602,7 @@ static void place_pet(player_type *master_ptr) m_ptr->fy = cy; m_ptr->fx = cx; + m_ptr->current_floor_ptr = master_ptr->current_floor_ptr; m_ptr->ml = TRUE; m_ptr->mtimed[MTIMED_CSLEEP] = 0; m_ptr->hold_o_idx = 0; @@ -607,14 +616,14 @@ static void place_pet(player_type *master_ptr) /* Must repair monsters */ repair_monsters = TRUE; } - update_monster(m_idx, TRUE); + update_monster(master_ptr, m_idx, TRUE); lite_spot(cy, cx); /* Pre-calculated in precalc_cur_num_of_pet() */ /* r_ptr->cur_num++; */ /* Hack -- Count the number of "reproducers" */ - if (r_ptr->flags2 & RF2_MULTIPLY) p_ptr->current_floor_ptr->num_repro++; + if (r_ptr->flags2 & RF2_MULTIPLY) master_ptr->current_floor_ptr->num_repro++; } else @@ -623,12 +632,12 @@ static void place_pet(player_type *master_ptr) monster_race *r_ptr = real_r_ptr(m_ptr); GAME_TEXT m_name[MAX_NLEN]; - monster_desc(m_name, m_ptr, 0); + monster_desc(master_ptr, m_name, m_ptr, 0); msg_format(_("%sとはぐれてしまった。", "You have lost sight of %s."), m_name); if (record_named_pet && m_ptr->nickname) { - monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE); - exe_write_diary(master_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name); + monster_desc(master_ptr, m_name, m_ptr, MD_INDEF_VISIBLE); + exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name); } /* Pre-calculated in precalc_cur_num_of_pet(), but need to decrease */ @@ -650,15 +659,15 @@ static void place_pet(player_type *master_ptr) * while new floor creation since dungeons may be re-created by\n * auto-scum option.\n */ -static void update_unique_artifact(s16b cur_floor_id) +static void update_unique_artifact(floor_type *floor_ptr, s16b cur_floor_id) { int i; /* Maintain unique monsters */ - for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++) + for (i = 1; i < floor_ptr->m_max; i++) { monster_race *r_ptr; - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i]; + monster_type *m_ptr = &floor_ptr->m_list[i]; if (!monster_is_valid(m_ptr)) continue; @@ -674,9 +683,9 @@ static void update_unique_artifact(s16b cur_floor_id) } /* Maintain artifatcs */ - 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 = &p_ptr->current_floor_ptr->o_list[i]; + object_type *o_ptr = &floor_ptr->o_list[i]; if (!OBJECT_IS_VALID(o_ptr)) continue; @@ -728,7 +737,7 @@ static void get_out_monster(floor_type *floor_ptr, player_type *protected_ptr) if (!in_bounds(floor_ptr, ny, nx)) continue; /* Require "empty" floor space */ - if (!cave_empty_bold(ny, nx)) continue; + if (!cave_empty_bold(protected_ptr->current_floor_ptr, ny, nx)) continue; /* Hack -- no teleport onto glyph of warding */ if (is_glyph_grid(&floor_ptr->grid_array[ny][nx])) continue; @@ -840,7 +849,7 @@ static void locate_connected_stairs(player_type *creature_ptr, floor_type *floor else if (!num) { /* No stairs found! -- No return */ - prepare_change_floor_mode(CFM_RAND_PLACE | CFM_NO_RETURN); + prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE | CFM_NO_RETURN); /* Mega Hack -- It's not the stairs you enter. Disable it. */ if (!feat_uses_special(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat)) floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].special = 0; @@ -859,6 +868,7 @@ static void locate_connected_stairs(player_type *creature_ptr, floor_type *floor /*! * @brief 現在のフロアを離れるに伴って行なわれる保存処理 * / Maintain quest monsters, mark next floor_id at stairs, save current floor, and prepare to enter next floor. + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし */ void leave_floor(player_type *creature_ptr) @@ -871,10 +881,10 @@ void leave_floor(player_type *creature_ptr) FLOOR_IDX tmp_floor_idx = 0; /* Preserve pets and prepare to take these to next floor */ - preserve_pet(); + preserve_pet(creature_ptr); /* Remove all mirrors without explosion */ - remove_all_mirrors(FALSE); + remove_all_mirrors(creature_ptr, FALSE); if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE); @@ -886,8 +896,8 @@ void leave_floor(player_type *creature_ptr) (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) && !(creature_ptr->change_floor_mode & CFM_NO_RETURN)) { - /* Get temporal floor_id */ - tmp_floor_idx = get_new_floor_id(); + /* Get temporary floor_id */ + tmp_floor_idx = get_new_floor_id(creature_ptr); } /* Search the quest monster index */ @@ -896,7 +906,7 @@ void leave_floor(player_type *creature_ptr) if ((quest[i].status == QUEST_STATUS_TAKEN) && ((quest[i].type == QUEST_TYPE_KILL_LEVEL) || (quest[i].type == QUEST_TYPE_RANDOM)) && - (quest[i].level == p_ptr->current_floor_ptr->dun_level) && + (quest[i].level == creature_ptr->current_floor_ptr->dun_level) && (creature_ptr->dungeon_idx == quest[i].dungeon) && !(quest[i].flags & QUEST_FLAG_PRESET)) { @@ -905,10 +915,10 @@ void leave_floor(player_type *creature_ptr) } /* Maintain quest monsters */ - for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++) + for (i = 1; i < creature_ptr->current_floor_ptr->m_max; i++) { monster_race *r_ptr; - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i]; + monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i]; if (!monster_is_valid(m_ptr)) continue; @@ -923,7 +933,7 @@ void leave_floor(player_type *creature_ptr) (r_ptr->flags7 & RF7_NAZGUL)) continue; /* Delete non-unique quest monsters */ - delete_monster_idx(i); + delete_monster_idx(creature_ptr, i); } /* Check if there is a same item */ @@ -953,7 +963,7 @@ void leave_floor(player_type *creature_ptr) if (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) { /* Extract stair position */ - g_ptr = &p_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]; + g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]; f_ptr = &f_info[g_ptr->feat]; /* Get back to old saved floor? */ @@ -966,7 +976,7 @@ void leave_floor(player_type *creature_ptr) /* Mark shaft up/down */ if (have_flag(f_ptr->flags, FF_STAIRS) && have_flag(f_ptr->flags, FF_SHAFT)) { - prepare_change_floor_mode(CFM_SHAFT); + prepare_change_floor_mode(creature_ptr, CFM_SHAFT); } } @@ -986,20 +996,20 @@ void leave_floor(player_type *creature_ptr) /* Get out from or Enter the dungeon */ if (creature_ptr->change_floor_mode & CFM_DOWN) { - if (!p_ptr->current_floor_ptr->dun_level) + if (!creature_ptr->current_floor_ptr->dun_level) move_num = d_info[creature_ptr->dungeon_idx].mindepth; } else if (creature_ptr->change_floor_mode & CFM_UP) { - if (p_ptr->current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth) - move_num = -p_ptr->current_floor_ptr->dun_level; + if (creature_ptr->current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth) + move_num = -creature_ptr->current_floor_ptr->dun_level; } - p_ptr->current_floor_ptr->dun_level += move_num; + creature_ptr->current_floor_ptr->dun_level += move_num; } /* Leaving the dungeon to town */ - if (!p_ptr->current_floor_ptr->dun_level && creature_ptr->dungeon_idx) + if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->dungeon_idx) { creature_ptr->leaving_dungeon = TRUE; if (!vanilla_town && !lite_town) @@ -1019,7 +1029,7 @@ void leave_floor(player_type *creature_ptr) { /* Kill all saved floors */ for (i = 0; i < MAX_SAVED_FLOORS; i++) - kill_saved_floor(&saved_floors[i]); + kill_saved_floor(creature_ptr, &saved_floors[i]); /* Reset visit_mark count */ latest_visit_mark = 1; @@ -1027,7 +1037,7 @@ void leave_floor(player_type *creature_ptr) else if (creature_ptr->change_floor_mode & CFM_NO_RETURN) { /* Kill current floor */ - kill_saved_floor(sf_ptr); + kill_saved_floor(creature_ptr, sf_ptr); } /* No current floor -- Left/Enter dungeon etc... */ @@ -1041,7 +1051,7 @@ void leave_floor(player_type *creature_ptr) if (!new_floor_id) { /* Get new id */ - new_floor_id = get_new_floor_id(); + new_floor_id = get_new_floor_id(creature_ptr); /* Connect from here */ if (g_ptr && !feat_uses_special(g_ptr->feat)) @@ -1064,23 +1074,23 @@ void leave_floor(player_type *creature_ptr) !(creature_ptr->change_floor_mode & CFM_NO_RETURN)) { /* Get out of the my way! */ - get_out_monster(p_ptr->current_floor_ptr, creature_ptr); + get_out_monster(creature_ptr->current_floor_ptr, creature_ptr); /* Record the last visit turn of current floor */ sf_ptr->last_visit = current_world_ptr->game_turn; - forget_lite(p_ptr->current_floor_ptr); - forget_view(); - clear_mon_lite(p_ptr->current_floor_ptr); + forget_lite(creature_ptr->current_floor_ptr); + forget_view(creature_ptr->current_floor_ptr); + clear_mon_lite(creature_ptr->current_floor_ptr); /* Save current floor */ - if (!save_floor(sf_ptr, 0)) + if (!save_floor(creature_ptr, sf_ptr, 0)) { /* Save failed -- No return */ - prepare_change_floor_mode(CFM_NO_RETURN); + prepare_change_floor_mode(creature_ptr, CFM_NO_RETURN); /* Kill current floor */ - kill_saved_floor(get_sf_ptr(creature_ptr->floor_id)); + kill_saved_floor(creature_ptr, get_sf_ptr(creature_ptr->floor_id)); } } } @@ -1088,10 +1098,11 @@ void leave_floor(player_type *creature_ptr) /*! * @brief フロアの切り替え処理 / Enter new floor. + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし * @details * If the floor is an old saved floor, it will be\n - * restored from the temporal file. If the floor is new one, new p_ptr->current_floor_ptr->grid_array\n + * restored from the temporary file. If the floor is new one, new floor\n * will be generated.\n */ void change_floor(player_type *creature_ptr) @@ -1118,7 +1129,7 @@ void change_floor(player_type *creature_ptr) if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) && !(creature_ptr->change_floor_mode & CFM_FIRST_FLOOR)) { - generate_floor(creature_ptr->current_floor_ptr); + generate_floor(creature_ptr); /* Paranoia -- No new saved floor */ new_floor_id = 0; @@ -1131,7 +1142,7 @@ void change_floor(player_type *creature_ptr) if (!new_floor_id) { /* Get new id */ - new_floor_id = get_new_floor_id(); + new_floor_id = get_new_floor_id(creature_ptr); } /* Pointer for infomations of new floor */ @@ -1141,7 +1152,7 @@ void change_floor(player_type *creature_ptr) if (sf_ptr->last_visit) { /* Old saved floor is exist */ - if (load_floor(sf_ptr, 0)) + if (load_floor(creature_ptr, sf_ptr, 0)) { loaded = TRUE; @@ -1224,12 +1235,12 @@ void change_floor(player_type *creature_ptr) m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp; /* Remove timed status (except MTIMED_CSLEEP) */ - (void)set_monster_fast(i, 0); - (void)set_monster_slow(i, 0); - (void)set_monster_stunned(i, 0); - (void)set_monster_confused(i, 0); - (void)set_monster_monfear(i, 0); - (void)set_monster_invulner(i, 0, FALSE); + (void)set_monster_fast(creature_ptr, i, 0); + (void)set_monster_slow(creature_ptr, i, 0); + (void)set_monster_stunned(creature_ptr, i, 0); + (void)set_monster_confused(creature_ptr, i, 0); + (void)set_monster_monfear(creature_ptr, i, 0); + (void)set_monster_invulner(creature_ptr, i, 0, FALSE); } /* Extract real monster race */ @@ -1243,7 +1254,7 @@ void change_floor(player_type *creature_ptr) if (r_ptr->floor_id != new_floor_id) { /* Disapper from here */ - delete_monster_idx(i); + delete_monster_idx(creature_ptr, i); } } @@ -1261,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 { @@ -1270,7 +1281,7 @@ void change_floor(player_type *creature_ptr) } } - (void)place_quest_monsters(creature_ptr->current_floor_ptr, creature_ptr); + (void)place_quest_monsters(creature_ptr); /* Place some random monsters */ alloc_times = absence_ticks / alloc_chance; @@ -1281,7 +1292,7 @@ void change_floor(player_type *creature_ptr) for (i = 0; i < alloc_times; i++) { /* Make a (group of) new monster */ - (void)alloc_monster(0, 0); + (void)alloc_monster(creature_ptr, 0, 0); } } @@ -1291,11 +1302,11 @@ void change_floor(player_type *creature_ptr) { if (sf_ptr->last_visit) { - /* Temporal file is broken? */ + /* Temporary file is broken? */ msg_print(_("階段は行き止まりだった。", "The staircases come to a dead end...")); /* Create simple dead end */ - build_dead_end(creature_ptr->current_floor_ptr); + build_dead_end(creature_ptr); /* Break connection */ if (creature_ptr->change_floor_mode & CFM_UP) @@ -1309,7 +1320,7 @@ void change_floor(player_type *creature_ptr) } else { - generate_floor(creature_ptr->current_floor_ptr); + generate_floor(creature_ptr); } /* Record last visit turn */ @@ -1327,7 +1338,7 @@ void change_floor(player_type *creature_ptr) /*** Create connected stairs ***/ /* No stairs down from Quest */ - if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr->current_floor_ptr->dun_level)) + if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level)) { g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair; } @@ -1380,10 +1391,10 @@ void change_floor(player_type *creature_ptr) place_pet(creature_ptr); /* Reset travel target place */ - forget_travel_flow(); + forget_travel_flow(creature_ptr->current_floor_ptr); /* Hack -- maintain unique and artifacts */ - update_unique_artifact(new_floor_id); + update_unique_artifact(creature_ptr->current_floor_ptr, new_floor_id); /* Now the player is in new floor */ creature_ptr->floor_id = new_floor_id;