OSDN Git Service

[Refactor] #39963 Separated spells-type.h from spells.h
[hengband/hengband.git] / src / player-move.c
index 25e5cf0..b71ced4 100644 (file)
 #include "angband.h"
 #include "core.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 
-#include "realm-song.h"
-#include "autopick.h"
+#include "realm/realm-song.h"
+#include "autopick/autopick.h"
 #include "dungeon.h"
 #include "floor.h"
 #include "melee.h"
 #include "player-move.h"
 #include "player-status.h"
 #include "player-effects.h"
+#include "player-race.h"
 #include "player-class.h"
+#include "player-inventory.h"
 #include "player-personality.h"
 #include "spells-floor.h"
 #include "feature.h"
 #include "monster-status.h"
 #include "object-hook.h"
 #include "object-flavor.h"
-#include "spells.h"
+#include "spell/spells-type.h"
 #include "cmd-basic.h"
-#include "view-mainwindow.h"
+#include "view/display-main-window.h"
 #include "world.h"
-#include "objectkind.h"
-#include "autopick.h"
+#include "object/object-kind.h"
+#include "autopick/autopick.h"
 #include "targeting.h"
 
-
-#ifdef TRAVEL
- /* for travel */
 travel_type travel;
-#endif
 
 /*!
  * @brief 地形やその上のアイテムの隠された要素を全て明かす /
  * Search for hidden things
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param y 対象となるマスのY座標
  * @param x 対象となるマスのX座標
  * @return なし
  */
-static void discover_hidden_things(POSITION y, POSITION x)
+static void discover_hidden_things(player_type *creature_ptr, POSITION y, POSITION x)
 {
-       OBJECT_IDX this_o_idx, next_o_idx = 0;
        grid_type *g_ptr;
-       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       g_ptr = &floor_ptr->grid_array[y][x];
 
-       /* Invisible trap */
-       if (g_ptr->mimic && is_trap(g_ptr->feat))
+       if (g_ptr->mimic && is_trap(creature_ptr, g_ptr->feat))
        {
-               disclose_grid(p_ptr->current_floor_ptr, y, x);
+               disclose_grid(creature_ptr, y, x);
                msg_print(_("トラップを発見した。", "You have found a trap."));
-               disturb(p_ptr, FALSE, TRUE);
+               disturb(creature_ptr, FALSE, TRUE);
        }
 
-       /* Secret door */
-       if (is_hidden_door(g_ptr))
+       if (is_hidden_door(creature_ptr, g_ptr))
        {
                msg_print(_("隠しドアを発見した。", "You have found a secret door."));
-               disclose_grid(p_ptr->current_floor_ptr, y, x);
-               disturb(p_ptr, FALSE, FALSE);
+               disclose_grid(creature_ptr, y, x);
+               disturb(creature_ptr, FALSE, FALSE);
        }
 
        /* Scan all objects in the grid */
-       for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+       OBJECT_IDX next_o_idx = 0;
+       for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-               o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
+               o_ptr = &floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
                if (o_ptr->tval != TV_CHEST) continue;
                if (!chest_traps[o_ptr->pval]) continue;
@@ -220,34 +219,33 @@ static void discover_hidden_things(POSITION y, POSITION x)
                {
                        msg_print(_("箱に仕掛けられたトラップを発見した!", "You have discovered a trap on the chest!"));
                        object_known(o_ptr);
-                       disturb(p_ptr, FALSE, FALSE);
+                       disturb(creature_ptr, FALSE, FALSE);
                }
        }
 }
 
+
 /*!
  * @brief プレイヤーの探索処理判定
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 void search(player_type *creature_ptr)
 {
-       DIRECTION i;
-       PERCENTAGE chance;
-
        /* Start with base search ability */
-       chance = creature_ptr->skill_srh;
+       PERCENTAGE chance = creature_ptr->skill_srh;
 
        /* Penalize various conditions */
        if (creature_ptr->blind || no_lite(creature_ptr)) chance = chance / 10;
        if (creature_ptr->confused || creature_ptr->image) chance = chance / 10;
 
        /* Search the nearby grids, which are always in bounds */
-       for (i = 0; i < 9; ++ i)
+       for (DIRECTION i = 0; i < 9; ++ i)
        {
                /* Sometimes, notice things */
                if (randint0(100) < chance)
                {
-                       discover_hidden_things(creature_ptr->y + ddy_ddd[i], creature_ptr->x + ddx_ddd[i]);
+                       discover_hidden_things(creature_ptr, creature_ptr->y + ddy_ddd[i], creature_ptr->x + ddx_ddd[i]);
                }
        }
 }
@@ -256,6 +254,7 @@ void search(player_type *creature_ptr)
 /*!
  * @brief プレイヤーがオブジェクトを拾った際のメッセージ表示処理 /
  * Helper routine for py_pickup() and py_pickup_floor().
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param o_idx 取得したオブジェクトの参照ID
  * @return なし
  * @details
@@ -269,8 +268,6 @@ void search(player_type *creature_ptr)
  */
 void py_pickup_aux(player_type *owner_ptr, OBJECT_IDX o_idx)
 {
-       INVENTORY_IDX slot;
-
 #ifdef JP
        GAME_TEXT o_name[MAX_NLEN];
        GAME_TEXT old_name[MAX_NLEN];
@@ -281,34 +278,34 @@ void py_pickup_aux(player_type *owner_ptr, OBJECT_IDX o_idx)
 #endif
 
        object_type *o_ptr;
-
        o_ptr = &owner_ptr->current_floor_ptr->o_list[o_idx];
 
 #ifdef JP
-       object_desc(old_name, o_ptr, OD_NAME_ONLY);
+       object_desc(owner_ptr, old_name, o_ptr, OD_NAME_ONLY);
        object_desc_kosuu(kazu_str, o_ptr);
        hirottakazu = o_ptr->number;
 #endif
+
        /* Carry the object */
-       slot = inven_carry(owner_ptr, o_ptr);
+       INVENTORY_IDX slot = inven_carry(owner_ptr, o_ptr);
 
        /* Get the object again */
        o_ptr = &owner_ptr->inventory_list[slot];
 
-       delete_object_idx(o_idx);
+       delete_object_idx(owner_ptr, o_idx);
 
        if (owner_ptr->pseikaku == SEIKAKU_MUNCHKIN)
        {
                bool old_known = identify_item(owner_ptr, o_ptr);
 
                /* Auto-inscription/destroy */
-               autopick_alter_item(slot, (bool)(destroy_identify && !old_known));
+               autopick_alter_item(owner_ptr, slot, (bool)(destroy_identify && !old_known));
 
                /* If it is destroyed, don't pick it up */
                if (o_ptr->marked & OM_AUTODESTROY) return;
        }
 
-       object_desc(o_name, o_ptr, 0);
+       object_desc(owner_ptr, o_name, o_ptr, 0);
 
 #ifdef JP
        if ((o_ptr->name1 == ART_CRIMSON) && (owner_ptr->pseikaku == SEIKAKU_COMBAT))
@@ -333,45 +330,40 @@ void py_pickup_aux(player_type *owner_ptr, OBJECT_IDX o_idx)
                        }
                }
        }
+
        strcpy(record_o_name, old_name);
 #else
        msg_format("You have %s (%c).", o_name, index_to_label(slot));
        strcpy(record_o_name, o_name);
 #endif
        record_turn = current_world_ptr->game_turn;
