OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。sortのエンバグに対応。 / Ongoing type replacement. Fix new...
[hengband/hengband.git] / src / floors.c
index d3494ea..20f14df 100644 (file)
@@ -1,27 +1,29 @@
-/* File: floors.c */
-
-/* Purpose: management of the saved floor */
-
-/*
- * Copyright (c) 2002  Mogami
- *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+/*!
+ * @file floors.c
+ * @brief 保存された階の管理 / management of the saved floor
+ * @date 2014/01/04
+ * @author
+ * Copyright (c) 2002  Mogami \n
+ * This software may be copied and distributed for educational, research, and \n
+ * not for profit purposes provided that this copyright and statement are \n
+ * included in all such copies. \n
+ * 2014 Deskull rearranged comment for Doxygen. \n
  */
 
 #include "angband.h"
 #include "grid.h"
 
 
-static s16b new_floor_id;       /* floor_id of the destination */
-static u32b change_floor_mode;  /* Mode flags for changing floor */
-static u32b latest_visit_mark;  /* Max number of visit_mark */
+static s16b new_floor_id;       /*!<次のフロアのID / floor_id of the destination */
+static u32b change_floor_mode;  /*!<フロア移行処理に関するフラグ / Mode flags for changing floor */
+static u32b latest_visit_mark;  /*!<フロアを渡った回数?(確認中) / Max number of visit_mark */
 
 
-/*
- * Initialize saved_floors array.  Make sure that old temporal files
- * are not remaining as gurbages.
+/*!
+ * @brief 保存フロア配列を初期化する / Initialize saved_floors array. 
+ * @param force テンポラリファイルが残っていた場合も警告なしで強制的に削除する。
+ * @details Make sure that old temporal files are not remaining as gurbages.
+ * @return なし
  */
 void init_saved_floors(bool force)
 {
@@ -59,11 +61,11 @@ void init_saved_floors(bool force)
                        if (!force)
                        {
 #ifdef JP
-                               msg_print("¥¨¥é¡¼¡§¸Å¤¤¥Æ¥ó¥Ý¥é¥ê¡¦¥Õ¥¡¥¤¥ë¤¬»Ä¤Ã¤Æ¤¤¤Þ¤¹¡£");
-                               msg_print("ÊѶòÈÚÅܤòÆó½Å¤Ëµ¯Æ°¤·¤Æ¤¤¤Ê¤¤¤«³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£");
-                               msg_print("²áµî¤ËÊѶòÈÚÅܤ¬¥¯¥é¥Ã¥·¥å¤·¤¿¾ì¹ç¤Ï°ì»þ¥Õ¥¡¥¤¥ë¤ò");
-                               msg_print("¶¯À©Åª¤Ëºï½ü¤·¤Æ¼Â¹Ô¤ò³¤±¤é¤ì¤Þ¤¹¡£");
-                               if (!get_check("¶¯À©Åª¤Ëºï½ü¤·¤Æ¤â¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) quit("¼Â¹ÔÃæ»ß");
+                               msg_print("エラー:古いテンポラリ・ファイルが残っています。");
+                               msg_print("変愚蛮怒を二重に起動していないか確認してください。");
+                               msg_print("過去に変愚蛮怒がクラッシュした場合は一時ファイルを");
+                               msg_print("強制的に削除して実行を続けられます。");
+                               if (!get_check("強制的に削除してもよろしいですか?")) quit("実行中止");
 #else
                                msg_print("Error: There are old temporal files.");
                                msg_print("Make sure you are not running two game processes simultaneously.");
@@ -115,10 +117,10 @@ void init_saved_floors(bool force)
 #endif
 }
 
-
-/*
- * Kill temporal files
- * Should be called just before the game quit.
+/*!
+ * @brief 保存フロア用テンポラリファイルを削除する / Kill temporal files
+ * @details Should be called just before the game quit.
+ * @return なし
  */
 void clear_saved_floor_files(void)
 {
@@ -161,9 +163,10 @@ void clear_saved_floor_files(void)
 #endif
 }
 
-
-/*
- * Get a pointer for an item of the saved_floors array.
+/*!
+ * @brief 保存フロアIDから参照ポインタを得る / Get a pointer for an item of the saved_floors array.
+ * @param floor_id 保存フロアID
+ * @return IDに対応する保存フロアのポインタ、ない場合はNULLを返す。
  */
 saved_floor_type *get_sf_ptr(s16b floor_id)
 {
@@ -184,13 +187,18 @@ saved_floor_type *get_sf_ptr(s16b floor_id)
 }
 
 
-/*
- * kill a saved floor and get an empty space
+/*!
+ * @brief 参照ポインタ先の保存フロアを抹消する / kill a saved floor and get an empty space
+ * @param sf_ptr 保存フロアの参照ポインタ
+ * @return なし
  */
 static void kill_saved_floor(saved_floor_type *sf_ptr)
 {
        char floor_savefile[1024];
 
+       /* Paranoia */
+       if (!sf_ptr) return;
+
        /* Already empty */
        if (!sf_ptr->floor_id) return;
 
@@ -221,13 +229,15 @@ static void kill_saved_floor(saved_floor_type *sf_ptr)
 }
 
 
-/*
- * Initialize new saved floor and get its floor id.  If number of
- * saved floors are already MAX_SAVED_FLOORS, kill the oldest one.
+/*!
+ * @brief 新規に利用可能な保存フロアを返す / Initialize new saved floor and get its floor id.
+ * @return 利用可能な保存フロアID
+ * @details
+ * If number of saved floors are already MAX_SAVED_FLOORS, kill the oldest one.
  */
 s16b get_new_floor_id(void)
 {
-       saved_floor_type *sf_ptr;
+       saved_floor_type *sf_ptr = NULL;
        int i;
 
        /* Look for empty space */
@@ -275,7 +285,8 @@ s16b get_new_floor_id(void)
        sf_ptr->lower_floor_id = 0;
        sf_ptr->visit_mark = latest_visit_mark++;
 
-       /* sf_ptr->dun_level is not yet decided */
+       /* sf_ptr->dun_level may be changed later */
+       sf_ptr->dun_level = dun_level;
 
 
        /* Increment number of floor_id */
@@ -288,17 +299,19 @@ s16b get_new_floor_id(void)
 }
 
 
-/*
- * Prepare mode flags of changing floor
+/*!
+ * @brief フロア切り替え時の処理フラグを追加する / Prepare mode flags of changing floor
+ * @param mode 追加したい所持フラグ
+ * @return なし
  */
 void prepare_change_floor_mode(u32b mode)
 {
        change_floor_mode |= mode;
 }
 
-
-/*
- * Builds the dead end
+/*!
+ * @brief 階段移動先のフロアが生成できない時に簡単な行き止まりマップを作成する / Builds the dead end
+ * @return なし
  */
 static void build_dead_end(void)
 {
@@ -325,20 +338,28 @@ static void build_dead_end(void)
        }
 
        /* Place at center of the floor */
-       py = cur_hgt / 2;
-       px = cur_wid / 2;
+       p_ptr->y = cur_hgt / 2;
+       p_ptr->x = cur_wid / 2;
 
        /* Give one square */
-       place_floor_bold(py, px);
+       place_floor_bold(p_ptr->y, p_ptr->x);
+
+       wipe_generate_cave_flags();
 }
 
 
-/*
- * Preserve_pets
+
+#define MAX_PARTY_MON 21 /*!< フロア移動時に先のフロアに連れて行けるペットの最大数 Maximum number of preservable pets */
+static monster_type party_mon[MAX_PARTY_MON]; /*!< フロア移動に保存するペットモンスターの配列 */
+
+/*!
+ * @brief フロア移動時のペット保存処理 / Preserve_pets
+ * @return なし
  */
 static void preserve_pet(void)
 {
-       int num, i;
+       int num;
+       MONSTER_IDX i;
 
        for (num = 0; num < MAX_PARTY_MON; num++)
        {
@@ -359,7 +380,7 @@ static void preserve_pet(void)
                else
                {
                        /* Preserve the mount */
-                       COPY(&party_mon[0], m_ptr, monster_type);
+                       (void)COPY(&party_mon[0], m_ptr, monster_type);
 
                        /* Delete from this floor */
                        delete_monster_idx(p_ptr->riding);
@@ -386,10 +407,10 @@ static void preserve_pet(void)
                        }
                        else
                        {
-                               int dis = distance(py, px, m_ptr->fy, m_ptr->fx);
+                               int dis = distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx);
 
                                /* Confused (etc.) monsters don't follow. */
-                               if (m_ptr->confused || m_ptr->stunned || m_ptr->csleep) continue;
+                               if (MON_CONFUSED(m_ptr) || MON_STUNNED(m_ptr) || MON_CSLEEP(m_ptr)) continue;
 
                                /* Pet of other pet don't follow. */
                                if (m_ptr->parent_m_idx) continue;
@@ -399,8 +420,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(py, px, m_ptr->fy, m_ptr->fx)) ||
-                                    (los(m_ptr->fy, m_ptr->fx, py, px) && projectable(m_ptr->fy, m_ptr->fx, py, px))))
+                                   ((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))))
                                {
                                        if (dis > 3) continue;
                                }
