OSDN Git Service

[Refactor] #37353 PROJECT_* 定義を新規ファイル projection.h へ移動。 / Move PROJECT_* definition...
[hengband/hengband.git] / src / cmd2.c
index 465386f..cd434a8 100644 (file)
 
 #include "angband.h"
 #include "chest.h"
+#include "floor.h"
+#include "melee.h"
 #include "object-hook.h"
+#include "projection.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
@@ -377,15 +380,11 @@ void do_cmd_search(void)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
                command_arg = 0;
        }
-
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Search */
@@ -400,22 +399,17 @@ void do_cmd_search(void)
  * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
  * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
  */
-static s16b chest_check(int y, int x, bool trapped)
+static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
 {
        cave_type *c_ptr = &cave[y][x];
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Scan all objects in the grid */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
 
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
-
-               /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
 
                /* Skip unknown chests XXX XXX */
@@ -429,8 +423,6 @@ static s16b chest_check(int y, int x, bool trapped)
                        return (this_o_idx);
                }
        }
-
-       /* No chest */
        return (0);
 }
 
@@ -444,18 +436,13 @@ static s16b chest_check(int y, int x, bool trapped)
  * @details
  * Assume there is no monster blocking the destination
  */
-static bool do_cmd_open_chest(int y, int x, s16b o_idx)
+static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 {
        int i, j;
-
        bool flag = TRUE;
-
        bool more = FALSE;
-
        object_type *o_ptr = &o_list[o_idx];
 
-
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Attempt to unlock it */
@@ -505,14 +492,9 @@ static bool do_cmd_open_chest(int y, int x, s16b o_idx)
                /* Let the Chest drop items */
                chest_death(FALSE, y, x, o_idx);
        }
-
-       /* Result */
        return (more);
 }
 
-
-#if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
-
 /*!
  * @brief 地形は開くものであって、かつ開かれているかを返す /
  * Attempt to open the given chest at the given location
@@ -547,7 +529,7 @@ static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under
        for (d = 0; d < 9; d++)
        {
                cave_type *c_ptr;
-               s16b feat;
+               FEAT_IDX feat;
 
                /* if not searching under player continue */
                if ((d == 8) && !under) continue;
@@ -594,7 +576,7 @@ static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under
 static int count_chests(POSITION *y, POSITION *x, bool trapped)
 {
        int d, count;
-       IDX o_idx;
+       OBJECT_IDX o_idx;
 
        object_type *o_ptr;
 
@@ -605,8 +587,8 @@ static int count_chests(POSITION *y, POSITION *x, bool trapped)
        for (d = 0; d < 9; d++)
        {
                /* Extract adjacent (legal) location */
-               int yy = p_ptr->y + ddy_ddd[d];
-               int xx = p_ptr->x + ddx_ddd[d];
+               POSITION yy = p_ptr->y + ddy_ddd[d];
+               POSITION xx = p_ptr->x + ddx_ddd[d];
 
                /* No (visible) chest is there */
                if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
@@ -655,9 +637,6 @@ static DIRECTION coords_to_dir(POSITION y, POSITION x)
        return d[dx + 1][dy + 1];
 }
 
-#endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
-
-
 /*!
  * @brief 「開ける」動作コマンドのサブルーチン /
  * Perform the basic "open" command on doors
@@ -669,19 +648,15 @@ static DIRECTION coords_to_dir(POSITION y, POSITION x)
  * Assume there is no monster blocking the destination
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_open_aux(int y, int x)
+static bool do_cmd_open_aux(POSITION y, POSITION x)
 {
        int i, j;
 
        /* Get requested grid */
        cave_type *c_ptr = &cave[y][x];
-
        feature_type *f_ptr = &f_info[c_ptr->feat];
-
        bool more = FALSE;
 
-
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Seeing true feature code (ignore mimic) */
@@ -706,7 +681,7 @@ static bool do_cmd_open_aux(int y, int x)
                /* Extract the lock power */
                j = f_ptr->power;
 
-               /* Extract the difficulty XXX XXX XXX */
+               /* Extract the difficulty */
                j = i - (j * 4);
 
                /* Always have a small chance of success */
@@ -715,13 +690,11 @@ static bool do_cmd_open_aux(int y, int x)
                /* Success */
                if (randint0(100) < j)
                {
-                       /* Message */
                        msg_print(_("鍵をはずした。", "You have picked the lock."));
 
                        /* Open the door */
                        cave_alter_feat(y, x, FF_OPEN);
 
-                       /* Sound */
                        sound(SOUND_OPENDOOR);
 
                        /* Experience */
@@ -734,7 +707,6 @@ static bool do_cmd_open_aux(int y, int x)
                        /* Failure */
                        if (flush_failure) flush();
 
-                       /* Message */
                        msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
 
                        /* We may keep trying */
@@ -748,11 +720,8 @@ static bool do_cmd_open_aux(int y, int x)
                /* Open the door */
                cave_alter_feat(y, x, FF_OPEN);
 
-               /* Sound */
                sound(SOUND_OPENDOOR);
        }
-
-       /* Result */
        return (more);
 }
 
@@ -767,17 +736,17 @@ void do_cmd_open(void)
 {
        POSITION y, x;
        DIRECTION dir;
-       IDX o_idx;
+       OBJECT_IDX o_idx;
 
        bool more = FALSE;
 
+       if (p_ptr->wild_mode) return;
+
        if (p_ptr->special_defense & KATA_MUSOU)
        {
                set_action(ACTION_NONE);
        }
 
-#ifdef ALLOW_EASY_OPEN /* TNB */
-
        /* Option: Pick a direction */
        if (easy_open)
        {
@@ -798,15 +767,11 @@ void do_cmd_open(void)
                }
        }
 
-#endif /* ALLOW_EASY_OPEN -- TNB */
-
        /* Allow repeated command */
        if (command_arg)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -816,7 +781,7 @@ void do_cmd_open(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, TRUE))
        {
-               s16b feat;
+               FEAT_IDX feat;
                cave_type *c_ptr;
 
                /* Get requested location */
@@ -835,20 +800,14 @@ void do_cmd_open(void)
                /* Nothing useful */
                if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
                {
-                       /* Message */
                        msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
                }
 
                /* Monster in the way */
                else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
-
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
-                       
-                       /* Attack */
                        py_attack(y, x, 0);
                }
 
