+
+
+#ifdef TRAVEL
+/*
+ * Test for traveling
+ */
+static int travel_test(int prev_dir)
+{
+ int new_dir = 0;
+ int i, max;
+ const cave_type *c_ptr;
+ int cost;
+
+ /* Cannot travel when blind */
+ if (p_ptr->blind || no_lite())
+ {
+ msg_print(_("Ìܤ¬¸«¤¨¤Ê¤¤¡ª", "You cannot see!"));
+ return (0);
+ }
+
+ /* break run when leaving trap detected region */
+ if ((disturb_trap_detect || alert_trap_detect)
+ && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+ {
+ /* No duplicate warning */
+ p_ptr->dtrap = FALSE;
+
+ /* You are just on the edge */
+ if (!(cave[py][px].info & CAVE_UNSAFE))
+ {
+ if (alert_trap_detect)
+ {
+#ifdef JP
+ msg_print("* Ãí°Õ:¤³¤ÎÀè¤Ï¥È¥é¥Ã¥×¤Î´¶ÃÎÈϰϳ°¤Ç¤¹¡ª *");
+#else
+ msg_print("*Leaving trap detect region!*");
+#endif
+ }
+
+ if (disturb_trap_detect)
+ {
+ /* Break Run */
+ return (0);
+ }
+ }
+ }
+
+ /* Range of newly adjacent grids */
+ max = (prev_dir & 0x01) + 1;
+
+ /* Look at every newly adjacent square. */
+ for (i = -max; i <= max; i++)
+ {
+ /* New direction */
+ int dir = cycle[chome[prev_dir] + i];
+
+ /* New location */
+ int row = py + ddy[dir];
+ int col = px + ddx[dir];
+
+ /* Access grid */
+ c_ptr = &cave[row][col];
+
+ /* Visible monsters abort running */
+ if (c_ptr->m_idx)
+ {
+ monster_type *m_ptr = &m_list[c_ptr->m_idx];
+
+ /* Visible monster */
+ if (m_ptr->ml) return (0);
+ }
+
+ }
+
+ /* Travel cost of current grid */
+ cost = travel.cost[py][px];
+
+ /* Determine travel direction */
+ for (i = 0; i < 8; ++ i) {
+ int dir_cost = travel.cost[py+ddy_ddd[i]][px+ddx_ddd[i]];
+
+ if (dir_cost < cost)
+ {
+ new_dir = ddd[i];
+ cost = dir_cost;
+ }
+ }
+
+ if (!new_dir) return (0);
+
+ /* Access newly move grid */
+ c_ptr = &cave[py+ddy[new_dir]][px+ddx[new_dir]];
+
+ /* Close door abort traveling */
+ if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
+
+ /* Visible and unignorable trap abort tarveling */
+ if (!c_ptr->mimic && !trap_can_be_ignored(c_ptr->feat)) return (0);
+
+ /* Move new grid */
+ return (new_dir);
+}
+
+
+/*
+ * Travel command
+ */
+void travel_step(void)
+{
+ /* Get travel direction */
+ travel.dir = travel_test(travel.dir);
+
+ /* disturb */
+ if (!travel.dir)
+ {
+ if (travel.run == 255)
+ {
+#ifdef JP
+ msg_print("Æ»¶Ú¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡ª");
+#else
+ msg_print("No route is found!");
+#endif
+ }
+ disturb(0, 1);
+ return;
+ }
+
+ energy_use = 100;
+
+ move_player(travel.dir, always_pickup, FALSE);
+
+ if ((py == travel.y) && (px == travel.x))
+ travel.run = 0;
+ else if (travel.run > 0)
+ travel.run--;
+
+ /* Travel Delay */
+ Term_xtra(TERM_XTRA_DELAY, delay_factor);
+}
+#endif