@@ -410,7 +431,7 @@ static void preserve_pet(void)
                                }
                        }
 
-                       COPY(&party_mon[num], &m_list[i], monster_type);
+                       (void)COPY(&party_mon[num], &m_list[i], monster_type);
 
                        num++;
 
@@ -432,7 +453,7 @@ static void preserve_pet(void)
                        if (p_ptr->riding == i) continue;
 
                        monster_desc(m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
-                       do_cmd_write_nikki(NIKKI_NAMED_PET, 4, m_name);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
                }
        }
 
@@ -447,15 +468,15 @@ static void preserve_pet(void)
                {
                        /* Its parent have gone, it also goes away. */
 
-                       if (m_ptr->ml)
+                       if (is_seen(m_ptr))
                        {
                                char m_name[80];
-                       
+
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
 #ifdef JP
-                               msg_format("%s¤Ï¾Ã¤¨µî¤Ã¤¿¡ª", m_name);
+                               msg_format("%sは消え去った!", m_name);
 #else
                                msg_format("%^s disappears!", m_name);
 #endif
@@ -468,8 +489,10 @@ static void preserve_pet(void)
 }
 
 
-/*
- * Pre-calculate the racial counters of preserved pets
+/*!
+ * @brief フロア移動時にペットを伴った場合の準備処理 / Pre-calculate the racial counters of preserved pets
+ * @return なし
+ * @details
  * To prevent multiple generation of unique monster who is the minion of player
  */
 void precalc_cur_num_of_pet(void)
@@ -490,9 +513,9 @@ void precalc_cur_num_of_pet(void)
        }
 }
 