@@ -868,7 +827,7 @@ void do_cmd_open(void)
        }
 
        /* Cancel repeat unless we may continue */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -884,14 +843,12 @@ void do_cmd_open(void)
  * Assume there is no monster blocking the destination
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_close_aux(int y, int x)
+static bool do_cmd_close_aux(POSITION y, POSITION x)
 {
-       /* Get grid and contents */
        cave_type *c_ptr = &cave[y][x];
-       s16b      old_feat = c_ptr->feat;
-       bool      more = FALSE;
+       FEAT_IDX old_feat = c_ptr->feat;
+       bool more = FALSE;
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Seeing true feature code (ignore mimic) */
@@ -905,7 +862,6 @@ static bool do_cmd_close_aux(int y, int x)
                if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
                    (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
                {
-                       /* Message */
                        msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
                }
                else
@@ -916,18 +872,14 @@ static bool do_cmd_close_aux(int y, int x)
                        /* Broken door */
                        if (old_feat == c_ptr->feat)
                        {
-                               /* Message */
                                msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
                        }
                        else
                        {
-                               /* Sound */
                                sound(SOUND_SHUTDOOR);
                        }
                }
        }
-
-       /* Result */
        return (more);
 }
 
@@ -946,13 +898,13 @@ void do_cmd_close(void)
 
        bool more = FALSE;
 
+       if (p_ptr->wild_mode) return;
+
        if (p_ptr->special_defense & KATA_MUSOU)
        {
                set_action(ACTION_NONE);
        }
 
-#ifdef ALLOW_EASY_OPEN /* TNB */
-
        /* Option: Pick a direction */
        if (easy_open)
        {
@@ -963,15 +915,11 @@ void do_cmd_close(void)
                }
        }
 
-#endif /* ALLOW_EASY_OPEN -- TNB */
-
        /* Allow repeated command */
        if (command_arg)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -979,16 +927,13 @@ void do_cmd_close(void)
        }
 
        /* Get a "repeated" direction */
-       if (get_rep_dir(&dir,FALSE))
+       if (get_rep_dir(&dir, FALSE))
        {
                cave_type *c_ptr;
-               s16b feat;
+               FEAT_IDX feat;
 
-               /* Get requested location */
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-
-               /* Get grid and contents */
                c_ptr = &cave[y][x];
 
                /* Feature code (applying "mimic" field) */
@@ -997,17 +942,14 @@ void do_cmd_close(void)
                /* Require open/broken door */
                if (!have_flag(f_info[feat].flags, FF_CLOSE))
                {
-                       /* Message */
                        msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
                }
 
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
 
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
                        /* Attack */
@@ -1023,7 +965,7 @@ void do_cmd_close(void)
        }
 
        /* Cancel repeat unless we may continue */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -1034,31 +976,26 @@ void do_cmd_close(void)
  * @param x 対象を行うマスのX座標
  * @return 
  */
-static bool do_cmd_tunnel_test(int y, int x)
+static bool do_cmd_tunnel_test(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
 
        /* Must have knowledge */
        if (!(c_ptr->info & CAVE_MARK))
        {
-               /* Message */
                msg_print(_("そこには何も見当たらない。", "You see nothing there."));
 
-               /* Nope */
                return (FALSE);
        }
 
        /* Must be a wall/door/etc */
        if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
        {
-               /* Message */
                msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
 
-               /* Nope */
                return (FALSE);
        }
 
-       /* Okay */
        return (TRUE);
 }
 
@@ -1074,18 +1011,17 @@ static bool do_cmd_tunnel_test(int y, int x)
  * Do not use twall anymore
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_tunnel_aux(int y, int x)
+static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
 {
        cave_type *c_ptr;
        feature_type *f_ptr, *mimic_f_ptr;
        int power;
-       cptr name;
+       concptr name;
        bool more = FALSE;
 
        /* Verify legality */
        if (!do_cmd_tunnel_test(y, x)) return (FALSE);
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Get grid */
@@ -1098,7 +1034,6 @@ static bool do_cmd_tunnel_aux(int y, int x)
 
        name = f_name + mimic_f_ptr->name;
 
-       /* Sound */
        sound(SOUND_DIG);
 
        if (have_flag(f_ptr->flags, FF_PERMANENT))
@@ -1122,7 +1057,6 @@ static bool do_cmd_tunnel_aux(int y, int x)
                /* Dig */
                if (p_ptr->skill_dig > randint0(20 * power))
                {
-                       /* Message */
                        msg_format(_("%sをくずした。", "You have removed the %s."), name);
 
                        /* Remove the feature */
@@ -1154,7 +1088,6 @@ static bool do_cmd_tunnel_aux(int y, int x)
                                p_ptr->update |= (PU_FLOW);
                        }
                        
-                       /* Sound */
                        if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
 
                        /* Remove the feature */
@@ -1189,8 +1122,6 @@ static bool do_cmd_tunnel_aux(int y, int x)
                /* Occasional Search XXX XXX */
                if (randint0(100) < 25) search();
        }
-
-       /* Result */
        return more;
 }
 
@@ -1213,7 +1144,7 @@ void do_cmd_tunnel(void)
        int                     y, x, dir;
 
        cave_type       *c_ptr;
-       s16b feat;
+       FEAT_IDX feat;
 
        bool            more = FALSE;
 
@@ -1228,8 +1159,6 @@ void do_cmd_tunnel(void)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -1252,7 +1181,6 @@ void do_cmd_tunnel(void)
                /* No tunnelling through doors */
                if (have_flag(f_info[feat].flags, FF_DOOR))
                {
-                       /* Message */
                        msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
                }
 
@@ -1265,10 +1193,8 @@ void do_cmd_tunnel(void)
                /* A monster is in the way */
                else if (c_ptr->m_idx)
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
 
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
                        /* Attack */
@@ -1284,12 +1210,9 @@ void do_cmd_tunnel(void)
        }
 
        /* Cancel repetition unless we can continue */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
