+/*!
+ * @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)
+{
+ int x, y, sx = 0, sy = 0;
+ int x_table[20];
+ int y_table[20];
+ int num = 0;
+ int i;
+
+ /* Search usable stairs */
+ for (y = 0; y < cur_hgt; y++)
+ {
+ for (x = 0; x < cur_wid; x++)
+ {
+ cave_type *c_ptr = &cave[y][x];
+ feature_type *f_ptr = &f_info[c_ptr->feat];
+ bool ok = FALSE;
+
+ if (change_floor_mode & CFM_UP)
+ {
+ if (have_flag(f_ptr->flags, FF_LESS) && have_flag(f_ptr->flags, FF_STAIRS) &&
+ !have_flag(f_ptr->flags, FF_SPECIAL))
+ {
+ ok = TRUE;
+
+ /* Found fixed stairs? */
+ if (c_ptr->special &&
+ c_ptr->special == sf_ptr->upper_floor_id)
+ {
+ sx = x;
+ sy = y;
+ }
+ }
+ }
+
+ else if (change_floor_mode & CFM_DOWN)
+ {
+ if (have_flag(f_ptr->flags, FF_MORE) && have_flag(f_ptr->flags, FF_STAIRS) &&
+ !have_flag(f_ptr->flags, FF_SPECIAL))
+ {
+ ok = TRUE;
+
+ /* Found fixed stairs */
+ if (c_ptr->special &&
+ c_ptr->special == sf_ptr->lower_floor_id)
+ {
+ sx = x;
+ sy = y;
+ }
+ }
+ }
+
+ else
+ {
+ if (have_flag(f_ptr->flags, FF_BLDG))
+ {
+ ok = TRUE;
+ }
+ }
+
+ if (ok && (num < 20))
+ {
+ x_table[num] = x;
+ y_table[num] = y;
+ num++;
+ }
+ }
+ }
+
+ if (sx)
+ {
+ /* Already fixed */
+ py = sy;
+ px = sx;
+ }
+ else if (!num)
+ {
+ /* No stairs found! -- No return */
+ 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;
+ }
+ else
+ {
+ /* Choose random one */
+ i = randint0(num);
+
+ /* Point stair location */
+ py = y_table[i];
+ px = x_table[i];
+ }
+}
+
+/*!
+ * @brief ¸½ºß¤Î¥Õ¥í¥¢¤òÎ¥¤ì¤ë¤Ëȼ¤Ã¤Æ¹Ô£ùÊݸ½èÍý
+ * / Maintain quest monsters, mark next floor_id at stairs, save current floor, and prepare to enter next floor.
+ * @return ¤Ê¤·