-
-/*
- * Place preserved pet monsters on new floor
+/*!
+ * @brief 移動先のフロアに伴ったペットを配置する / Place preserved pet monsters on new floor
+ * @return なし
  */
 static void place_pet(void)
 {
@@ -501,7 +524,8 @@ static void place_pet(void)
 
        for (i = 0; i < max_num; i++)
        {
-               int cy, cx, m_idx;
+               POSITION cy = 0, cx = 0;
+               MONSTER_IDX m_idx;
 
                if (!(party_mon[i].r_idx)) continue;
 
@@ -511,19 +535,20 @@ static void place_pet(void)
                        p_ptr->riding = m_idx;
                        if (m_idx)
                        {
-                               cy = py;
-                               cx = px;
+                               cy = p_ptr->y;
+                               cx = p_ptr->x;
                        }
                }
                else
                {
-                       int j, d;
+                       int j;
+                       POSITION d;
 
                        for (d = 1; d < 6; d++)
                        {
                                for (j = 1000; j > 0; j--)
                                {
-                                       scatter(&cy, &cx, py, px, d, 0);
+                                       scatter(&cy, &cx, p_ptr->y, p_ptr->x, d, 0);
                                        if (monster_can_enter(cy, cx, &r_info[party_mon[i].r_idx], 0)) break;
                                }
                                if (j) break;
@@ -547,7 +572,7 @@ static void place_pet(void)
                        m_ptr->fy = cy;
                        m_ptr->fx = cx;
                        m_ptr->ml = TRUE;
-                       m_ptr->csleep = 0;
+                       m_ptr->mtimed[MTIMED_CSLEEP] = 0;
 
                        /* Paranoia */
                        m_ptr->hold_o_idx = 0;
@@ -587,14 +612,14 @@ static void place_pet(void)
 
                        monster_desc(m_name, m_ptr, 0);
 #ifdef JP
-                       msg_format("%s¤È¤Ï¤°¤ì¤Æ¤·¤Þ¤Ã¤¿¡£", m_name);
+                       msg_format("%sとはぐれてしまった。", m_name);
 #else
                        msg_format("You have lost sight of %s.", m_name);
 #endif
                        if (record_named_pet && m_ptr->nickname)
                        {
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                               do_cmd_write_nikki(NIKKI_NAMED_PET, 5, m_name);
+                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name);
                        }
 
                        /* Pre-calculated in precalc_cur_num_of_pet(), but need to decrease */
@@ -602,17 +627,19 @@ static void place_pet(void)
                }
        }
 