-
-
-       check_find_art_quest_completion(o_ptr);
+       check_find_art_quest_completion(owner_ptr, o_ptr);
 }
 
 
 /*!
  * @brief プレイヤーがオブジェクト上に乗った際の表示処理
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param pickup 自動拾い処理を行うならばTRUEとする
  * @return なし
  * @details
  * Player "wants" to pick up an object or gold.
  * Note that we ONLY handle things that can be picked up.
- * See "move_player(p_ptr, )" for handling of other things.
+ * See "move_player(creature_ptr, )" for handling of other things.
  */
 void carry(player_type *creature_ptr, bool pickup)
 {
-       grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
-
-       OBJECT_IDX this_o_idx, next_o_idx = 0;
-
-       GAME_TEXT o_name[MAX_NLEN];
-
        /* Recenter the map around the player */
-       verify_panel();
+       verify_panel(creature_ptr);
 
        creature_ptr->update |= (PU_MONSTERS);
        creature_ptr->redraw |= (PR_MAP);
        creature_ptr->window |= (PW_OVERHEAD);
-       handle_stuff();
+       handle_stuff(creature_ptr);
 
        /* Automatically pickup/destroy/inscribe items */
-       autopick_pickup_items(g_ptr);
+       grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
+       autopick_pickup_items(creature_ptr, g_ptr);
 
        if (easy_floor)
        {
@@ -380,88 +372,62 @@ void carry(player_type *creature_ptr, bool pickup)
        }
 
        /* Scan the pile of objects */
-       for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+       OBJECT_IDX next_o_idx = 0;
+       for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
                o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
-
-#ifdef ALLOW_EASY_SENSE /* TNB */
-
-               /* Option: Make item sensing easy */
-               if (easy_sense)
-               {
-                       /* Sense the object */
-                       (void)sense_object(o_ptr);
-               }
-
-#endif /* ALLOW_EASY_SENSE -- TNB */
-
-               object_desc(o_name, o_ptr, 0);
+               GAME_TEXT o_name[MAX_NLEN];
+               object_desc(creature_ptr, o_name, o_ptr, 0);
                next_o_idx = o_ptr->next_o_idx;
 
                disturb(creature_ptr, FALSE, FALSE);
 
-               /* Pick up gold */
                if (o_ptr->tval == TV_GOLD)
                {
                        int value = (long)o_ptr->pval;
-
-                       /* Delete the gold */
-                       delete_object_idx(this_o_idx);
-
+                       delete_object_idx(creature_ptr, this_o_idx);
                        msg_format(_(" $%ld の価値がある%sを見つけた。", "You collect %ld gold pieces worth of %s."),
                           (long)value, o_name);
 
                        sound(SOUND_SELL);
 
-                       /* Collect the gold */
                        creature_ptr->au += value;
-
-                       /* Redraw gold */
                        creature_ptr->redraw |= (PR_GOLD);
                        creature_ptr->window |= (PW_PLAYER);
+                       continue;
                }
 
-               /* Pick up objects */
-               else
+               /* Hack - some objects were handled in autopick_pickup_items(). */
+               if (o_ptr->marked & OM_NOMSG)
                {
-                       /* Hack - some objects were handled in autopick_pickup_items(). */
-                       if (o_ptr->marked & OM_NOMSG)
-                       {
-                               /* Clear the flag. */
-                               o_ptr->marked &= ~OM_NOMSG;
-                       }
-                       else if (!pickup)
-                       {
-                               msg_format(_("%sがある。", "You see %s."), o_name);
-                       }
-
-                       /* Note that the pack is too full */
-                       else if (!inven_carry_okay(o_ptr))
-                       {
-                               msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
-                       }
-
-                       /* Pick up the item (if requested and allowed) */
-                       else
-                       {
-                               int okay = TRUE;
+                       o_ptr->marked &= ~OM_NOMSG;
+                       continue;
+               }
+               
+               if (!pickup)
+               {
+                       msg_format(_("%sがある。", "You see %s."), o_name);
+                       continue;
+               }
+               
+               if (!inven_carry_okay(o_ptr))
+               {
+                       msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
+                       continue;
+               }
 
-                               /* Hack -- query every item */
-                               if (carry_query_flag)
-                               {
-                                       char out_val[MAX_NLEN+20];
-                                       sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
-                                       okay = get_check(out_val);
-                               }
+               int is_pickup_successful = TRUE;
+               if (carry_query_flag)
+               {
+                       char out_val[MAX_NLEN + 20];
+                       sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
+                       is_pickup_successful = get_check(out_val);
+               }
 
-                               /* Attempt to pick up an object. */
-                               if (okay)
-                               {
-                                       /* Pick up the object */
-                                       py_pickup_aux(creature_ptr, this_o_idx);
-                               }
-                       }
+               if (is_pickup_successful)
+               {
+                       py_pickup_aux(creature_ptr, this_o_idx);
                }
        }
 }
@@ -469,6 +435,7 @@ void carry(player_type *creature_ptr, bool pickup)
 
 /*!
  * @brief パターンによる移動制限処理
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param c_y プレイヤーの移動元Y座標
  * @param c_x プレイヤーの移動元X座標
  * @param n_y プレイヤーの移動先Y座標
@@ -477,16 +444,15 @@ void carry(player_type *creature_ptr, bool pickup)
  */
 bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION n_y, POSITION n_x)
 {
-       feature_type *cur_f_ptr = &f_info[p_ptr->current_floor_ptr->grid_array[c_y][c_x].feat];
-       feature_type *new_f_ptr = &f_info[p_ptr->current_floor_ptr->grid_array[n_y][n_x].feat];
+       feature_type *cur_f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[c_y][c_x].feat];
+       feature_type *new_f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[n_y][n_x].feat];
        bool is_pattern_tile_cur = have_flag(cur_f_ptr->flags, FF_PATTERN);
        bool is_pattern_tile_new = have_flag(new_f_ptr->flags, FF_PATTERN);
-       int pattern_type_cur, pattern_type_new;
 
        if (!is_pattern_tile_cur && !is_pattern_tile_new) return TRUE;
 
-       pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->subtype : NOT_PATTERN_TILE;
-       pattern_type_new = is_pattern_tile_new ? new_f_ptr->subtype : NOT_PATTERN_TILE;
+       int pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->subtype : NOT_PATTERN_TILE;
+       int pattern_type_new = is_pattern_tile_new ? new_f_ptr->subtype : NOT_PATTERN_TILE;
 
        if (pattern_type_new == PATTERN_TILE_START)
        {
@@ -501,7 +467,8 @@ bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION
                else
                        return TRUE;
        }
-       else if ((pattern_type_new == PATTERN_TILE_OLD) ||
+       
+       if ((pattern_type_new == PATTERN_TILE_OLD) ||
                 (pattern_type_new == PATTERN_TILE_END) ||
                 (pattern_type_new == PATTERN_TILE_WRECKED))
        {
@@ -517,12 +484,14 @@ bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION
                        return FALSE;
                }
        }
-       else if ((pattern_type_new == PATTERN_TILE_TELEPORT) ||
+       
+       if ((pattern_type_new == PATTERN_TILE_TELEPORT) ||
                 (pattern_type_cur == PATTERN_TILE_TELEPORT))
        {
                return TRUE;
        }
-       else if (pattern_type_cur == PATTERN_TILE_START)
+       
+       if (pattern_type_cur == PATTERN_TILE_START)
        {
                if (is_pattern_tile_new)
                        return TRUE;
@@ -532,7 +501,8 @@ bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION
                        return FALSE;
                }
        }
-       else if ((pattern_type_cur == PATTERN_TILE_OLD) ||
+       
+       if ((pattern_type_cur == PATTERN_TILE_OLD) ||
                 (pattern_type_cur == PATTERN_TILE_END) ||
                 (pattern_type_cur == PATTERN_TILE_WRECKED))
        {
@@ -546,56 +516,50 @@ bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION
                        return TRUE;
                }
        }
-       else
+       
+       if (!is_pattern_tile_cur)
        {
-               if (!is_pattern_tile_cur)
-               {
-                       msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
-                                               "You must start walking the Pattern from the startpoint."));
+               msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
+                       "You must start walking the Pattern from the startpoint."));
 
-                       return FALSE;
-               }
-               else
-               {
-                       byte ok_move = PATTERN_TILE_START;
-                       switch (pattern_type_cur)
-                       {
-                               case PATTERN_TILE_1:
-                                       ok_move = PATTERN_TILE_2;
-                                       break;
-                               case PATTERN_TILE_2:
-                                       ok_move = PATTERN_TILE_3;
-                                       break;
-                               case PATTERN_TILE_3:
-                                       ok_move = PATTERN_TILE_4;
-                                       break;
-                               case PATTERN_TILE_4:
-                                       ok_move = PATTERN_TILE_1;
-                                       break;
-                               default:
-                                       if (current_world_ptr->wizard)
-                                               msg_format(_("おかしなパターン歩行、%d。", "Funny Pattern walking, %d."), pattern_type_cur);
-
-                                       return TRUE; /* Goof-up */
-                       }
+               return FALSE;
+       }
+       
+       byte ok_move = PATTERN_TILE_START;
+       switch (pattern_type_cur)
+       {
+       case PATTERN_TILE_1:
+               ok_move = PATTERN_TILE_2;
+               break;
+       case PATTERN_TILE_2:
+               ok_move = PATTERN_TILE_3;
+               break;
+       case PATTERN_TILE_3:
+               ok_move = PATTERN_TILE_4;
+               break;
+       case PATTERN_TILE_4:
+               ok_move = PATTERN_TILE_1;
+               break;
+       default:
+               if (current_world_ptr->wizard)
+                       msg_format(_("おかしなパターン歩行、%d。", "Funny Pattern walking, %d."), pattern_type_cur);
+               return TRUE;
+       }
 
-                       if ((pattern_type_new == ok_move) || (pattern_type_new == pattern_type_cur))
-                               return TRUE;
-                       else
-                       {
-                               if (!is_pattern_tile_new)
-                                       msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
-                               else
-                                       msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
+       if ((pattern_type_new == ok_move) || (pattern_type_new == pattern_type_cur)) return TRUE;
+       
+       if (!is_pattern_tile_new)
+               msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
+       else
+               msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
 
-                               return FALSE;
-                       }
-               }
-       }
+       return FALSE;
 }
 
+
 /*!
  * @brief 移動に伴うプレイヤーのステータス変化処理
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param ny 移動先Y座標
  * @param nx 移動先X座標
  * @param mpe_mode 移動オプションフラグ
@@ -605,8 +569,9 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
 {
        POSITION oy = creature_ptr->y;
        POSITION ox = creature_ptr->x;
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[ny][nx];
-       grid_type *oc_ptr = &p_ptr->current_floor_ptr->grid_array[oy][ox];
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
+       grid_type *oc_ptr = &floor_ptr->grid_array[oy][ox];
        feature_type *f_ptr = &f_info[g_ptr->feat];
        feature_type *of_ptr = &f_info[oc_ptr->feat];
 
@@ -627,7 +592,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
 
                        if (om_idx > 0) /* Monster on old spot (or creature_ptr->riding) */
                        {
-                               monster_type *om_ptr = &p_ptr->current_floor_ptr->m_list[om_idx];
+                               monster_type *om_ptr = &floor_ptr->m_list[om_idx];
                                om_ptr->fy = ny;
                                om_ptr->fx = nx;
                                update_monster(creature_ptr, om_idx, TRUE);
@@ -635,22 +600,22 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
 
                        if (nm_idx > 0) /* Monster on new spot */
                        {
-                               monster_type *nm_ptr = &p_ptr->current_floor_ptr->m_list[nm_idx];
+                               monster_type *nm_ptr = &floor_ptr->m_list[nm_idx];
                                nm_ptr->fy = oy;
                                nm_ptr->fx = ox;
                                update_monster(creature_ptr, nm_idx, TRUE);
                        }
                }
 