-
-#ifdef ALLOW_EASY_OPEN /* TNB */
-
 /*!
  * @brief 移動処理による簡易な「開く」処理 /
  * easy_open_door --
@@ -1304,7 +1227,7 @@ void do_cmd_tunnel(void)
  *     do_cmd_open_test() and do_cmd_open_aux().
  * </pre>
  */
-bool easy_open_door(int y, int x)
+bool easy_open_door(POSITION y, POSITION x)
 {
        int i, j;
 
@@ -1314,7 +1237,6 @@ bool easy_open_door(int y, int x)
        /* Must be a closed door */
        if (!is_closed_door(c_ptr->feat))
        {
-               /* Nope */
                return (FALSE);
        }
 
@@ -1339,7 +1261,7 @@ bool easy_open_door(int y, int x)
                /* Extract the lock power */
                j = f_ptr->power;
 
-               /* Extract the difficulty XXX XXX XXX */
+               /* Extract the difficulty */
                j = i - (j * 4);
 
                /* Always have a small chance of success */
@@ -1348,13 +1270,11 @@ bool easy_open_door(int y, int x)
                /* Success */
                if (randint0(100) < j)
                {
-                       /* Message */
                        msg_print(_("鍵をはずした。", "You have picked the lock."));
 
                        /* Open the door */
                        cave_alter_feat(y, x, FF_OPEN);
 
-                       /* Sound */
                        sound(SOUND_OPENDOOR);
 
                        /* Experience */
@@ -1367,7 +1287,6 @@ bool easy_open_door(int y, int x)
                        /* Failure */
                        if (flush_failure) flush();
 
-                       /* Message */
                        msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
 
                }
@@ -1379,17 +1298,11 @@ bool easy_open_door(int y, int x)
                /* Open the door */
                cave_alter_feat(y, x, FF_OPEN);
 
-               /* Sound */
                sound(SOUND_OPENDOOR);
        }
-
-       /* Result */
        return (TRUE);
 }
 
-#endif /* ALLOW_EASY_OPEN -- TNB */
-
-
 /*!
  * @brief 箱のトラップを解除するコマンドのメインルーチン /
  * Perform the basic "disarm" command
@@ -1404,16 +1317,12 @@ bool easy_open_door(int y, int x)
  * Returns TRUE if repeated commands may continue
  * </pre>
  */
-static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
+static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 {
        int i, j;
-
        bool more = FALSE;
-
        object_type *o_ptr = &o_list[o_idx];
 
-
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Get the "disarm" factor */
@@ -1472,8 +1381,6 @@ static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
                sound(SOUND_FAIL);
                chest_trap(y, x, o_idx);
        }
-
-       /* Result */
        return (more);
 }
 
@@ -1492,36 +1399,25 @@ static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
  * Returns TRUE if repeated commands may continue
  * </pre>
  */
-#ifdef ALLOW_EASY_DISARM /* TNB */
-
-bool do_cmd_disarm_aux(int y, int x, int dir)
 
-#else /* ALLOW_EASY_DISARM -- TNB */
-
-static bool do_cmd_disarm_aux(int y, int x, int dir)
-
-#endif /* ALLOW_EASY_DISARM -- TNB */
+bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
 {
-       /* Get grid and contents */
        cave_type *c_ptr = &cave[y][x];
 
        /* Get feature */
        feature_type *f_ptr = &f_info[c_ptr->feat];
 
        /* Access trap name */
-       cptr name = (f_name + f_ptr->name);
+       concptr name = (f_name + f_ptr->name);
 
        /* Extract trap "power" */
        int power = f_ptr->power;
-
        bool more = FALSE;
 
        /* Get the "disarm" factor */
        int i = p_ptr->skill_dis;
-
        int j;
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Penalize some conditions */
@@ -1537,7 +1433,6 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
        /* Success */
        if (randint0(100) < j)
        {
-               /* Message */
                msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
                
                /* Reward */
@@ -1546,17 +1441,8 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
                /* Remove the trap */
                cave_alter_feat(y, x, FF_DISARM);
 
-#ifdef ALLOW_EASY_DISARM /* TNB */
-
                /* Move the player onto the trap */
                move_player(dir, easy_disarm, FALSE);
-
-#else /* ALLOW_EASY_DISARM -- TNB */
-
-               /* move the player onto the trap grid */
-               move_player(dir, FALSE, FALSE);
-
-#endif /* ALLOW_EASY_DISARM -- TNB */
        }
 
        /* Failure -- Keep trying */
@@ -1565,7 +1451,6 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
                /* Failure */
                if (flush_failure) flush();
 
-               /* Message */
                msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
 
                /* We may keep trying */
@@ -1575,23 +1460,10 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
        /* Failure -- Set off the trap */
        else
        {
-               /* Message */
                msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
-
-#ifdef ALLOW_EASY_DISARM /* TNB */
-
                /* Move the player onto the trap */
                move_player(dir, easy_disarm, FALSE);
-
-#else /* ALLOW_EASY_DISARM -- TNB */
-
-               /* Move the player onto the trap */
-               move_player(dir, FALSE, FALSE);
-
-#endif /* ALLOW_EASY_DISARM -- TNB */
        }
-
-       /* Result */
        return (more);
 }
 
@@ -1605,17 +1477,17 @@ void do_cmd_disarm(void)
 {
        POSITION y, x;
        DIRECTION dir;
-       s16b o_idx;
+       OBJECT_IDX o_idx;
 
        bool more = FALSE;
 
+       if (p_ptr->wild_mode) return;
+
        if (p_ptr->special_defense & KATA_MUSOU)
        {
                set_action(ACTION_NONE);
        }
 
-#ifdef ALLOW_EASY_DISARM /* TNB */
-
        /* Option: Pick a direction */
        if (easy_disarm)
        {
@@ -1635,15 +1507,12 @@ void do_cmd_disarm(void)
                }
        }
 