-       /* For accuracy of precalc_cur_num_of_pet() */               
-       C_WIPE(party_mon, MAX_PARTY_MON, monster_type);                            
+       /* For accuracy of precalc_cur_num_of_pet() */
+       (void)C_WIPE(party_mon, MAX_PARTY_MON, monster_type);
 }
 
 
-/*
- * Hack -- Update location of unique monsters and artifacts
- *
- * The r_ptr->floor_id and a_ptr->floor_id are not updated correctly
- * while new floor creation since dungeons may be re-created by
- * auto-scum option.
+/*!
+ * @brief ユニークモンスターやアーティファクトの所在フロアを更新する / Hack -- Update location of unique monsters and artifacts
+ * @param cur_floor_id 現在のフロアID
+ * @return なし
+ * @details 
+ * The r_ptr->floor_id and a_ptr->floor_id are not updated correctly\n
+ * 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)
 {
@@ -647,7 +674,7 @@ static void update_unique_artifact(s16b cur_floor_id)
                if (!o_ptr->k_idx) continue;
 
                /* Memorize location of the artifact */
-               if (artifact_p(o_ptr))
+               if (object_is_fixed_artifact(o_ptr))
                {
                        a_info[o_ptr->name1].floor_id = cur_floor_id;
                }
@@ -655,17 +682,17 @@ static void update_unique_artifact(s16b cur_floor_id)
 }
 
 
-/*
- * When a monster is at a place where player will return,
- * Get out of the my way!
+/*!
+ * @brief フロア移動時、プレイヤーの移動先モンスターが既にいた場合ランダムな近隣に移動させる / When a monster is at a place where player will return,
+ * @return なし
  */
 static void get_out_monster(void)
 {
        int tries = 0;
        int dis = 1;
-       int oy = py;
-       int ox = px;
-       int m_idx = cave[oy][ox].m_idx;
+       int oy = p_ptr->y;
+       int ox = p_ptr->x;
+       MONSTER_IDX m_idx = cave[oy][ox].m_idx;
 
        /* Nothing to do if no monster */
        if (!m_idx) return;
@@ -707,12 +734,12 @@ static void get_out_monster(void)
 
                m_ptr = &m_list[m_idx];
 
-               /* Update the new location */
-               cave[ny][nx].m_idx = m_idx;
-
                /* Update the old location */
                cave[oy][ox].m_idx = 0;
 
+               /* Update the new location */
+               cave[ny][nx].m_idx = m_idx;
+
                /* Move the monster */
                m_ptr->fy = ny;
                m_ptr->fx = nx; 
@@ -724,20 +751,16 @@ static void get_out_monster(void)
        }
 }
 
-
-/*
- * Is this feature has special meaning (except floor_id) with c_ptr->special?
+/*!
+ * マス構造体のspecial要素を利用する地形かどうかを判定するマクロ / Is this feature has special meaning (except floor_id) with c_ptr->special?
  */
 #define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL))
 
 