-               lite_spot(oy, ox);
-               lite_spot(ny, nx);
+               lite_spot(creature_ptr, oy, ox);
+               lite_spot(creature_ptr, ny, nx);
 
                /* Check for new panel (redraw map) */
-               verify_panel();
+               verify_panel(creature_ptr);
 
                if (mpe_mode & MPE_FORGET_FLOW)
                {
-                       forget_flow(creature_ptr->current_floor_ptr);
+                       forget_flow(floor_ptr);
 
                        creature_ptr->update |= (PU_UN_VIEW);
                        creature_ptr->redraw |= (PR_MAP);
@@ -660,11 +625,11 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
                creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 
                /* Remove "unsafe" flag */
-               if ((!creature_ptr->blind && !no_lite(creature_ptr)) || !is_trap(g_ptr->feat)) g_ptr->info &= ~(CAVE_UNSAFE);
+               if ((!creature_ptr->blind && !no_lite(creature_ptr)) || !is_trap(creature_ptr, g_ptr->feat)) g_ptr->info &= ~(CAVE_UNSAFE);
 
                /* For get everything when requested hehe I'm *NASTY* */
-               if (p_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_FORGET)) wiz_dark(creature_ptr);
-               if (mpe_mode & MPE_HANDLE_STUFF) handle_stuff();
+               if (floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_FORGET)) wiz_dark(creature_ptr);
+               if (mpe_mode & MPE_HANDLE_STUFF) handle_stuff(creature_ptr);
 
                if (creature_ptr->pclass == CLASS_NINJA)
                {
@@ -721,7 +686,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
        /* Handle "store doors" */
        if (have_flag(f_ptr->flags, FF_STORE))
        {
-               disturb(p_ptr, FALSE, TRUE);
+               disturb(creature_ptr, FALSE, TRUE);
 
                free_turn(creature_ptr);
                /* Hack -- Enter store */
@@ -731,7 +696,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
        /* Handle "building doors" -KMW- */
        else if (have_flag(f_ptr->flags, FF_BLDG))
        {
-               disturb(p_ptr, FALSE, TRUE);
+               disturb(creature_ptr, FALSE, TRUE);
 
                free_turn(creature_ptr);
                /* Hack -- Enter building */
@@ -741,7 +706,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
        /* Handle quest areas -KMW- */
        else if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
        {
-               disturb(p_ptr, FALSE, TRUE);
+               disturb(creature_ptr, FALSE, TRUE);
 
                free_turn(creature_ptr);
                /* Hack -- Enter quest level */
@@ -750,15 +715,15 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
 
        else if (have_flag(f_ptr->flags, FF_QUEST_EXIT))
        {
-               if (quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
+               if (quest[floor_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
                {
-                       complete_quest(creature_ptr->current_floor_ptr->inside_quest);
+                       complete_quest(creature_ptrfloor_ptr->inside_quest);
                }
 
                leave_quest_check(creature_ptr);
 
-               creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
-               p_ptr->current_floor_ptr->dun_level = 0;
+               floor_ptr->inside_quest = g_ptr->special;
+               floor_ptr->dun_level = 0;
                creature_ptr->oldpx = 0;
                creature_ptr->oldpy = 0;
 
@@ -768,7 +733,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
        /* Set off a trap */
        else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
        {
-               disturb(p_ptr, FALSE, TRUE);
+               disturb(creature_ptr, FALSE, TRUE);
 
                /* Hidden trap */
                if (g_ptr->mimic || have_flag(f_ptr->flags, FF_SECRET))
@@ -776,7 +741,7 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
                        msg_print(_("トラップだ!", "You found a trap!"));
 
                        /* Pick a trap */
-                       disclose_grid(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x);
+                       disclose_grid(creature_ptr, creature_ptr->y, creature_ptr->x);
                }
 
                /* Hit the trap */
@@ -800,15 +765,17 @@ bool move_player_effect(player_type *creature_ptr, POSITION ny, POSITION nx, BIT
                                msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
                        }
 
-                       if (disturb_trap_detect) disturb(p_ptr, FALSE, TRUE);
+                       if (disturb_trap_detect) disturb(creature_ptr, FALSE, TRUE);
                }
        }
 
        return player_bold(creature_ptr, ny, nx) && !creature_ptr->is_dead && !creature_ptr->leaving;
 }
 
+
 /*!
  * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param feat 地形ID
  * @return トラップが自動的に無効ならばTRUEを返す
  */
@@ -854,18 +821,28 @@ bool trap_can_be_ignored(player_type *creature_ptr, FEAT_IDX feat)
 
 
 /*
+ * todo 負論理なので反転させたい
  * Determine if a "boundary" grid is "floor mimic"
+ * @param grid_type *g_ptr
+ * @param feature_type *f_ptr
+ * @param feature_type  *mimic_f_ptr
+ * @return 移動不能であればTRUE
  */
-#define boundary_floor(C, F, MF) \
-       ((C)->mimic && permanent_wall(F) && \
-        (have_flag((MF)->flags, FF_MOVE) || have_flag((MF)->flags, FF_CAN_FLY)) && \
-        have_flag((MF)->flags, FF_PROJECT) && \
-        !have_flag((MF)->flags, FF_OPEN))
+bool boundary_floor(grid_type *g_ptr, feature_type *f_ptr, feature_type *mimic_f_ptr)
+{
+       bool is_boundary_floor = g_ptr->mimic > 0;
+       is_boundary_floor &= permanent_wall(f_ptr);
+       is_boundary_floor &= have_flag((mimic_f_ptr)->flags, FF_MOVE) || have_flag((mimic_f_ptr)->flags, FF_CAN_FLY);
+       is_boundary_floor &= have_flag((mimic_f_ptr)->flags, FF_PROJECT);
+       is_boundary_floor &= !have_flag((mimic_f_ptr)->flags, FF_OPEN);
+       return is_boundary_floor;
+}
 
 
 /*!
  * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す /
  * Move player in the given direction, with the given "pickup" flag.
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param dir 移動方向ID
  * @param do_pickup 罠解除を試みながらの移動ならばTRUE
  * @param break_trap トラップ粉砕処理を行うならばTRUE
@@ -879,31 +856,16 @@ bool trap_can_be_ignored(player_type *creature_ptr, FEAT_IDX feat)
  */
 void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool break_trap)
 {
-       /* Find the result of moving */
        POSITION y = creature_ptr->y + ddy[dir];
        POSITION x = creature_ptr->x + ddx[dir];
 
-       /* Examine the destination */
-       grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
-
-       feature_type *f_ptr = &f_info[g_ptr->feat];
-
-       monster_type *m_ptr;
-
-       monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
-       monster_race *riding_r_ptr = &r_info[creature_ptr->riding ? riding_m_ptr->r_idx : 0];
-
-       GAME_TEXT m_name[MAX_NLEN];
-
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       grid_type *g_ptr = &floor_ptr->grid_array[y][x];
        bool p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
-       bool p_can_kill_walls = FALSE;
        bool stormbringer = FALSE;
 
-       bool oktomove = TRUE;
-       bool do_past = FALSE;
-
        /* Exit the area */
-       if (!creature_ptr->current_floor_ptr->dun_level && !creature_ptr->wild_mode &&
+       if (!floor_ptr->dun_level && !creature_ptr->wild_mode &&
                ((x == 0) || (x == MAX_WID - 1) ||
                 (y == 0) || (y == MAX_HGT - 1)))
        {
@@ -915,8 +877,8 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        {
                                creature_ptr->wilderness_y--;
                                creature_ptr->wilderness_x--;
-                               creature_ptr->oldpy = creature_ptr->current_floor_ptr->height - 2;
-                               creature_ptr->oldpx = creature_ptr->current_floor_ptr->width - 2;
+                               creature_ptr->oldpy = floor_ptr->height - 2;
+                               creature_ptr->oldpx = floor_ptr->width - 2;
                                creature_ptr->ambush_flag = FALSE;
                        }
 
@@ -924,7 +886,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        {
                                creature_ptr->wilderness_y--;
                                creature_ptr->wilderness_x++;
-                               creature_ptr->oldpy = creature_ptr->current_floor_ptr->height - 2;
+                               creature_ptr->oldpy = floor_ptr->height - 2;
                                creature_ptr->oldpx = 1;
                                creature_ptr->ambush_flag = FALSE;
                        }
@@ -934,7 +896,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                                creature_ptr->wilderness_y++;
                                creature_ptr->wilderness_x--;
                                creature_ptr->oldpy = 1;
-                               creature_ptr->oldpx = creature_ptr->current_floor_ptr->width - 2;
+                               creature_ptr->oldpx = floor_ptr->width - 2;
                                creature_ptr->ambush_flag = FALSE;
                        }
 
@@ -950,7 +912,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        else if (y == 0)
                        {
                                creature_ptr->wilderness_y--;
-                               creature_ptr->oldpy = creature_ptr->current_floor_ptr->height - 2;
+                               creature_ptr->oldpy = floor_ptr->height - 2;
                                creature_ptr->oldpx = x;
                                creature_ptr->ambush_flag = FALSE;
                        }
@@ -966,7 +928,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        else if (x == 0)
                        {
                                creature_ptr->wilderness_x--;
-                               creature_ptr->oldpx = creature_ptr->current_floor_ptr->width - 2;
+                               creature_ptr->oldpx = floor_ptr->width - 2;
                                creature_ptr->oldpy = y;
                                creature_ptr->ambush_flag = FALSE;
                        }
@@ -990,18 +952,23 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                p_can_enter = FALSE;
        }
 
-       m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+       monster_type *m_ptr;
+       m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
 
        if (creature_ptr->inventory_list[INVEN_RARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
        if (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
 
        /* Player can not walk through "walls"... */
        /* unless in Shadow Form */
-       p_can_kill_walls = creature_ptr->kill_wall && have_flag(f_ptr->flags, FF_HURT_DISI) &&
+       feature_type *f_ptr = &f_info[g_ptr->feat];
+       bool p_can_kill_walls = creature_ptr->kill_wall && have_flag(f_ptr->flags, FF_HURT_DISI) &&
                (!p_can_enter || !have_flag(f_ptr->flags, FF_LOS)) &&
                !have_flag(f_ptr->flags, FF_PERMANENT);
 
        /* Hack -- attack monsters */
+       GAME_TEXT m_name[MAX_NLEN];
+       bool can_move = TRUE;
+       bool do_past = FALSE;
        if (g_ptr->m_idx && (m_ptr->ml || p_can_enter || p_can_kill_walls))
        {
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -1013,24 +980,24 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                    pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x) && (p_can_enter || p_can_kill_walls))
                {
                        /* Disturb the monster */
-                       (void)set_monster_csleep(g_ptr->m_idx, 0);
+                       (void)set_monster_csleep(creature_ptr, g_ptr->m_idx, 0);
 
-                       monster_desc(m_name, m_ptr, 0);
+                       monster_desc(creature_ptr, m_name, m_ptr, 0);
 
                        if (m_ptr->ml)
                        {
                                /* Auto-Recall if possible and visible */
-                               if (!creature_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                               health_track(g_ptr->m_idx);
+                               if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
+                               health_track(creature_ptr, g_ptr->m_idx);
                        }
 
                        /* displace? */
                        if ((stormbringer && (randint1(1000) > 666)) || (creature_ptr->pclass == CLASS_BERSERKER))
                        {
                                py_attack(creature_ptr, y, x, 0);
-                               oktomove = FALSE;
+                               can_move = FALSE;
                        }
-                       else if (monster_can_cross_terrain(creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat, r_ptr, 0))
+                       else if (monster_can_cross_terrain(creature_ptrfloor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat, r_ptr, 0))
                        {
                                do_past = TRUE;
                        }
@@ -1038,7 +1005,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        {
                                msg_format(_("%^sが邪魔だ!", "%^s is in your way!"), m_name);
                                free_turn(creature_ptr);
-                               oktomove = FALSE;
+                               can_move = FALSE;
                        }
 
                        /* now continue on to 'movement' */
@@ -1046,30 +1013,32 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                else
                {
                        py_attack(creature_ptr, y, x, 0);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                }
        }
 
-       if (oktomove && creature_ptr->riding)
+       monster_type *riding_m_ptr = &floor_ptr->m_list[creature_ptr->riding];
+       monster_race *riding_r_ptr = &r_info[creature_ptr->riding ? riding_m_ptr->r_idx : 0];
+       if (can_move && creature_ptr->riding)
        {
                if (riding_r_ptr->flags1 & RF1_NEVER_MOVE)
                {
                        msg_print(_("動けない!", "Can't move!"));
                        free_turn(creature_ptr);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
                else if (MON_MONFEAR(riding_m_ptr))
                {
                        GAME_TEXT steed_name[MAX_NLEN];
-                       monster_desc(steed_name, riding_m_ptr, 0);
+                       monster_desc(creature_ptr, steed_name, riding_m_ptr, 0);
                        msg_format(_("%sが恐怖していて制御できない。", "%^s is too scared to control."), steed_name);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
                else if (creature_ptr->riding_ryoute)
                {
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
                else if (have_flag(f_ptr->flags, FF_CAN_FLY) && (riding_r_ptr->flags7 & RF7_CAN_FLY))
@@ -1086,35 +1055,35 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                {
                        msg_format(_("%sの上に行けない。", "Can't swim."), f_name + f_info[get_feat_mimic(g_ptr)].name);
                        free_turn(creature_ptr);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
                else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
                {
-                       msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name);
+                       msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name);
                        free_turn(creature_ptr);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
                else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
                {
                        msg_format(_("%sの上に行けない。", "Too hot to go through."), f_name + f_info[get_feat_mimic(g_ptr)].name);
                        free_turn(creature_ptr);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
 
-               if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
+               if (can_move && MON_STUNNED(riding_m_ptr) && one_in_(2))
                {
                        GAME_TEXT steed_name[MAX_NLEN];
-                       monster_desc(steed_name, riding_m_ptr, 0);
+                       monster_desc(creature_ptr, steed_name, riding_m_ptr, 0);
                        msg_format(_("%sが朦朧としていてうまく動けない!", "You cannot control stunned %s!"), steed_name);
-                       oktomove = FALSE;
+                       can_move = FALSE;
                        disturb(creature_ptr, FALSE, TRUE);
                }
        }
 
-       if (!oktomove)
+       if (!can_move)
        {
        }
 
@@ -1123,7 +1092,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                msg_format(_("空を飛ばないと%sの上には行けない。", "You need to fly to go through the %s."), f_name + f_info[get_feat_mimic(g_ptr)].name);
                free_turn(creature_ptr);
                creature_ptr->running = 0;
-               oktomove = FALSE;
+               can_move = FALSE;
        }
 
        /*
@@ -1136,7 +1105,6 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                if ((creature_ptr->pclass != CLASS_RANGER) && !creature_ptr->levitation && (!creature_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) creature_ptr->energy_use *= 2;
        }
 
-
        /* Disarm a visible trap */
        else if ((do_pickup != easy_disarm) && have_flag(f_ptr->flags, FF_DISARM) && !g_ptr->mimic)
        {
@@ -1147,7 +1115,6 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                }
        }
 
-
        /* Player can not walk through "walls" unless in wraith form...*/
        else if (!p_can_enter && !p_can_kill_walls)
        {
@@ -1156,7 +1123,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                feature_type *mimic_f_ptr = &f_info[feat];
                concptr name = f_name + mimic_f_ptr->name;
 
-               oktomove = FALSE;
+               can_move = FALSE;
 
                /* Notice things in the dark */
                if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(creature_ptr, y, x))
@@ -1178,7 +1145,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
 #endif
 
                                g_ptr->info |= (CAVE_MARK);
-                               lite_spot(y, x);
+                               lite_spot(creature_ptr, y, x);
                        }
                }
 
@@ -1197,7 +1164,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        else
                        {
                                /* Closed doors */
-                               if (easy_open && is_closed_door(feat) && easy_open_door(creature_ptr, y, x)) return;
+                               if (easy_open && is_closed_door(creature_ptr, feat) && easy_open_door(creature_ptr, y, x)) return;
 
 #ifdef JP
                                msg_format("%sが行く手をはばんでいる。", name);
@@ -1222,7 +1189,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
        }
 
        /* Normal movement */
-       if (oktomove && !pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x))
+       if (can_move && !pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x))
        {
                if (!(creature_ptr->confused || creature_ptr->stun || creature_ptr->image))
                {
@@ -1232,54 +1199,49 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                /* To avoid a loop with running */
                disturb(creature_ptr, FALSE, TRUE);
 
-               oktomove = FALSE;
+               can_move = FALSE;
        }
 
-       /* Normal movement */
-       if (oktomove)
-       {
-               u32b mpe_mode = MPE_ENERGY_USE;
+       if (!can_move) return;
 
-               if (creature_ptr->warning)
-               {
-                       if (!process_warning(creature_ptr, x, y))
-                       {
-                               creature_ptr->energy_use = 25;
-                               return;
-                       }
-               }
-
-               if (do_past)
+       if (creature_ptr->warning)
+       {
+               if (!process_warning(creature_ptr, x, y))
                {
-                       msg_format(_("%sを押し退けた。", "You push past %s."), m_name);
+                       creature_ptr->energy_use = 25;
+                       return;
                }
+       }
 
-               /* Change oldpx and oldpy to place the player well when going back to big mode */
-               if (creature_ptr->wild_mode)
-               {
-                       if (ddy[dir] > 0)  creature_ptr->oldpy = 1;
-                       if (ddy[dir] < 0)  creature_ptr->oldpy = MAX_HGT - 2;
-                       if (ddy[dir] == 0) creature_ptr->oldpy = MAX_HGT / 2;
-                       if (ddx[dir] > 0)  creature_ptr->oldpx = 1;
-                       if (ddx[dir] < 0)  creature_ptr->oldpx = MAX_WID - 2;
-                       if (ddx[dir] == 0) creature_ptr->oldpx = MAX_WID / 2;
-               }
+       if (do_past)
+       {
+               msg_format(_("%sを押し退けた。", "You push past %s."), m_name);
+       }
 
-               if (p_can_kill_walls)
-               {
-                       cave_alter_feat(y, x, FF_HURT_DISI);
+       /* Change oldpx and oldpy to place the player well when going back to big mode */
+       if (creature_ptr->wild_mode)
+       {
+               if (ddy[dir] > 0)  creature_ptr->oldpy = 1;
+               if (ddy[dir] < 0)  creature_ptr->oldpy = MAX_HGT - 2;
+               if (ddy[dir] == 0) creature_ptr->oldpy = MAX_HGT / 2;
+               if (ddx[dir] > 0)  creature_ptr->oldpx = 1;
+               if (ddx[dir] < 0)  creature_ptr->oldpx = MAX_WID - 2;
+               if (ddx[dir] == 0) creature_ptr->oldpx = MAX_WID / 2;
+       }
 
-                       /* Update some things -- similar to GF_KILL_WALL */
-                       creature_ptr->update |= (PU_FLOW);
-               }
+       if (p_can_kill_walls)
+       {
+               cave_alter_feat(creature_ptr, y, x, FF_HURT_DISI);
 
-               /* sound(SOUND_WALK); */
+               /* Update some things -- similar to GF_KILL_WALL */
+               creature_ptr->update |= (PU_FLOW);
+       }
 
-               if (do_pickup != always_pickup) mpe_mode |= MPE_DO_PICKUP;
-               if (break_trap) mpe_mode |= MPE_BREAK_TRAP;
+       u32b mpe_mode = MPE_ENERGY_USE;
+       if (do_pickup != always_pickup) mpe_mode |= MPE_DO_PICKUP;
+       if (break_trap) mpe_mode |= MPE_BREAK_TRAP;
 
-               (void)move_player_effect(creature_ptr, y, x, mpe_mode);
-       }
+       (void)move_player_effect(creature_ptr, y, x, mpe_mode);
 }
 
 
@@ -1288,43 +1250,43 @@ static bool ignore_avoid_run;
 /*!
  * @brief ダッシュ移動処理中、移動先のマスが既知の壁かどうかを判定する /
  * Hack -- Check for a "known wall" (see below)
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param dir 想定する移動方向ID
  * @param y 移動元のY座標
  * @param x 移動元のX座標
  * @return 移動先が既知の壁ならばTRUE
  */
-static bool see_wall(DIRECTION dir, POSITION y, POSITION x)
+static bool see_wall(player_type *creature_ptr, DIRECTION dir, POSITION y, POSITION x)
 {
-       grid_type *g_ptr;
-
        /* Get the new location */
        y += ddy[dir];
        x += ddx[dir];
 
        /* Illegal grids are not known walls */
-       if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) return (FALSE);
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (!in_bounds2(floor_ptr, y, x)) return FALSE;
 
-       /* Access grid */
-       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       grid_type *g_ptr;
+       g_ptr = &floor_ptr->grid_array[y][x];
 
        /* Must be known to the player */
-       if (g_ptr->info & (CAVE_MARK))
-       {
-               /* Feature code (applying "mimic" field) */
-               s16b         feat = get_feat_mimic(g_ptr);
-               feature_type *f_ptr = &f_info[feat];
+       if (!(g_ptr->info & CAVE_MARK)) return FALSE;
 
-               /* Wall grids are known walls */
-               if (!player_can_enter(p_ptr, feat, 0)) return !have_flag(f_ptr->flags, FF_DOOR);
+       /* Feature code (applying "mimic" field) */
+       s16b feat = get_feat_mimic(g_ptr);
+       feature_type *f_ptr = &f_info[feat];
 
-               /* Don't run on a tree unless explicitly requested */
-               if (have_flag(f_ptr->flags, FF_AVOID_RUN) && !ignore_avoid_run)
-                       return TRUE;
+       /* Wall grids are known walls */
+       if (!player_can_enter(creature_ptr, feat, 0))
+               return !have_flag(f_ptr->flags, FF_DOOR);
 
-               /* Don't run in a wall */
-               if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
-                       return !have_flag(f_ptr->flags, FF_DOOR);
-       }
+       /* Don't run on a tree unless explicitly requested */
+       if (have_flag(f_ptr->flags, FF_AVOID_RUN) && !ignore_avoid_run)
+               return TRUE;
+
+       /* Don't run in a wall */
+       if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
+               return !have_flag(f_ptr->flags, FF_DOOR);
 
        return FALSE;
 }
@@ -1333,28 +1295,30 @@ static bool see_wall(DIRECTION dir, POSITION y, POSITION x)
 /*!
  * @brief ダッシュ移動処理中、移動先のマスか未知の地形かどうかを判定する /
  * Hack -- Check for an "unknown corner" (see below)
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param dir 想定する移動方向ID
  * @param y 移動元のY座標
  * @param x 移動元のX座標
  * @return 移動先が未知の地形ならばTRUE
  */
-static bool see_nothing(DIRECTION dir, POSITION y, POSITION x)
+static bool see_nothing(player_type *creature_ptr, DIRECTION dir, POSITION y, POSITION x)
 {
        /* Get the new location */
        y += ddy[dir];
        x += ddx[dir];
 
        /* Illegal grids are unknown */
-       if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) return (TRUE);
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (!in_bounds2(floor_ptr, y, x)) return TRUE;
 
        /* Memorized grids are always known */
-       if (p_ptr->current_floor_ptr->grid_array[y][x].info & (CAVE_MARK)) return (FALSE);
+       if (floor_ptr->grid_array[y][x].info & (CAVE_MARK)) return FALSE;
 
        /* Viewable door/wall grids are known */
-       if (player_can_see_bold(p_ptr, y, x)) return (FALSE);
+       if (player_can_see_bold(creature_ptr, y, x)) return FALSE;
 
        /* Default */
-       return (TRUE);
+       return TRUE;
 }
 
 
@@ -1392,6 +1356,7 @@ static bool find_breakleft;
 /*!
  * @brief ダッシュ処理の導入 /
  * Initialize the running algorithm for a new direction.
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param dir 導入の移動先
  * @details
  * Diagonal Corridor -- allow diaginal entry into corridors.\n
@@ -1405,11 +1370,8 @@ static bool find_breakleft;
  *       \#x\#                  \@x\#\n
  *       \@\@p.                  p\n
  */
-static void run_init(DIRECTION dir)
+static void run_init(player_type *creature_ptr, DIRECTION dir)
 {
-       int row, col, deepleft, deepright;
-       int i, shortleft, shortright;
-
        /* Save the direction */
        find_current = dir;
 
@@ -1423,76 +1385,78 @@ static void run_init(DIRECTION dir)
        find_breakright = find_breakleft = FALSE;
 
        /* Assume no nearby walls */
-       deepleft = deepright = FALSE;
-       shortright = shortleft = FALSE;
+       bool deepleft = FALSE;
+       bool deepright = FALSE;
+       bool shortright = FALSE;
+       bool shortleft = FALSE;
 
-       p_ptr->run_py = p_ptr->y;
-       p_ptr->run_px = p_ptr->x;
+       creature_ptr->run_py = creature_ptr->y;
+       creature_ptr->run_px = creature_ptr->x;
 
        /* Find the destination grid */
-       row = p_ptr->y + ddy[dir];
-       col = p_ptr->x + ddx[dir];
+       int row = creature_ptr->y + ddy[dir];
+       int col = creature_ptr->x + ddx[dir];
 
-       ignore_avoid_run = cave_have_flag_bold(p_ptr->current_floor_ptr, row, col, FF_AVOID_RUN);
+       ignore_avoid_run = cave_have_flag_bold(creature_ptr->current_floor_ptr, row, col, FF_AVOID_RUN);
 
        /* Extract cycle index */
-       i = chome[dir];
+       int i = chome[dir];
 
        /* Check for walls */
-       if (see_wall(cycle[i+1], p_ptr->y, p_ptr->x))
+       if (see_wall(creature_ptr, cycle[i+1], creature_ptr->y, creature_ptr->x))
        {
                find_breakleft = TRUE;
                shortleft = TRUE;
        }
-       else if (see_wall(cycle[i+1], row, col))
+       else if (see_wall(creature_ptr, cycle[i+1], row, col))
        {
                find_breakleft = TRUE;
                deepleft = TRUE;
        }
 
        /* Check for walls */
-       if (see_wall(cycle[i-1], p_ptr->y, p_ptr->x))
+       if (see_wall(creature_ptr, cycle[i-1], creature_ptr->y, creature_ptr->x))
        {
                find_breakright = TRUE;
                shortright = TRUE;
        }
-       else if (see_wall(cycle[i-1], row, col))
+       else if (see_wall(creature_ptr, cycle[i-1], row, col))
        {
                find_breakright = TRUE;
                deepright = TRUE;
        }
 
        /* Looking for a break */
-       if (find_breakleft && find_breakright)
-       {
-               /* Not looking for open area */
-               find_openarea = FALSE;
+       if (!find_breakleft || !find_breakright) return;
 
-               /* Hack -- allow angled corridor entry */
-               if (dir & 0x01)
+       /* Not looking for open area */
+       find_openarea = FALSE;
+
+       /* Hack -- allow angled corridor entry */
+       if (dir & 0x01)
+       {
+               if (deepleft && !deepright)
                {
-                       if (deepleft && !deepright)
-                       {
-                               find_prevdir = cycle[i - 1];
-                       }
-                       else if (deepright && !deepleft)
-                       {
-                               find_prevdir = cycle[i + 1];
-                       }
+                       find_prevdir = cycle[i - 1];
                }
-
-               /* Hack -- allow blunt corridor entry */
-               else if (see_wall(cycle[i], row, col))
+               else if (deepright && !deepleft)
                {
-                       if (shortleft && !shortright)
-                       {
-                               find_prevdir = cycle[i - 2];
-                       }
-                       else if (shortright && !shortleft)
-                       {
-                               find_prevdir = cycle[i + 2];
-                       }
+                       find_prevdir = cycle[i + 1];
                }
+
+               return;
+       }
+
+       /* Hack -- allow blunt corridor entry */
+       if (!see_wall(creature_ptr, cycle[i], row, col)) return;
+
+       if (shortleft && !shortright)
+       {
+               find_prevdir = cycle[i - 2];
+       }
+       else if (shortright && !shortleft)
+       {
+               find_prevdir = cycle[i + 2];
        }
 }
 
@@ -1500,36 +1464,28 @@ static void run_init(DIRECTION dir)
 /*!
  * @brief ダッシュ移動が継続できるかどうかの判定 /
  * Update the current "run" path
- * @return
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 立ち止まるべき条件が満たされたらTRUE
  * ダッシュ移動が継続できるならばTRUEを返す。
  * Return TRUE if the running should be stopped
  */
-static bool run_test(void)
+static bool run_test(player_type *creature_ptr)
 {
-       DIRECTION prev_dir, new_dir, check_dir = 0;
-       int row, col;
-       int i, max, inv;
-       int option = 0, option2 = 0;
-       grid_type *g_ptr;
-       FEAT_IDX feat;
-       feature_type *f_ptr;
-
-       /* Where we came from */
-       prev_dir = find_prevdir;
-
+       DIRECTION prev_dir = find_prevdir;
 
        /* Range of newly adjacent grids */
-       max = (prev_dir & 0x01) + 1;
+       int max = (prev_dir & 0x01) + 1;
 
        /* break run when leaving trap detected region */
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        if ((disturb_trap_detect || alert_trap_detect)
-           && p_ptr->dtrap && !(p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_IN_DETECT))
+           && creature_ptr->dtrap && !(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_IN_DETECT))
        {
                /* No duplicate warning */
-               p_ptr->dtrap = FALSE;
+               creature_ptr->dtrap = FALSE;
 
                /* You are just on the edge */
-               if (!(p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
+               if (!(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_UNSAFE))
                {
                        if (alert_trap_detect)
                        {
@@ -1539,52 +1495,55 @@ static bool run_test(void)
                        if (disturb_trap_detect)
                        {
                                /* Break Run */
-                               return(TRUE);
+                               return TRUE;
                        }
                }
        }
 
        /* Look at every newly adjacent square. */
-       for (i = -max; i <= max; i++)
+       DIRECTION check_dir = 0;
+       int option = 0, option2 = 0;
+       for (int i = -max; i <= max; i++)
        {
                OBJECT_IDX this_o_idx, next_o_idx = 0;
 
                /* New direction */
-               new_dir = cycle[chome[prev_dir] + i];
+               DIRECTION new_dir = cycle[chome[prev_dir] + i];
 
                /* New location */
-               row = p_ptr->y + ddy[new_dir];
-               col = p_ptr->x + ddx[new_dir];
+               int row = creature_ptr->y + ddy[new_dir];
+               int col = creature_ptr->x + ddx[new_dir];
 
-               /* Access grid */
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[row][col];
+               grid_type *g_ptr;
+               g_ptr = &floor_ptr->grid_array[row][col];
 
                /* Feature code (applying "mimic" field) */
-               feat = get_feat_mimic(g_ptr);
+               FEAT_IDX feat = get_feat_mimic(g_ptr);
+               feature_type *f_ptr;
                f_ptr = &f_info[feat];
 
                /* Visible monsters abort running */
                if (g_ptr->m_idx)
                {
-                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+                       monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
 
                        /* Visible monster */
-                       if (m_ptr->ml) return (TRUE);
+                       if (m_ptr->ml) return TRUE;
                }
 
                /* Visible objects abort running */
                for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                {
                        object_type *o_ptr;
-                       o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
+                       o_ptr = &floor_ptr->o_list[this_o_idx];
                        next_o_idx = o_ptr->next_o_idx;
 
                        /* Visible object */
-                       if (o_ptr->marked & OM_FOUND) return (TRUE);
+                       if (o_ptr->marked & OM_FOUND) return TRUE;
                }
 
                /* Assume unknown */
-               inv = TRUE;
+               bool inv = TRUE;
 
                /* Check memorized grids */
                if (g_ptr->info & (CAVE_MARK))
@@ -1608,7 +1567,7 @@ static bool run_test(void)
                                }
 
                                /* Lava */
-                               else if (have_flag(f_ptr->flags, FF_LAVA) && (p_ptr->immune_fire || IS_INVULN(p_ptr)))
+                               else if (have_flag(f_ptr->flags, FF_LAVA) && (creature_ptr->immune_fire || IS_INVULN(creature_ptr)))
                                {
                                        /* Ignore */
                                        notice = FALSE;
@@ -1616,7 +1575,7 @@ static bool run_test(void)
 
                                /* Deep water */
                                else if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
-                                        (p_ptr->levitation || p_ptr->can_swim || (p_ptr->total_weight <= weight_limit(p_ptr))))
+                                        (creature_ptr->levitation || creature_ptr->can_swim || (creature_ptr->total_weight <= weight_limit(creature_ptr))))
                                {
                                        /* Ignore */
                                        notice = FALSE;
@@ -1624,57 +1583,14 @@ static bool run_test(void)
                        }
 
                        /* Interesting feature */
-                       if (notice) return (TRUE);
+                       if (notice) return TRUE;
 
                        /* The grid is "visible" */
                        inv = FALSE;
                }
 
                /* Analyze unknown grids and floors considering mimic */
-               if (inv || !see_wall(0, row, col))
-               {
-                       /* Looking for open area */
-                       if (find_openarea)
-                       {
-                               /* Nothing */
-                       }
-
-                       /* The first new direction. */
-                       else if (!option)
-                       {
-                               option = new_dir;
-                       }
-
-                       /* Three new directions. Stop running. */
-                       else if (option2)
-                       {
-                               return (TRUE);
-                       }
-
-                       /* Two non-adjacent new directions.  Stop running. */
-                       else if (option != cycle[chome[prev_dir] + i - 1])
-                       {
-                               return (TRUE);
-                       }
-
-                       /* Two new (adjacent) directions (case 1) */
-                       else if (new_dir & 0x01)
-                       {
-                               check_dir = cycle[chome[prev_dir] + i - 2];
-                               option2 = new_dir;
-                       }
-
-                       /* Two new (adjacent) directions (case 2) */
-                       else
-                       {
-                               check_dir = cycle[chome[prev_dir] + i + 1];
-                               option2 = option;
-                               option = new_dir;
-                       }
-               }
-
-               /* Obstacle, while looking for open area */
-               else
+               if (!inv && see_wall(creature_ptr, 0, row, col))
                {
                        if (find_openarea)
                        {
@@ -1690,22 +1606,59 @@ static bool run_test(void)
                                        find_breakleft = TRUE;
                                }
                        }
+
+                       continue;
+               }
+
+               /* Looking for open area */
+               if (find_openarea) continue;
+
+               /* The first new direction. */
+               if (!option)
+               {
+                       option = new_dir;
+                       continue;
                }
+
+               /* Three new directions. Stop running. */
+               if (option2)
+               {
+                       return TRUE;
+               }
+
+               /* Two non-adjacent new directions.  Stop running. */
+               if (option != cycle[chome[prev_dir] + i - 1])
+               {
+                       return TRUE;
+               }
+
+               /* Two new (adjacent) directions (case 1) */
+               if (new_dir & 0x01)
+               {
+                       check_dir = cycle[chome[prev_dir] + i - 2];
+                       option2 = new_dir;
+                       continue;
+               }
+
+               /* Two new (adjacent) directions (case 2) */
+               check_dir = cycle[chome[prev_dir] + i + 1];
+               option2 = option;
+               option = new_dir;
        }
 
        /* Looking for open area */
        if (find_openarea)
        {
                /* Hack -- look again */
-               for (i = -max; i < 0; i++)
+               for (int i = -max; i < 0; i++)
                {
                        /* Unknown grid or non-wall */
-                       if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
+                       if (!see_wall(creature_ptr, cycle[chome[prev_dir] + i], creature_ptr->y, creature_ptr->x))
                        {
                                /* Looking to break right */
                                if (find_breakright)
                                {
-                                       return (TRUE);
+                                       return TRUE;
                                }
                        }
 
@@ -1715,21 +1668,21 @@ static bool run_test(void)
                                /* Looking to break left */
                                if (find_breakleft)
                                {
-                                       return (TRUE);
+                                       return TRUE;
                                }
                        }
                }
 
                /* Hack -- look again */
-               for (i = max; i > 0; i--)
+               for (int i = max; i > 0; i--)
                {
                        /* Unknown grid or non-wall */
-                       if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
+                       if (!see_wall(creature_ptr, cycle[chome[prev_dir] + i], creature_ptr->y, creature_ptr->x))
                        {
                                /* Looking to break left */
                                if (find_breakleft)
                                {
-                                       return (TRUE);
+                                       return TRUE;
                                }
                        }
 
@@ -1739,105 +1692,84 @@ static bool run_test(void)
                                /* Looking to break right */
                                if (find_breakright)
                                {
-                                       return (TRUE);
+                                       return TRUE;
                                }
                        }
                }
+
+               return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
        }
 
-       /* Not looking for open area */
-       else
+       /* No options */
+       if (!option)
        {
-               /* No options */
-               if (!option)
-               {
-                       return (TRUE);
-               }
+               return TRUE;
+       }
 
-               /* One option */
-               else if (!option2)
-               {
-                       /* Primary option */
-                       find_current = option;
+       /* One option */
+       if (!option2)
+       {
+               find_current = option;
+               find_prevdir = option;
+               return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
+       }
 
-                       /* No other options */
-                       find_prevdir = option;
-               }
+       /* Two options, examining corners */
+       else if (!find_cut)
+       {
+               find_current = option;
+               find_prevdir = option2;
+               return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
+       }
+
+       /* Two options, pick one */
+       /* Get next location */
+       int row = creature_ptr->y + ddy[option];
+       int col = creature_ptr->x + ddx[option];
 
-               /* Two options, examining corners */
-               else if (!find_cut)
+       /* Don't see that it is closed off. */
+       /* This could be a potential corner or an intersection. */
+       if (!see_wall(creature_ptr, option, row, col) ||
+               !see_wall(creature_ptr, check_dir, row, col))
+       {
+               /* Can not see anything ahead and in the direction we */
+               /* are turning, assume that it is a potential corner. */
+               if (see_nothing(creature_ptr, option, row, col) &&
+                       see_nothing(creature_ptr, option2, row, col))
                {
-                       /* Primary option */
                        find_current = option;
-
-                       /* Hack -- allow curving */
                        find_prevdir = option2;
+                       return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
                }
 
-               /* Two options, pick one */
-               else
-               {
-                       /* Get next location */
-                       row = p_ptr->y + ddy[option];
-                       col = p_ptr->x + ddx[option];
-
-                       /* Don't see that it is closed off. */
-                       /* This could be a potential corner or an intersection. */
-                       if (!see_wall(option, row, col) ||
-                           !see_wall(check_dir, row, col))
-                       {
-                               /* Can not see anything ahead and in the direction we */
-                               /* are turning, assume that it is a potential corner. */
-                               if (see_nothing(option, row, col) &&
-                                   see_nothing(option2, row, col))
-                               {
-                                       find_current = option;
-                                       find_prevdir = option2;
-                               }
-
-                               /* STOP: we are next to an intersection or a room */
-                               else
-                               {
-                                       return (TRUE);
-                               }
-                       }
-
-                       /* This corner is seen to be enclosed; we cut the corner. */
-                       else if (find_cut)
-                       {
-                               find_current = option2;
-                               find_prevdir = option2;
-                       }
-
-                       /* This corner is seen to be enclosed, and we */
-                       /* deliberately go the long way. */
-                       else
-                       {
-                               find_current = option;
-                               find_prevdir = option2;
-                       }
-               }
+               /* STOP: we are next to an intersection or a room */
+               return TRUE;
        }
 
-       /* About to hit a known wall, stop */
-       if (see_wall(find_current, p_ptr->y, p_ptr->x))
+       /* This corner is seen to be enclosed; we cut the corner. */
+       if (find_cut)
        {
-               return (TRUE);
+               find_current = option2;
+               find_prevdir = option2;
+               return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
        }
 
-       /* Failure */
-       return (FALSE);
+       /* This corner is seen to be enclosed, and we */
+       /* deliberately go the long way. */
+       find_current = option;
+       find_prevdir = option2;
+       return see_wall(creature_ptr, find_current, creature_ptr->y, creature_ptr->x);
 }
 
 
-
 /*!
  * @brief 継続的なダッシュ処理 /
  * Take one step along the current "run" path
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param dir 移動を試みる方向ID
  * @return なし
  */
-void run_step(DIRECTION dir)
+void run_step(player_type *creature_ptr, DIRECTION dir)
 {
        /* Start running */
        if (dir)
@@ -1846,81 +1778,76 @@ void run_step(DIRECTION dir)
                ignore_avoid_run = TRUE;
 
                /* Hack -- do not start silly run */
-               if (see_wall(dir, p_ptr->y, p_ptr->x))
+               if (see_wall(creature_ptr, dir, creature_ptr->y, creature_ptr->x))
                {
                        sound(SOUND_HITWALL);
 
                        msg_print(_("その方向には走れません。", "You cannot run in that direction."));
 
-                       disturb(p_ptr, FALSE, FALSE);
+                       disturb(creature_ptr, FALSE, FALSE);
 
                        return;
                }
 
-               run_init(dir);
+               run_init(creature_ptr, dir);
        }
 
        /* Keep running */
        else
        {
                /* Update run */
-               if (run_test())
+               if (run_test(creature_ptr))
                {
-                       disturb(p_ptr, FALSE, FALSE);
+                       disturb(creature_ptr, FALSE, FALSE);
 
                        return;
                }
        }
 
        /* Decrease the run counter */
-       if (--p_ptr->running <= 0) return;
+       if (--creature_ptr->running <= 0) return;
 
        /* Take time */
-       take_turn(p_ptr, 100);
+       take_turn(creature_ptr, 100);
 
        /* Move the player, using the "pickup" flag */
-       move_player(p_ptr, find_current, FALSE, FALSE);
+       move_player(creature_ptr, find_current, FALSE, FALSE);
 
-       if (player_bold(p_ptr, p_ptr->run_py, p_ptr->run_px))
+       if (player_bold(creature_ptr, creature_ptr->run_py, creature_ptr->run_px))
        {
-               p_ptr->run_py = 0;
-               p_ptr->run_px = 0;
-               disturb(p_ptr, FALSE, FALSE);
+               creature_ptr->run_py = 0;
+               creature_ptr->run_px = 0;
+               disturb(creature_ptr, FALSE, FALSE);
        }
 }
 
 