-#endif /* ALLOW_EASY_DISARM -- TNB */
 
        /* Allow repeated command */
        if (command_arg)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -1654,13 +1523,10 @@ void do_cmd_disarm(void)
        if (get_rep_dir(&dir,TRUE))
        {
                cave_type *c_ptr;
-               s16b feat;
+               FEAT_IDX feat;
 
-               /* Get location */
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-
-               /* Get grid and contents */
                c_ptr = &cave[y][x];
 
                /* Feature code (applying "mimic" field) */
@@ -1672,14 +1538,12 @@ void do_cmd_disarm(void)
                /* Disarm a trap */
                if (!is_trap(feat) && !o_idx)
                {
-                       /* Message */
                        msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
                }
 
                /* Monster in the way */
                else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
                {
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
                        /* Attack */
@@ -1689,20 +1553,18 @@ void do_cmd_disarm(void)
                /* Disarm chest */
                else if (o_idx)
                {
-                       /* Disarm the chest */
                        more = do_cmd_disarm_chest(y, x, o_idx);
                }
 
                /* Disarm trap */
                else
                {
-                       /* Disarm the trap */
                        more = do_cmd_disarm_aux(y, x, dir);
                }
        }
 
        /* Cancel repeat unless told not to */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -1720,7 +1582,7 @@ void do_cmd_disarm(void)
  * Returns TRUE if repeated commands may continue
  * </pre>
  */
-static bool do_cmd_bash_aux(int y, int x, int dir)
+static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 {
        /* Get grid */
        cave_type       *c_ptr = &cave[y][x];
@@ -1737,15 +1599,13 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
 
        bool            more = FALSE;
 
-       cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
+       concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
-       /* Message */
        msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
 
-       /* Compare bash power to door power XXX XXX XXX */
+       /* Compare bash power to door power */
        temp = (bash - (temp * 10));
 
        if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
@@ -1756,10 +1616,8 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
        /* Hack -- attempt to bash down the door */
        if (randint0(100) < temp)
        {
-               /* Message */
                msg_format(_("%sを壊した!", "The %s crashes open!"), name);
 
-               /* Sound */
                sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
 
                /* Break down the door */
@@ -1782,7 +1640,6 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
        else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
                 p_ptr->lev)
        {
-               /* Message */
                msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
 
                /* Allow repeated bashing */
@@ -1792,14 +1649,11 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
        /* High dexterity yields coolness */
        else
        {
-               /* Message */
                msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
 
                /* Hack -- Lose balance ala paralysis */
                (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
        }
-
-       /* Result */
        return (more);
 }
 
@@ -1824,12 +1678,11 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
  */
 void do_cmd_bash(void)
 {
-       int                     y, x, dir;
-
+       int     y, x, dir;
        cave_type       *c_ptr;
-
        bool            more = FALSE;
 
+       if (p_ptr->wild_mode) return;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -1841,8 +1694,6 @@ void do_cmd_bash(void)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -1852,7 +1703,7 @@ void do_cmd_bash(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir,FALSE))
        {
-               s16b feat;
+               FEAT_IDX feat;
 
                /* Bash location */
                y = p_ptr->y + ddy[dir];
@@ -1867,17 +1718,14 @@ void do_cmd_bash(void)
                /* Nothing useful */
                if (!have_flag(f_info[feat].flags, FF_BASH))
                {
-                       /* Message */
                        msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
                }
 
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
 
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
                        /* Attack */
@@ -1893,7 +1741,7 @@ void do_cmd_bash(void)
        }
 
        /* Unless valid action taken, cancel bash */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -1906,7 +1754,7 @@ void do_cmd_bash(void)
  *
  * Attack monsters, tunnel through walls, disarm traps, open doors.
  *
- * Consider confusion XXX XXX XXX
+ * Consider confusion 
  *
  * This command must always take a turn, to prevent free detection
  * of invisible monsters.
@@ -1914,12 +1762,10 @@ void do_cmd_bash(void)
  */
 void do_cmd_alter(void)
 {
-       int                     y, x, dir;
-
-       cave_type       *c_ptr;
-
-       bool            more = FALSE;
-
+       POSITION y, x;
+       DIRECTION dir;
+       cave_type *c_ptr;
+       bool more = FALSE;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -1931,8 +1777,6 @@ void do_cmd_alter(void)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -1942,10 +1786,9 @@ void do_cmd_alter(void)
        /* Get a direction */
        if (get_rep_dir(&dir,TRUE))
        {
-               s16b feat;
+               FEAT_IDX feat;
                feature_type *f_ptr;
 
-               /* Get location */
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
@@ -1956,13 +1799,10 @@ void do_cmd_alter(void)
                feat = get_feat_mimic(c_ptr);
                f_ptr = &f_info[feat];
 
-               /* Take a turn */
                p_ptr->energy_use = 100;
 
-               /* Attack monsters */
                if (c_ptr->m_idx)
                {
-                       /* Attack */
                        py_attack(y, x, 0);
                }
 
@@ -1996,16 +1836,14 @@ void do_cmd_alter(void)
                        more = do_cmd_disarm_aux(y, x, dir);
                }
 
-               /* Oops */
                else
                {
-                       /* Oops */
                        msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
                }
        }
 
        /* Cancel repetition unless we can continue */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -2017,12 +1855,12 @@ void do_cmd_alter(void)
  * @return オブジェクトがある場合TRUEを返す
  * @details
  * <pre>
- * XXX XXX XXX Let user choose a pile of spikes, perhaps?
+ * Let user choose a pile of spikes, perhaps?
  * </pre>
  */
-static bool get_spike(int *ip)
+static bool get_spike(INVENTORY_IDX *ip)
 {
-       int i;
+       INVENTORY_IDX i;
 
        /* Check every item in the pack */
        for (i = 0; i < INVEN_PACK; i++)
@@ -2043,7 +1881,6 @@ static bool get_spike(int *ip)
                }
        }
 
-       /* Oops */
        return (FALSE);
 }
 
@@ -2059,7 +1896,9 @@ static bool get_spike(int *ip)
  */
 void do_cmd_spike(void)
 {
-       int dir;
+       DIRECTION dir;
+
+       if (p_ptr->wild_mode) return;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -2067,17 +1906,15 @@ void do_cmd_spike(void)
        }
 
        /* Get a "repeated" direction */
-       if (get_rep_dir(&dir,FALSE))
+       if (get_rep_dir(&dir, FALSE))
        {
-               int y, x, item;
+               POSITION y, x;
+               INVENTORY_IDX item;
                cave_type *c_ptr;
-               s16b feat;
+               FEAT_IDX feat;
 
-               /* Get location */
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-
-               /* Get grid and contents */
                c_ptr = &cave[y][x];
 
                /* Feature code (applying "mimic" field) */
@@ -2086,24 +1923,20 @@ void do_cmd_spike(void)
                /* Require closed door */
                if (!have_flag(f_info[feat].flags, FF_SPIKE))
                {
-                       /* Message */
                        msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
                }
 
                /* Get a spike */
                else if (!get_spike(&item))
                {
-                       /* Message */
                        msg_print(_("くさびを持っていない!", "You have no spikes!"));
                }
 
                /* Is a monster in the way? */
                else if (c_ptr->m_idx)
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
 
-                       /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
                        /* Attack */
@@ -2113,7 +1946,6 @@ void do_cmd_spike(void)
                /* Go for it */
                else
                {
-                       /* Take a turn */
                        p_ptr->energy_use = 100;
 
                        /* Successful jamming */
@@ -2138,7 +1970,7 @@ void do_cmd_spike(void)
  */
 void do_cmd_walk(bool pickup)
 {
-       int dir;
+       DIRECTION dir;
 
        bool more = FALSE;
 
@@ -2148,8 +1980,6 @@ void do_cmd_walk(bool pickup)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
@@ -2159,7 +1989,6 @@ void do_cmd_walk(bool pickup)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, FALSE))
        {
-               /* Take a turn */
                p_ptr->energy_use = 100;
 
                if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
@@ -2203,7 +2032,7 @@ void do_cmd_walk(bool pickup)
        }
 
        /* Cancel repeat unless we may continue */
-       if (!more) disturb(0, 0);
+       if (!more) disturb(FALSE, FALSE);
 }
 
 
@@ -2214,7 +2043,7 @@ void do_cmd_walk(bool pickup)
  */
 void do_cmd_run(void)
 {
-       int dir;
+       DIRECTION dir;
 
        /* Hack -- no running when confused */
        if (p_ptr->confused)
@@ -2256,15 +2085,12 @@ void do_cmd_stay(bool pickup)
        {
                /* Set repeat count */
                command_rep = command_arg - 1;
-
-               /* Redraw the state */
                p_ptr->redraw |= (PR_STATE);
 
                /* Cancel the arg */
                command_arg = 0;
        }
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        if (pickup) mpe_mode |= MPE_DO_PICKUP;
@@ -2293,7 +2119,7 @@ void do_cmd_rest(void)
        /* Prompt for time if needed */
        if (command_arg <= 0)
        {
-               cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ", 
+               concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ", 
                                   "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
 
 
@@ -2331,12 +2157,11 @@ void do_cmd_rest(void)
 
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
 
-       /* Take a turn XXX XXX XXX (?) */
+       /* Take a turn (?) */
        p_ptr->energy_use = 100;
 
        /* The sin of sloth */
-       if (command_arg > 100)
-               chg_virtue(V_DILIGENCE, -1);
+       if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
        
        /* Why are you sleeping when there's no need?  WAKE UP!*/
        if ((p_ptr->chp == p_ptr->mhp) &&
@@ -2352,17 +2177,12 @@ void do_cmd_rest(void)
        /* Save the rest code */
        resting = command_arg;
        p_ptr->action = ACTION_REST;
-
-       /* Recalculate bonuses */
        p_ptr->update |= (PU_BONUS);
+       update_creature(p_ptr);
 
-       /* Redraw the state */
        p_ptr->redraw |= (PR_STATE);
+       update_output();
 
-       /* Handle stuff */
-       handle_stuff();
-
-       /* Refresh */
        Term_fresh();
 }
 
@@ -2439,9 +2259,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       u32b flgs[TR_FLAG_SIZE];
-
-       /* Extract the flags */
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
 
        /* Some "weapons" and "ammo" do extra damage */
@@ -2451,153 +2269,115 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                case TV_ARROW:
                case TV_BOLT:
                {
-                       /* Slay Animal */
-                       if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
-                           (r_ptr->flags3 & RF3_ANIMAL))
+                       if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
-
                                if (mult < 17) mult = 17;
                        }
 
-                       /* Kill Animal */
-                       if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
-                           (r_ptr->flags3 & RF3_ANIMAL))
+                       if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
-
                                if (mult < 27) mult = 27;
                        }
 