-/*
- * Virtually teleport onto the stairs that is connecting between two
- * floors.
- *
- * Teleport level spell and trap doors will always lead the player to
- * the one of the floors connected by the one of the stairs in the
- * current floor.
+/*!
+ * @brief 新フロアに移動元フロアに繋がる階段を配置する / Virtually teleport onto the stairs that is connecting between two floors.
+ * @param sf_ptr 移動元の保存フロア構造体参照ポインタ
+ * @return なし
  */
 static void locate_connected_stairs(saved_floor_type *sf_ptr)
 {
@@ -810,8 +833,8 @@ static void locate_connected_stairs(saved_floor_type *sf_ptr)
        if (sx)
        {
                /* Already fixed */
-               py = sy;
-               px = sx;
+               p_ptr->y = sy;
+               p_ptr->x = sx;
        }
        else if (!num)
        {
@@ -819,7 +842,7 @@ static void locate_connected_stairs(saved_floor_type *sf_ptr)
                prepare_change_floor_mode(CFM_RAND_PLACE | CFM_NO_RETURN);
 
                /* Mega Hack -- It's not the stairs you enter.  Disable it.  */
-               if (!feat_uses_special(cave[py][px].feat)) cave[py][px].special = 0;
+               if (!feat_uses_special(cave[p_ptr->y][p_ptr->x].feat)) cave[p_ptr->y][p_ptr->x].special = 0;
        }
        else
        {
@@ -827,14 +850,15 @@ static void locate_connected_stairs(saved_floor_type *sf_ptr)
                i = randint0(num);
 
                /* Point stair location */
-               py = y_table[i];
-               px = x_table[i];
+               p_ptr->y = y_table[i];
+               p_ptr->x = x_table[i];
        }
 }
 