-#ifdef TRAVEL
-
 /*!
  * @brief トラベル機能の判定処理 /
  * Test for traveling
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param prev_dir 前回移動を行った元の方角ID
  * @return 次の方向
  */
-static DIRECTION travel_test(DIRECTION prev_dir)
+static DIRECTION travel_test(player_type *creature_ptr, DIRECTION prev_dir)
 {
-       DIRECTION new_dir = 0;
-       int i, max;
-       const grid_type *g_ptr;
-       int cost;
-
        /* Cannot travel when blind */
-       if (p_ptr->blind || no_lite(p_ptr))
+       if (creature_ptr->blind || no_lite(creature_ptr))
        {
                msg_print(_("目が見えない!", "You cannot see!"));
-               return (0);
+               return 0;
        }
 
        /* break run when leaving trap detected region */
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        if ((disturb_trap_detect || alert_trap_detect)
-           && p_ptr->dtrap && !(p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_IN_DETECT))
+           && creature_ptr->dtrap && !(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_IN_DETECT))
        {
                /* No duplicate warning */
-               p_ptr->dtrap = FALSE;
+               creature_ptr->dtrap = FALSE;
 
                /* You are just on the edge */
-               if (!(p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
+               if (!(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_UNSAFE))
                {
                        if (alert_trap_detect)
                        {
@@ -1930,44 +1857,46 @@ static DIRECTION travel_test(DIRECTION prev_dir)
                        if (disturb_trap_detect)
                        {
                                /* Break Run */
-                               return (0);
+                               return 0;
                        }
                }
        }
 
        /* Range of newly adjacent grids */
-       max = (prev_dir & 0x01) + 1;
+       int max = (prev_dir & 0x01) + 1;
 
        /* Look at every newly adjacent square. */
-       for (i = -max; i <= max; i++)
+       const grid_type *g_ptr;
+       for (int i = -max; i <= max; i++)
        {
                /* New direction */
                DIRECTION dir = cycle[chome[prev_dir] + i];
 
                /* New location */
-               POSITION row = p_ptr->y + ddy[dir];
-               POSITION col = p_ptr->x + ddx[dir];
+               POSITION row = creature_ptr->y + ddy[dir];
+               POSITION col = creature_ptr->x + ddx[dir];
 
-               /* Access grid */
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[row][col];
+               g_ptr = &floor_ptr->grid_array[row][col];
 
                /* Visible monsters abort running */
                if (g_ptr->m_idx)
                {
-                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+                       monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
 
                        /* Visible monster */
-                       if (m_ptr->ml) return (0);
+                       if (m_ptr->ml) return 0;
                }
 
        }
 
        /* Travel cost of current grid */
-       cost = travel.cost[p_ptr->y][p_ptr->x];
+       int cost = travel.cost[creature_ptr->y][creature_ptr->x];
 
        /* Determine travel direction */
-       for (i = 0; i < 8; ++ i) {
-               int dir_cost = travel.cost[p_ptr->y+ddy_ddd[i]][p_ptr->x+ddx_ddd[i]];
+       DIRECTION new_dir = 0;
+       for (int i = 0; i < 8; ++ i)
+       {
+               int dir_cost = travel.cost[creature_ptr->y+ddy_ddd[i]][creature_ptr->x+ddx_ddd[i]];
 
                if (dir_cost < cost)
                {
@@ -1976,31 +1905,32 @@ static DIRECTION travel_test(DIRECTION prev_dir)
                }
        }
 
-       if (!new_dir) return (0);
+       if (!new_dir) return 0;
 
        /* Access newly move grid */
-       g_ptr = &p_ptr->current_floor_ptr->grid_array[p_ptr->y+ddy[new_dir]][p_ptr->x+ddx[new_dir]];
+       g_ptr = &floor_ptr->grid_array[creature_ptr->y+ddy[new_dir]][creature_ptr->x+ddx[new_dir]];
 
        /* Close door abort traveling */
-       if (!easy_open && is_closed_door(g_ptr->feat)) return (0);
+       if (!easy_open && is_closed_door(creature_ptr, g_ptr->feat)) return 0;
 
        /* Visible and unignorable trap abort tarveling */
-       if (!g_ptr->mimic && !trap_can_be_ignored(p_ptr, g_ptr->feat)) return (0);
+       if (!g_ptr->mimic && !trap_can_be_ignored(creature_ptr, g_ptr->feat)) return 0;
 
        /* Move new grid */
-       return (new_dir);
+       return new_dir;
 }
 
 
 /*!
  * @brief トラベル機能の実装 /
  * Travel command
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 void travel_step(player_type *creature_ptr)
 {
        /* Get travel direction */
-       travel.dir = travel_test(travel.dir);
+       travel.dir = travel_test(creature_ptr, travel.dir);
 
        if (!travel.dir)
        {
@@ -2009,6 +1939,7 @@ void travel_step(player_type *creature_ptr)
                        msg_print(_("道筋が見つかりません!", "No route is found!"));
                        travel.y = travel.x = 0;
                }
+
                disturb(creature_ptr, FALSE, TRUE);
                return;
        }
@@ -2023,18 +1954,15 @@ void travel_step(player_type *creature_ptr)
                travel.y = travel.x = 0;
        }
        else if (travel.run > 0)
+       {
                travel.run--;
+       }
 
        /* Travel Delay */
        Term_xtra(TERM_XTRA_DELAY, delay_factor);
 }