-                       /* Slay Evil */
-                       if ((have_flag(flgs, TR_SLAY_EVIL)) &&
-                           (r_ptr->flags3 & RF3_EVIL))
+                       if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
-
                                if (mult < 15) mult = 15;
                        }
 
-                       /* Kill Evil */
-                       if ((have_flag(flgs, TR_KILL_EVIL)) &&
-                           (r_ptr->flags3 & RF3_EVIL))
+                       if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
-
                                if (mult < 25) mult = 25;
                        }
 
-                       /* Slay Human */
-                       if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
-                           (r_ptr->flags2 & RF2_HUMAN))
+                       if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
-
                                if (mult < 17) mult = 17;
                        }
 
-                       /* Kill Human */
-                       if ((have_flag(flgs, TR_KILL_HUMAN)) &&
-                           (r_ptr->flags2 & RF2_HUMAN))
+                       if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
-
                                if (mult < 27) mult = 27;
                        }
 
-                       /* Slay Undead */
-                       if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
-                           (r_ptr->flags3 & RF3_UNDEAD))
+                       if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
-
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Kill Undead */
-                       if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
-                           (r_ptr->flags3 & RF3_UNDEAD))
+                       if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
-
                                if (mult < 30) mult = 30;
                        }
 
-                       /* Slay Demon */
-                       if ((have_flag(flgs, TR_SLAY_DEMON)) &&
-                           (r_ptr->flags3 & RF3_DEMON))
+                       if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
-
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Kill Demon */
-                       if ((have_flag(flgs, TR_KILL_DEMON)) &&
-                           (r_ptr->flags3 & RF3_DEMON))
+                       if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
-
                                if (mult < 30) mult = 30;
                        }
 
-                       /* Slay Orc */
-                       if ((have_flag(flgs, TR_SLAY_ORC)) &&
-                           (r_ptr->flags3 & RF3_ORC))
+                       if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
-
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Kill Orc */
-                       if ((have_flag(flgs, TR_KILL_ORC)) &&
-                           (r_ptr->flags3 & RF3_ORC))
+                       if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
-
                                if (mult < 30) mult = 30;
                        }
 