-/*
- * Maintain quest monsters, mark next floor_id at stairs, save current
- * floor, and prepare to enter next floor.
+/*!
+ * @brief 現在のフロアを離れるに伴って行なわれる保存処理
+ * / Maintain quest monsters, mark next floor_id at stairs, save current floor, and prepare to enter next floor.
+ * @return なし
  */
 void leave_floor(void)
 {
@@ -842,7 +866,7 @@ void leave_floor(void)
        feature_type *f_ptr;
        saved_floor_type *sf_ptr;
        int quest_r_idx = 0;
-       int i;
+       DUNGEON_IDX i;
 
        /* Preserve pets and prepare to take these to next floor */
        preserve_pet();
@@ -850,6 +874,8 @@ void leave_floor(void)
        /* Remove all mirrors without explosion */
        remove_all_mirrors(FALSE);
 
+       if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
+
        /* New floor is not yet prepared */
        new_floor_id = 0;
 
@@ -860,9 +886,6 @@ void leave_floor(void)
        {
            /* Get temporal floor_id */
            p_ptr->floor_id = get_new_floor_id();
-           
-           /* Record the dungeon level */
-           get_sf_ptr(p_ptr->floor_id)->dun_level = dun_level;
        }
 
 
@@ -912,7 +935,7 @@ void leave_floor(void)
                if (!o_ptr->k_idx) continue;
 
                /* Delete old memorized location of the artifact */
-               if (artifact_p(o_ptr))
+               if (object_is_fixed_artifact(o_ptr))
                {
                        a_info[o_ptr->name1].floor_id = 0;
                }
@@ -931,7 +954,7 @@ void leave_floor(void)
        if (change_floor_mode & CFM_SAVE_FLOORS)
        {
                /* Extract stair position */
-               c_ptr = &cave[py][px];
+               c_ptr = &cave[p_ptr->y][p_ptr->x];
                f_ptr = &f_info[c_ptr->feat];
 
                /* Get back to old saved floor? */
@@ -995,8 +1018,6 @@ void leave_floor(void)
        /* Kill some old saved floors */
        if (!(change_floor_mode & CFM_SAVE_FLOORS))
        {
-               int i;
-
                /* Kill all saved floors */
                for (i = 0; i < MAX_SAVED_FLOORS; i++)
                        kill_saved_floor(&saved_floors[i]);
@@ -1029,9 +1050,6 @@ void leave_floor(void)
                {
                        c_ptr->special = new_floor_id;
                }
-
-               /* Record new dungeon level */
-               get_sf_ptr(new_floor_id)->dun_level = dun_level;
        }
 
        /* Fix connection -- level teleportation or trap door */
@@ -1075,10 +1093,13 @@ void leave_floor(void)
 }
 
 
-/*
- * Enter new floor.  If the floor is an old saved floor, it will be
- * restored from the temporal file.  If the floor is new one, new cave
- * will be generated.
+/*!
+ * @brief フロアの切り替え処理 / Enter new floor.
+ * @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 cave\n
+ * will be generated.\n
  */
 void change_floor(void)
 {
@@ -1135,7 +1156,7 @@ void change_floor(void)
                                /* Forbid return stairs */
                                if (change_floor_mode & CFM_NO_RETURN)
                                {
-                                       cave_type *c_ptr = &cave[py][px];
+                                       cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
 
                                        if (!feat_uses_special(c_ptr->feat))
                                        {
@@ -1176,14 +1197,27 @@ void change_floor(void)
                        }
                }
 
+               /* Break connection to killed floor */
+               else
+               {
+                       if (change_floor_mode & CFM_UP)
+                               sf_ptr->lower_floor_id = 0;
+                       else if (change_floor_mode & CFM_DOWN)
+                               sf_ptr->upper_floor_id = 0;
+               }
+
                /* Maintain monsters and artifacts */
                if (loaded)
                {
-                       int i;
-                       s32b absence_ticks = (turn - sf_ptr->last_visit) / TURNS_PER_TICK;
+                       IDX i;
+                       s32b tmp_last_visit = sf_ptr->last_visit;
+                       s32b absence_ticks;
                        int alloc_chance = d_info[dungeon_type].max_m_alloc_chance;
                        int alloc_times;
 
+                       while (tmp_last_visit > turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
+                       absence_ticks = (turn - tmp_last_visit) / TURNS_PER_TICK;
+
                        /* Maintain monsters */
                        for (i = 1; i < m_max; i++)
                        {
@@ -1198,23 +1232,13 @@ void change_floor(void)
                                        /* Restore HP */
                                        m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
 
-                                       /* Remove fear */
-                                       m_ptr->monfear = 0;
-
-                                       /* Remove invulnerability */
-                                       m_ptr->invulner = 0;
-
-                                       /* Remove fast status */
-                                       m_ptr->fast = 0;
-
-                                       /* Remove slow status */
-                                       m_ptr->slow = 0;
-
-                                       /* Remove stun */
-                                       m_ptr->stunned = 0;
-
-                                       /* Remove confusion */
-                                       m_ptr->confused = 0;
+                                       /* 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);
                                }
 
                                /* Extract real monster race */
@@ -1241,7 +1265,7 @@ void change_floor(void)
                                if (!o_ptr->k_idx) continue;
 
                                /* Ignore non-artifact */
-                               if (!artifact_p(o_ptr)) continue;
+                               if (!object_is_fixed_artifact(o_ptr)) continue;
 
                                /* Appear at a different floor? */
                                if (a_info[o_ptr->name1].floor_id != new_floor_id)
@@ -1256,7 +1280,7 @@ void change_floor(void)
                                }
                        }
 
-                       place_quest_monsters();
+                       (void)place_quest_monsters();
 
                        /* Place some random monsters */
                        alloc_times = absence_ticks / alloc_chance;
@@ -1269,6 +1293,7 @@ void change_floor(void)
                                /* Make a (group of) new monster */
                                (void)alloc_monster(0, 0);
                        }
+
                }
 
                /* New floor_id or failed to restore */
@@ -1278,7 +1303,7 @@ void change_floor(void)
                        {
                                /* Temporal file is broken? */
 #ifdef JP
-                               msg_print("³¬ÃʤϹԤ­»ß¤Þ¤ê¤À¤Ã¤¿¡£");
+                               msg_print("階段は行き止まりだった。");
 #else
                                msg_print("The staircases come to a dead end...");
 #endif
@@ -1312,26 +1337,20 @@ void change_floor(void)
                        if (!(change_floor_mode & CFM_NO_RETURN))
                        {
                                /* Extract stair position */
-                               cave_type *c_ptr = &cave[py][px];
+                               cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
 
                                /*** Create connected stairs ***/
 
                                /* No stairs down from Quest */
                                if ((change_floor_mode & CFM_UP) && !quest_number(dun_level))
                                {
-                                       if (change_floor_mode & CFM_SHAFT)
-                                               c_ptr->feat = FEAT_MORE_MORE;
-                                       else
-                                               c_ptr->feat = FEAT_MORE;
+                                       c_ptr->feat = (change_floor_mode & CFM_SHAFT) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair;
                                }
 
                                /* No stairs up when ironman_downward */
                                else if ((change_floor_mode & CFM_DOWN) && !ironman_downward)
                                {
-                                       if (change_floor_mode & CFM_SHAFT)
-                                               c_ptr->feat = FEAT_LESS_LESS;
-                                       else
-                                               c_ptr->feat = FEAT_LESS;
+                                       c_ptr->feat = (change_floor_mode & CFM_SHAFT) ? feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair;
                                }
 
                                /* Paranoia -- Clear mimic */
@@ -1355,7 +1374,7 @@ void change_floor(void)
                        if (!p_ptr->blind)
                        {
 #ifdef JP
-                               msg_print("ÆÍÁ³³¬Ãʤ¬ºÉ¤¬¤ì¤Æ¤·¤Þ¤Ã¤¿¡£");
+                               msg_print("突然階段が塞がれてしまった。");
 #else
                                msg_print("Suddenly the stairs is blocked!");
 #endif
@@ -1363,7 +1382,7 @@ void change_floor(void)
                        else
                        {
 #ifdef JP
-                               msg_print("¥´¥È¥´¥È¤È²¿¤«²»¤¬¤·¤¿¡£");
+                               msg_print("ゴトゴトと何か音がした。");
 #else
                                msg_print("You hear some noises.");
 #endif
@@ -1384,6 +1403,9 @@ void change_floor(void)
        /* Place preserved pet monsters */
        place_pet();
 
+       /* Reset travel target place */
+       forget_travel_flow();
+
        /* Hack -- maintain unique and artifacts */
        update_unique_artifact(new_floor_id);
 
@@ -1400,15 +1422,20 @@ void change_floor(void)
        /* Remember when this level was "created" */
        old_turn = turn;
 
+       /* No dungeon feeling yet */
+       p_ptr->feeling_turn = old_turn;
+       p_ptr->feeling = 0;
+
        /* Clear all flags */
        change_floor_mode = 0L;
-}
-
 
+       select_floor_music();
+}
 
-/*
- * Create stairs at or move previously created stairs into the player
- * location.
+/*!
+ * @brief プレイヤーの手による能動的な階段生成処理 /
+ * Create stairs at or move previously created stairs into the player location.
+ * @return なし
  */
 void stair_creation(void)
 {
@@ -1433,7 +1460,7 @@ void stair_creation(void)
        {
                /* arena or quest */
 #ifdef JP
-               msg_print("¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡ª");
+               msg_print("効果がありません!");
 #else
                msg_print("There is no effect!");
 #endif
@@ -1441,10 +1468,10 @@ void stair_creation(void)
        }
 
        /* Artifacts resists */
-       if (!cave_valid_bold(py, px))
+       if (!cave_valid_bold(p_ptr->y, p_ptr->x))
        {
 #ifdef JP
-               msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
+               msg_print("床上のアイテムが呪文を跳ね返した。");
 #else
                msg_print("The object resists the spell.");
 #endif
@@ -1453,11 +1480,19 @@ void stair_creation(void)
        }
 
        /* Destroy all objects in the grid */
-       delete_object(py, px);
+       delete_object(p_ptr->y, p_ptr->x);
 
        /* Extract current floor data */
        sf_ptr = get_sf_ptr(p_ptr->floor_id);
 
+       /* Paranoia */
+       if (!sf_ptr)
+       {
+               /* No floor id? -- Create now! */
+               p_ptr->floor_id = get_new_floor_id();
+               sf_ptr = get_sf_ptr(p_ptr->floor_id);
+       } 
+
        /* Choose randomly */
        if (up && down)
        {
@@ -1517,20 +1552,18 @@ void stair_creation(void)
        /* Create a staircase */
        if (up)
        {
-               if (dest_sf_ptr->last_visit && dest_sf_ptr->dun_level <= dun_level - 2)
-                       cave_set_feat(py, px, FEAT_LESS_LESS);
-               else
-                       cave_set_feat(py, px, FEAT_LESS);
+               cave_set_feat(p_ptr->y, p_ptr->x,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= dun_level - 2)) ?
+                       feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
        }
        else
        {
-               if (dest_sf_ptr->last_visit && dest_sf_ptr->dun_level >= dun_level + 2)
-                       cave_set_feat(py, px, FEAT_MORE_MORE);
-               else
-                       cave_set_feat(py, px, FEAT_MORE);
+               cave_set_feat(p_ptr->y, p_ptr->x,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= dun_level + 2)) ?
+                       feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
        }
 
 
        /* Connect this stairs to the destination */
-       cave[py][px].special = dest_floor_id;
+       cave[p_ptr->y][p_ptr->x].special = dest_floor_id;
 }