-#endif
 
 
-#ifdef TRAVEL
-/*
- * Hack: travel command
- */
 #define TRAVEL_UNABLE 9999
 
 static int flow_head = 0;
@@ -2044,35 +1972,36 @@ static POSITION temp2_y[MAX_SHORT];
 
 /*!
  * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 void forget_travel_flow(floor_type *floor_ptr)
 {
-       POSITION x, y;
        /* Check the entire dungeon / Forget the old data */
-       for (y = 0; y < floor_ptr->height; y++)
+       for (POSITION y = 0; y < floor_ptr->height; y++)
        {
-               for (x = 0; x < floor_ptr->width; x++)
+               for (POSITION x = 0; x < floor_ptr->width; x++)
                {
-
                        travel.cost[y][x] = MAX_SHORT;
                }
        }
+
        travel.y = travel.x = 0;
 }
 
+
 /*!
  * @brief トラベル処理中に地形に応じた移動コスト基準を返す
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param y 該当地点のY座標
  * @param x 該当地点のX座標
  * @return コスト値
  */
 static int travel_flow_cost(player_type *creature_ptr, POSITION y, POSITION x)
 {
-       feature_type *f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[y][x].feat];
-       int cost = 1;
-
        /* Avoid obstacles (ex. trees) */
+       int cost = 1;
+       feature_type *f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[y][x].feat];
        if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
 
        /* Water */