-                       /* Slay Troll */
-                       if ((have_flag(flgs, TR_SLAY_TROLL)) &&
-                           (r_ptr->flags3 & RF3_TROLL))
+                       if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
@@ -2607,72 +2387,54 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Kill Troll */
-                       if ((have_flag(flgs, TR_KILL_TROLL)) &&
-                           (r_ptr->flags3 & RF3_TROLL))
+                       if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_TROLL;
                                }
-
                                if (mult < 30) mult = 30;
                        }
 
-                       /* Slay Giant */
-                       if ((have_flag(flgs, TR_SLAY_GIANT)) &&
-                           (r_ptr->flags3 & RF3_GIANT))
+                       if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
-
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Kill Giant */
-                       if ((have_flag(flgs, TR_KILL_GIANT)) &&
-                           (r_ptr->flags3 & RF3_GIANT))
+                       if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
-
                                if (mult < 30) mult = 30;
                        }
 
-                       /* Slay Dragon  */
-                       if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
-                           (r_ptr->flags3 & RF3_DRAGON))
+                       if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
-
                                if (mult < 20) mult = 20;
                        }
 
-                       /* Execute Dragon */
-                       if ((have_flag(flgs, TR_KILL_DRAGON)) &&
-                           (r_ptr->flags3 & RF3_DRAGON))
+                       if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
-
                                if (mult < 30) mult = 30;
-
-                               if ((o_ptr->name1 == ART_BARD_ARROW) &&
-                                   (m_ptr->r_idx == MON_SMAUG) &&
+                               if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
                                    (inventory[INVEN_BOW].name1 == ART_BARD))
                                        mult *= 5;
                        }
 
-                       /* Brand (Acid) */
                        if (have_flag(flgs, TR_BRAND_ACID))
                        {
                                /* Notice immunity */
@@ -2683,15 +2445,12 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                                r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
                                        }
                                }
-
-                               /* Otherwise, take the damage */
                                else
                                {
                                        if (mult < 17) mult = 17;
                                }
                        }
 
-                       /* Brand (Elec) */
                        if (have_flag(flgs, TR_BRAND_ELEC))
                        {
                                /* Notice immunity */
@@ -2702,15 +2461,12 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                                r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
                                        }
                                }
-
-                               /* Otherwise, take the damage */
                                else
                                {
                                        if (mult < 17) mult = 17;
                                }
                        }
 
-                       /* Brand (Fire) */
                        if (have_flag(flgs, TR_BRAND_FIRE))
                        {
                                /* Notice immunity */
@@ -2721,7 +2477,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                                r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
                                        }
                                }
-
                                /* Otherwise, take the damage */
                                else
                                {
@@ -2737,7 +2492,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                }
                        }
 
-                       /* Brand (Cold) */
                        if (have_flag(flgs, TR_BRAND_COLD))
                        {
                                /* Notice immunity */
@@ -2763,7 +2517,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                }
                        }
 
-                       /* Brand (Poison) */
                        if (have_flag(flgs, TR_BRAND_POIS))
                        {
                                /* Notice immunity */
@@ -2774,7 +2527,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                                                r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
                                        }
                                }
