OSDN Git Service

Add Doxygen comment to cmd6.c.
[hengband/hengband.git] / src / floors.c
index 3942ccd..64fd137 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)
 {
@@ -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,9 +229,11 @@ 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)
 {
@@ -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)
 {
@@ -330,17 +343,18 @@ static void build_dead_end(void)
 
        /* Give one square */
        place_floor_bold(py, px);
-}
 
+       wipe_generate_cave_flags();
+}
 
-/* Maximum number of preservable pets */
-#define MAX_PARTY_MON 21
 
-static monster_type party_mon[MAX_PARTY_MON];
 
+#define MAX_PARTY_MON 21 /*!< ¥Õ¥í¥¢°ÜÆ°»þ¤ËÀè¤Î¥Õ¥í¥¢¤ËÏ¢¤ì¤Æ¹Ô¤±¤ë¥Ú¥Ã¥È¤ÎºÇÂç¿ô Maximum number of preservable pets */
+static monster_type party_mon[MAX_PARTY_MON]; /*!< ¥Õ¥í¥¢°ÜÆ°¤ËÊݸ¤¹¤ë¥Ú¥Ã¥È¥â¥ó¥¹¥¿¡¼¤ÎÇÛÎó */
 
-/*
- * Preserve_pets
+/*!
+ * @brief ¥Õ¥í¥¢°ÜÆ°»þ¤Î¥Ú¥Ã¥ÈÊݸ½èÍý / Preserve_pets
+ * @return ¤Ê¤·
  */
 static void preserve_pet(void)
 {
@@ -365,7 +379,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);
@@ -395,7 +409,7 @@ static void preserve_pet(void)
                                int dis = distance(py, px, 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;
@@ -416,7 +430,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++;
 
@@ -438,7 +452,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);
                }
        }
 
@@ -474,8 +488,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)
@@ -496,9 +512,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)
 {
@@ -541,7 +557,6 @@ static void place_pet(void)
                {
                        monster_type *m_ptr = &m_list[m_idx];
                        monster_race *r_ptr;
-                       int cmi;
 
                        cave[cy][cx].m_idx = m_idx;
 
@@ -554,8 +569,7 @@ static void place_pet(void)
                        m_ptr->fy = cy;
                        m_ptr->fx = cx;
                        m_ptr->ml = TRUE;
-                       m_ptr->csleep = 0;
-                       for (cmi = 0; cmi < MAX_MPROC; cmi++) m_ptr->mproc_idx[cmi] = 0;
+                       m_ptr->mtimed[MTIMED_CSLEEP] = 0;
 
                        /* Paranoia */
                        m_ptr->hold_o_idx = 0;
@@ -580,13 +594,6 @@ static void place_pet(void)
                        /* Hack -- Count the number of "reproducers" */
                        if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
 
-                       if (m_ptr->fast) mproc_add(m_idx, MPROC_FAST);
-                       if (m_ptr->slow) mproc_add(m_idx, MPROC_SLOW);
-                       if (m_ptr->stunned) mproc_add(m_idx, MPROC_STUNNED);
-                       if (m_ptr->confused) mproc_add(m_idx, MPROC_CONFUSED);
-                       if (m_ptr->monfear) mproc_add(m_idx, MPROC_MONFEAR);
-                       if (m_ptr->invulner) mproc_add(m_idx, MPROC_INVULNER);
-
                        /* Hack -- Notice new multi-hued monsters */
                        {
                                monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
@@ -609,7 +616,7 @@ static void place_pet(void)
                        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 */
@@ -618,16 +625,18 @@ static void place_pet(void)
        }
 
        /* For accuracy of precalc_cur_num_of_pet() */
-       C_WIPE(party_mon, MAX_PARTY_MON, monster_type);
+       (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)
 {
@@ -670,9 +679,9 @@ 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)
 {
@@ -739,20 +748,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)
 {
@@ -847,9 +852,10 @@ static void locate_connected_stairs(saved_floor_type *sf_ptr)
        }
 }
 
-/*
- * 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)
 {
@@ -877,9 +883,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;
        }
 
 
@@ -1046,9 +1049,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 */
@@ -1092,10 +1092,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)
 {
@@ -1193,14 +1196,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;
+                       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++)
                        {
@@ -1215,47 +1231,13 @@ void change_floor(void)
                                        /* Restore HP */
                                        m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
 
-                                       if (m_ptr->monfear)
-                                       {
-                                               /* Remove fear */
-                                               m_ptr->monfear = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_MONFEAR], MPROC_MONFEAR);
-                                       }
-
-                                       if (m_ptr->invulner)
-                                       {
-                                               /* Remove invulnerability */
-                                               m_ptr->invulner = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_INVULNER], MPROC_INVULNER);
-                                       }
-
-                                       if (m_ptr->fast)
-                                       {
-                                               /* Remove fast status */
-                                               m_ptr->fast = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_FAST], MPROC_FAST);
-                                       }
-
-                                       if (m_ptr->slow)
-                                       {
-                                               /* Remove slow status */
-                                               m_ptr->slow = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_SLOW], MPROC_SLOW);
-                                       }
-
-                                       if (m_ptr->stunned)
-                                       {
-                                               /* Remove stun */
-                                               m_ptr->stunned = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_STUNNED], MPROC_STUNNED);
-                                       }
-
-                                       if (m_ptr->confused)
-                                       {
-                                               /* Remove confusion */
-                                               m_ptr->confused = 0;
-                                               mproc_remove(i, m_ptr->mproc_idx[MPROC_CONFUSED], MPROC_CONFUSED);
-                                       }
+                                       /* 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 */
@@ -1297,7 +1279,7 @@ void change_floor(void)
                                }
                        }
 
-                       place_quest_monsters();
+                       (void)place_quest_monsters();
 
                        /* Place some random monsters */
                        alloc_times = absence_ticks / alloc_chance;
@@ -1360,19 +1342,13 @@ void change_floor(void)
                                /* 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 */
@@ -1425,6 +1401,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);
 
@@ -1449,11 +1428,10 @@ void change_floor(void)
        change_floor_mode = 0L;
 }
 
-
-
-/*
- * 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)
 {
@@ -1503,6 +1481,14 @@ void stair_creation(void)
        /* 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)
        {
@@ -1562,17 +1548,15 @@ 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(py, px,
+                       (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(py, px,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= dun_level + 2)) ?
+                       feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
        }