@@ -2099,48 +2028,48 @@ static int travel_flow_cost(player_type *creature_ptr, POSITION y, POSITION x)
                if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
        }
 
-       return (cost);
+       return cost;
 }
 
+
 /*!
  * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param y 目標地点のY座標
  * @param x 目標地点のX座標
  * @param n 現在のコスト
  * @param wall プレイヤーが壁の中にいるならばTRUE
  * @return なし
  */
-static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
+static void travel_flow_aux(player_type *creature_ptr, POSITION y, POSITION x, int n, bool wall)
 {
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-       feature_type *f_ptr = &f_info[g_ptr->feat];
-       int old_head = flow_head;
-       int add_cost = 1;
-       int base_cost = (n % TRAVEL_UNABLE);
-       int from_wall = (n / TRAVEL_UNABLE);
-       int cost;
-
        /* Ignore out of bounds */
-       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+       feature_type *f_ptr = &f_info[g_ptr->feat];
+       if (!in_bounds(floor_ptr, y, x)) return;
 
        /* Ignore unknown grid except in wilderness */
-       if (p_ptr->current_floor_ptr->dun_level > 0 && !(g_ptr->info & CAVE_KNOWN)) return;
+       if (floor_ptr->dun_level > 0 && !(g_ptr->info & CAVE_KNOWN)) return;
 
        /* Ignore "walls" and "rubble" (include "secret doors") */
+       int add_cost = 1;
+       int from_wall = (n / TRAVEL_UNABLE);
        if (have_flag(f_ptr->flags, FF_WALL) ||
                have_flag(f_ptr->flags, FF_CAN_DIG) ||
-               (have_flag(f_ptr->flags, FF_DOOR) && p_ptr->current_floor_ptr->grid_array[y][x].mimic) ||
-               (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
+               (have_flag(f_ptr->flags, FF_DOOR) && floor_ptr->grid_array[y][x].mimic) ||
+               (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !creature_ptr->levitation))
        {
                if (!wall || !from_wall) return;
                add_cost += TRAVEL_UNABLE;
        }
        else
        {
-               add_cost = travel_flow_cost(p_ptr, y, x);
+               add_cost = travel_flow_cost(creature_ptr, y, x);
        }
 
-       cost = base_cost + add_cost;
+       int base_cost = (n % TRAVEL_UNABLE);
+       int cost = base_cost + add_cost;
 
        /* Ignore lower cost entries */
        if (travel.cost[y][x] <= cost) return;
@@ -2149,6 +2078,7 @@ static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
        travel.cost[y][x] = cost;
 
        /* Enqueue that entry */
+       int old_head = flow_head;
        temp2_y[flow_head] = y;
        temp2_x[flow_head] = x;
 
@@ -2157,33 +2087,30 @@ static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
 
        /* Hack -- notice overflow by forgetting new entry */
        if (flow_head == flow_tail) flow_head = old_head;
-
-       return;
 }
 
+
 /*!
  * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param ty 目標地点のY座標
  * @param tx 目標地点のX座標
  * @return なし
  */
-static void travel_flow(POSITION ty, POSITION tx)
+static void travel_flow(player_type *creature_ptr, POSITION ty, POSITION tx)
 {
-       POSITION x, y;
-       DIRECTION d;
-       bool wall = FALSE;
-       feature_type *f_ptr = &f_info[p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
-
-       /* Reset the "queue" */
        flow_head = flow_tail = 0;
 
        /* is player in the wall? */
+       bool wall = FALSE;
+       feature_type *f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
        if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
 
        /* Start at the target grid */
-       travel_flow_aux(ty, tx, 0, wall);
+       travel_flow_aux(creature_ptr, ty, tx, 0, wall);
 
        /* Now process the queue */
+       POSITION x, y;
        while (flow_head != flow_tail)
        {
                /* Extract the next entry */
@@ -2193,21 +2120,18 @@ static void travel_flow(POSITION ty, POSITION tx)
                /* Forget that entry */
                if (++flow_tail == MAX_SHORT) flow_tail = 0;
 
-               /* Ignore too far entries */
-               //if (distance(ty, tx, y, x) > 100) continue;
-
                /* Add the "children" */
-               for (d = 0; d < 8; d++)
+               for (DIRECTION d = 0; d < 8; d++)
                {
                        /* Add that child if "legal" */
-                       travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
+                       travel_flow_aux(creature_ptr, y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
                }
        }
 
-       /* Forget the flow info */
        flow_head = flow_tail = 0;
 }
 
+
 /*!
  * @brief トラベル処理のメインルーチン
  * @return なし
@@ -2215,10 +2139,6 @@ static void travel_flow(POSITION ty, POSITION tx)
 void do_cmd_travel(player_type *creature_ptr)
 {
        POSITION x, y;
-       int i;
-       POSITION dx, dy, sx, sy;
-       feature_type *f_ptr;
-
        if (travel.x != 0 && travel.y != 0 &&
                get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
        {
@@ -2233,19 +2153,21 @@ void do_cmd_travel(player_type *creature_ptr)
                return;
        }
 
-       f_ptr = &f_info[p_ptr->current_floor_ptr->grid_array[y][x].feat];
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       feature_type *f_ptr;
+       f_ptr = &f_info[floor_ptr->grid_array[y][x].feat];
 
-       if ((p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_MARK) &&
+       if ((floor_ptr->grid_array[y][x].info & CAVE_MARK) &&
                (have_flag(f_ptr->flags, FF_WALL) ||
                        have_flag(f_ptr->flags, FF_CAN_DIG) ||
-                       (have_flag(f_ptr->flags, FF_DOOR) && p_ptr->current_floor_ptr->grid_array[y][x].mimic)))
+                       (have_flag(f_ptr->flags, FF_DOOR) && floor_ptr->grid_array[y][x].mimic)))
        {
                msg_print(_("そこには行くことができません!", "You cannot travel there!"));
                return;
        }
 
        forget_travel_flow(creature_ptr->current_floor_ptr);
-       travel_flow(y, x);
+       travel_flow(creature_ptr, y, x);
 
        travel.x = x;
        travel.y = y;
@@ -2255,17 +2177,17 @@ void do_cmd_travel(player_type *creature_ptr)
        travel.dir = 0;
 
        /* Decides first direction */
-       dx = abs(creature_ptr->x - x);
-       dy = abs(creature_ptr->y - y);
-       sx = ((x == creature_ptr->x) || (dx < dy)) ? 0 : ((x > creature_ptr->x) ? 1 : -1);
-       sy = ((y == creature_ptr->y) || (dy < dx)) ? 0 : ((y > creature_ptr->y) ? 1 : -1);
+       POSITION dx = abs(creature_ptr->x - x);
+       POSITION dy = abs(creature_ptr->y - y);
+       POSITION sx = ((x == creature_ptr->x) || (dx < dy)) ? 0 : ((x > creature_ptr->x) ? 1 : -1);
+       POSITION sy = ((y == creature_ptr->y) || (dy < dx)) ? 0 : ((y > creature_ptr->y) ? 1 : -1);
 
-       for (i = 1; i <= 9; i++)
+       for (int i = 1; i <= 9; i++)
        {
                if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;
        }
 }
-#endif
+
 
 /*
  * Something has happened to disturb the player.
@@ -2275,14 +2197,6 @@ void do_cmd_travel(player_type *creature_ptr)
  */
 void disturb(player_type *creature_ptr, bool stop_search, bool stop_travel)
 {
-#ifndef TRAVEL
-       /* Unused */
-       stop_travel = stop_travel;
-#endif
-
-       /* Cancel auto-commands */
-       /* command_new = 0; */
-
        /* Cancel repeated commands */
        if (command_rep)
        {
@@ -2307,7 +2221,7 @@ void disturb(player_type *creature_ptr, bool stop_search, bool stop_travel)
                creature_ptr->running = 0;
 
                /* Check for new panel if appropriate */
-               if (center_player && !center_running) verify_panel();
+               if (center_player && !center_running) verify_panel(creature_ptr);
 
                /* Calculate torch radius */
                creature_ptr->update |= (PU_TORCH);
@@ -2316,20 +2230,17 @@ void disturb(player_type *creature_ptr, bool stop_search, bool stop_travel)
                creature_ptr->update |= (PU_FLOW);
        }
 
-#ifdef TRAVEL
        if (stop_travel)
        {
                /* Cancel */
                travel.run = 0;
 
                /* Check for new panel if appropriate */
-               if (center_player && !center_running) verify_panel();
+               if (center_player && !center_running) verify_panel(creature_ptr);
 
                /* Calculate torch radius */
                creature_ptr->update |= (PU_TORCH);
        }
-#endif
 
-       /* Flush the input if requested */
        if (flush_disturb) flush();
 }