-
                                /* Otherwise, take the damage */
                                else
                                {
@@ -2834,10 +2586,11 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
  * Note that Bows of "Extra Shots" give an extra shot.
  * </pre>
  */
-void do_cmd_fire_aux(int item, object_type *j_ptr)
+void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
 {
-       int dir;
-       int i, y, x, ny, nx, ty, tx, prev_y, prev_x;
+       DIRECTION dir;
+       int i;
+       POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
        int tdam_base, tdis, thits, tmul;
        int bonus, chance;
        int cur_dis, visible;
@@ -2850,7 +2603,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
 
        bool hit_body = FALSE;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        u16b path_g[512];       /* For calcuration of path length */
 
@@ -2872,7 +2625,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
        /* Sniper - Cannot shot a single arrow twice */
        if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
 
-       /* Describe the object */
        object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
 
        /* Use the proper number of shots */
@@ -2968,8 +2720,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
        /* Start at the player */
        y = p_ptr->y;
        x = p_ptr->x;
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Obtain a local object */
@@ -2993,10 +2743,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                floor_item_optimize(0 - item);
        }
 
-       /* Sound */
        sound(SOUND_SHOOT);
-
-       /* Hack -- Handle stuff */
        handle_stuff();
 
        /* Save the old location */
@@ -3029,7 +2776,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
                                /* Forget the wall */
                                c_ptr->info &= ~(CAVE_MARK);
-
                                p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
 
                                /* Destroy the wall */
@@ -3050,11 +2796,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                if (snipe_type == SP_LITE)
                {
                        cave[ny][nx].info |= (CAVE_GLOW);
-
-                       /* Notice */
                        note_spot(ny, nx);
-
-                       /* Redraw */
                        lite_spot(ny, nx);
                }
 
@@ -3091,11 +2833,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                if (snipe_type == SP_EVILNESS)
                {
                        cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
-
-                       /* Notice */
                        note_spot(ny, nx);
-
-                       /* Redraw */
                        lite_spot(ny, nx);
                }
 
@@ -3107,7 +2845,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                x = nx;
                y = ny;
 
-
                /* Monster here, Try to hit it */
                if (cave[y][x].m_idx)
                {
@@ -3173,20 +2910,16 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                /* Handle visible monster */
                                else
                                {
-                                       char m_name[80];
+                                       GAME_TEXT m_name[MAX_NLEN];
 
                                        /* Get "the monster" or "it" */
                                        monster_desc(m_name, m_ptr, 0);
 
-                                       /* Message */
                                        msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
 
                                        if (m_ptr->ml)
                                        {
-                                               /* Hack -- Track this monster race */
                                                if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-
-                                               /* Hack -- Track this monster */
                                                health_track(c_mon_ptr->m_idx);
                                        }
                                }
@@ -3196,7 +2929,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                        if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
                                                && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
                                        {
-                                               char m_name[80];
+                                               GAME_TEXT m_name[MAX_NLEN];
 
                                                /* Get "the monster" or "it" */
                                                monster_desc(m_name, m_ptr, 0);
@@ -3208,7 +2941,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                }
                                else
                                {
-                                       /* Apply special damage XXX XXX XXX */
+                                       /* Apply special damage */
                                        tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
                                        tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
 
@@ -3237,16 +2970,12 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                if (snipe_type == SP_HOLYNESS)
                                {
                                        cave[ny][nx].info |= (CAVE_GLOW);
-
-                                       /* Notice */
                                        note_spot(ny, nx);
-
-                                       /* Redraw */
                                        lite_spot(ny, nx);
                                }
 
                                /* Hit the monster, check for death */
-                               if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
+                               if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
                                {
                                        /* Dead monster */
                                }
@@ -3258,7 +2987,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                        if (object_is_fixed_artifact(q_ptr) &&
                                                (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
                                        {
-                                               char m_name[80];
+                                               GAME_TEXT m_name[MAX_NLEN];
 
                                                monster_desc(m_name, m_ptr, 0);
 
@@ -3266,24 +2995,16 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                                msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
                                        }
 
-                                       /* Message */
                                        message_pain(c_mon_ptr->m_idx, tdam);
 
                                        /* Anger the monster */
                                        if (tdam > 0) anger_monster(m_ptr);
 
-                                       /* Take note */
                                        if (fear && m_ptr->ml)
                                        {
-                                               char m_name[80];
-
-                                               /* Sound */
+                                               GAME_TEXT m_name[MAX_NLEN];
                                                sound(SOUND_FLEE);
-
-                                               /* Get the monster name (or "it") */
                                                monster_desc(m_name, m_ptr, 0);
-
-                                               /* Message */
                                                msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
                                        }
 
@@ -3320,8 +3041,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                                        m_ptr->fx = nx;
                                                        m_ptr->fy = ny;
 
-                                                       /* Update the monster (new location) */
-                                                       update_mon(c_mon_ptr->m_idx, TRUE);
+                                                       update_monster(c_mon_ptr->m_idx, TRUE);
 
                                                        lite_spot(ny, nx);
                                                        lite_spot(oy, ox);
@@ -3358,7 +3078,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
        {
                MONSTER_IDX m_idx = cave[y][x].m_idx;
                monster_type *m_ptr = &m_list[m_idx];
-               IDX o_idx = o_pop();
+               OBJECT_IDX o_idx = o_pop();
 
                if (!o_idx)
                {
@@ -3413,8 +3133,10 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
 void do_cmd_fire(void)
 {
        OBJECT_IDX item;
-       object_type *j_ptr;
-       cptr q, s;
+       object_type *j_ptr, *ammo_ptr;
+       concptr q, s;
+
+       if(p_ptr->wild_mode) return;
 
        is_fired = FALSE;       /* not fired yet */
 
@@ -3452,10 +3174,12 @@ void do_cmd_fire(void)
        /* Require proper missile */
        item_tester_tval = p_ptr->tval_ammo;
 
-       /* Get an item */
        q = _("どれを撃ちますか? ", "Fire which item? ");
        s = _("発射されるアイテムがありません。", "You have nothing to fire.");
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
+
+
+       ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!ammo_ptr)
        {
                flush();
                return;
@@ -3500,8 +3224,9 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 {
        DIRECTION dir;
        OBJECT_IDX item;
-       int i, y, x, ty, tx, prev_y, prev_x;
-       int ny[19], nx[19];
+       int i;
+       POSITION y, x, ty, tx, prev_y, prev_x;
+       POSITION ny[19], nx[19];
        int chance, tdam, tdis;
        int mul, div, dd, ds;
        int cur_dis, visible;
@@ -3509,7 +3234,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
        object_type forge;
        object_type *q_ptr;
-
        object_type *o_ptr;
 
        bool hit_body = FALSE;
@@ -3517,15 +3241,16 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        bool equiped_item = FALSE;
        bool return_when_thrown = FALSE;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        int msec = delay_factor * delay_factor * delay_factor;
 
-       u32b flgs[TR_FLAG_SIZE];
-       cptr q, s;
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
+       concptr q, s;
        bool come_back = FALSE;
        bool do_drop = TRUE;
 
+       if (p_ptr->wild_mode) return FALSE;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -3535,6 +3260,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        if (shuriken >= 0)
        {
                item = shuriken;
+               o_ptr = &inventory[item];
        }
        else if (boomerang)
        {
@@ -3543,45 +3269,41 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        item_tester_hook = item_tester_hook_boomerang;
                        q = _("どの武器を投げますか? ", "Throw which item? ");
                        s = _("投げる武器がない。", "You have nothing to throw.");
-                       if (!get_item(&item, q, s, (USE_EQUIP)))
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr)
                        {
                                flush();
                                return FALSE;
                        }
                }
-               else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
-               else item = INVEN_RARM;
+               else if (buki_motteruka(INVEN_LARM))
+               {
+                       item = INVEN_LARM;
+                       o_ptr = &inventory[item];
+               }
+               else
+               {
+                       item = INVEN_RARM;
+                       o_ptr = &inventory[item];
+               }
        }
        else
        {
-               /* Get an item */
                q = _("どのアイテムを投げますか? ", "Throw which item? ");
                s = _("投げるアイテムがない。", "You have nothing to throw.");
-               if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
+               o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
+               if (!o_ptr)
                {
                        flush();
                        return FALSE;
                }
        }
 
-       /* Access the item (if in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
-
        /* Item is cursed */
        if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
        {
-               /* Oops */
                msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
 
-               /* Nope */
                return FALSE;
        }
 
@@ -3592,13 +3314,10 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
                        msg_print(NULL);
 
-                       /* Nope */
                        return FALSE;
                }
 
        }
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Obtain a local object */
@@ -3614,7 +3333,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        /* Single object */
        q_ptr->number = 1;
 
-       /* Description */
        object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
 
        if (p_ptr->mighty_throw) mult += 3;
@@ -3684,7 +3402,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                p_ptr->redraw |= (PR_EQUIPPY);
        }
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Rogue and Ninja gets bonus */
@@ -3695,8 +3412,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        y = p_ptr->y;
        x = p_ptr->x;
 
-
-       /* Hack -- Handle stuff */
        handle_stuff();
 
        if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
@@ -3734,8 +3449,8 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                /* The player can see the (on screen) missile */
                if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
                {
-                       char c = object_char(q_ptr);
-                       byte a = object_attr(q_ptr);
+                       SYMBOL_CODE c = object_char(q_ptr);
+                       TERM_COLOR a = object_attr(q_ptr);
 
                        /* Draw, Hilite, Fresh, Pause, Erase */
                        print_rel(c, a, ny[cur_dis], nx[cur_dis]);
@@ -3768,7 +3483,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                if (cave[y][x].m_idx)
                {
                        cave_type *c_ptr = &cave[y][x];
-
                        monster_type *m_ptr = &m_list[c_ptr->m_idx];
 
                        /* Check the visibility */
@@ -3792,20 +3506,13 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                /* Handle visible monster */
                                else
                                {
-                                       char m_name[80];
-
-                                       /* Get "the monster" or "it" */
+                                       GAME_TEXT m_name[MAX_NLEN];
                                        monster_desc(m_name, m_ptr, 0);
-
-                                       /* Message */
                                        msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
 
                                        if (m_ptr->ml)
                                        {
-                                               /* Hack -- Track this monster race */
                                                if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-
-                                               /* Hack -- Track this monster */
                                                health_track(c_ptr->m_idx);
                                        }
                                }
@@ -3815,7 +3522,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                ds = q_ptr->ds;
                                torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
                                tdam = damroll(dd, ds);
-                               /* Apply special damage XXX XXX XXX */
+                               /* Apply special damage */
                                tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
                                tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
                                if (q_ptr->to_d > 0)
@@ -3852,7 +3559,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                        tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
 
                                /* Hit the monster, check for death */
-                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
+                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
                                {
                                        /* Dead monster */
                                }
@@ -3860,25 +3567,17 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                /* No death */
                                else
                                {
-                                       /* Message */
                                        message_pain(c_ptr->m_idx, tdam);
 
                                        /* Anger the monster */
                                        if ((tdam > 0) && !object_is_potion(q_ptr))
                                                anger_monster(m_ptr);
 
-                                       /* Take note */
                                        if (fear && m_ptr->ml)
                                        {
-                                               char m_name[80];
-
-                                               /* Sound */
                                                sound(SOUND_FLEE);
-
-                                               /* Get the monster name (or "it") */
+                                               GAME_TEXT m_name[MAX_NLEN];
                                                monster_desc(m_name, m_ptr, 0);
-
-                                               /* Message */
                                                msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
                                        }
                                }
@@ -3900,8 +3599,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        {
                j = 100;
 
-               if (!(summon_named_creature(0, y, x, q_ptr->pval,
-                                           !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
+               if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
                        msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
                else if (object_is_cursed(q_ptr))
                        msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
@@ -3914,7 +3612,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        {
                if (hit_body || hit_wall || (randint1(100) < j))
                {
-                       /* Message */
                        msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
 
                        if (potion_smash_effect(0, y, x, q_ptr->k_idx))
@@ -3926,7 +3623,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                                    is_friendly(&m_list[cave[y][x].m_idx]) &&
                                    !MON_INVULNER(m_ptr))
                                {
-                                       char m_name[80];
+                                       GAME_TEXT m_name[MAX_NLEN];
                                        monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
                                        msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
                                        set_hostile(&m_list[cave[y][x].m_idx]);
@@ -4009,22 +3706,13 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        /* Wear the new stuff */
                        object_copy(o_ptr, q_ptr);
 
-                       /* Increase the weight */
                        p_ptr->total_weight += q_ptr->weight;
 
                        /* Increment the equip counter by hand */
                        equip_cnt++;
 
-                       /* Recalculate bonuses */
-                       p_ptr->update |= (PU_BONUS);
-
                        /* Recalculate torch */
-                       p_ptr->update |= (PU_TORCH);
-
-                       /* Recalculate mana XXX */
-                       p_ptr->update |= (PU_MANA);
-
-                       /* Window stuff */
+                       p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
                        p_ptr->window |= (PW_EQUIP);
                }
                else
@@ -4039,17 +3727,14 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                calc_android_exp();
        }
 
-       /* Drop (or break) near that location */
        if (do_drop)
        {
                if (cave_have_flag_bold(y, x, FF_PROJECT))
                {
-                       /* Drop (or break) near that location */
                        (void)drop_near(q_ptr, j, y, x);
                }
                else
                {
-                       /* Drop (or break) near that location */
                        (void)drop_near(q_ptr, j, prev_y, prev_x);
                }
        }
@@ -4075,18 +3760,16 @@ static POSITION temp2_y[MAX_SHORT];
  */
 void forget_travel_flow(void)
 {
-       int x, y;
-
-       /* Check the entire dungeon */
+       POSITION x, y;
+       /* Check the entire dungeon / Forget the old data */
        for (y = 0; y < cur_hgt; y++)
        {
                for (x = 0; x < cur_wid; x++)
                {
-                       /* Forget the old data */
+                       
                        travel.cost[y][x] = MAX_SHORT;
                }
        }
-
        travel.y = travel.x = 0;
 }
 
@@ -4096,7 +3779,7 @@ void forget_travel_flow(void)
  * @param x 該当地点のX座標
  * @return コスト値
  */
-static int travel_flow_cost(int y, int x)
+static int travel_flow_cost(POSITION y, POSITION x)
 {
        feature_type *f_ptr = &f_info[cave[y][x].feat];
        int cost = 1;
@@ -4196,9 +3879,9 @@ static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
  * @param tx 目標地点のX座標
  * @return なし
  */
-static void travel_flow(int ty, int tx)
+static void travel_flow(POSITION ty, POSITION tx)
 {
-       int x, y, d;
+       POSITION x, y, d;
        bool wall = FALSE;
        feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
 
@@ -4244,7 +3927,7 @@ void do_cmd_travel(void)
 {
        POSITION x, y;
        int i;
-       int dx, dy, sx, sy;
+       POSITION dx, dy, sx, sy;
        feature_type *f_ptr;
 
        if (travel.x != 0 && travel.y != 0 &&