OSDN Git Service

[Refactor] #37353 コメント整理と型の置換 / Refactor comments and type replacement.
[hengband/hengband.git] / src / cave.c
index 9ea6f9c..068557a 100644 (file)
@@ -386,11 +386,11 @@ bool los(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
  * @param x x座標
  * @return 指定された座標に照明がかかっているならTRUEを返す。。
  */
-static bool check_local_illumination(int y, int x)
+static bool check_local_illumination(POSITION y, POSITION x)
 {
        /* Hack -- move towards player */
-       int yy = (y < p_ptr->y) ? (y + 1) : (y > p_ptr->y) ? (y - 1) : y;
-       int xx = (x < p_ptr->x) ? (x + 1) : (x > p_ptr->x) ? (x - 1) : x;
+       POSITION yy = (y < p_ptr->y) ? (y + 1) : (y > p_ptr->y) ? (y - 1) : y;
+       POSITION xx = (x < p_ptr->x) ? (x + 1) : (x > p_ptr->x) ? (x - 1) : x;
 
        /* Check for "local" illumination */
 
@@ -423,7 +423,7 @@ static bool check_local_illumination(int y, int x)
        if (player_has_los_bold((Y), (X))) \
        { \
                /* Update the monster */ \
-               if (cave[(Y)][(X)].m_idx) update_mon(cave[(Y)][(X)].m_idx, FALSE); \
+               if (cave[(Y)][(X)].m_idx) update_monster(cave[(Y)][(X)].m_idx, FALSE); \
 \
                /* Notice and redraw */ \
                note_spot((Y), (X)); \
@@ -437,9 +437,10 @@ static bool check_local_illumination(int y, int x)
  * @param x x座標
  * @return なし
  */
-void update_local_illumination(int y, int x)
+void update_local_illumination(POSITION y, POSITION x)
 {
-       int i, yy, xx;
+       int i;
+       POSITION yy, xx;
 
        if (!in_bounds(y, x)) return;
 
@@ -564,7 +565,7 @@ void update_local_illumination(int y, int x)
  * "glowing" grid.  This prevents the player from being able to "see" the\n
  * walls of illuminated rooms from a corridor outside the room.\n
  */
-bool player_can_see_bold(int y, int x)
+bool player_can_see_bold(POSITION y, POSITION x)
 {
        cave_type *c_ptr;
 
@@ -613,12 +614,10 @@ bool no_lite(void)
  * @details 
  * 条件は永久地形でなく、なおかつ該当のマスにアーティファクトが存在しないか、である。英語の旧コメントに反して*破壊*の抑止判定には現在使われていない。
  */
-bool cave_valid_bold(int y, int x)
+bool cave_valid_bold(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Forbid perma-grids */
        if (cave_perma_grid(c_ptr)) return (FALSE);
@@ -627,8 +626,6 @@ bool cave_valid_bold(int y, int x)
        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 */
@@ -662,7 +659,7 @@ static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_monster(byte *ap, char *cp)
+static void image_monster(TERM_COLOR *ap, char *cp)
 {
        /* Random symbol from set above */
        if (use_graphics)
@@ -690,7 +687,7 @@ static void image_monster(byte *ap, char *cp)
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_object(byte *ap, char *cp)
+static void image_object(TERM_COLOR *ap, char *cp)
 {
        if (use_graphics)
        {
@@ -717,7 +714,7 @@ static void image_object(byte *ap, char *cp)
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_random(byte *ap, char *cp)
+static void image_random(TERM_COLOR *ap, char *cp)
 {
        /* Normally, assume monsters */
        if (randint0(100) < 75)
@@ -796,9 +793,9 @@ static byte lighting_colours[16][2] =
  * @brief 調査中
  * @todo コメントを付加すること
  */
-void apply_default_feat_lighting(byte f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
+void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
 {
-       byte s_attr = f_attr[F_LIT_STANDARD];
+       TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
        byte s_char = f_char[F_LIT_STANDARD];
        int i;
 
@@ -943,20 +940,20 @@ void apply_default_feat_lighting(byte f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
  * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect\n
  * then a whole lot of code should be changed...  XXX XXX\n
  */
-void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
+void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap, char *tcp)
 {
        /* Get the cave */
        cave_type *c_ptr = &cave[y][x];
 
-       s16b this_o_idx, next_o_idx = 0;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Feature code (applying "mimic" field) */
-       s16b feat = get_feat_mimic(c_ptr);
+       FEAT_IDX feat = get_feat_mimic(c_ptr);
 
        /* Access floor */
        feature_type *f_ptr = &f_info[feat];
 
-       byte a;
+       TERM_COLOR a;
        byte c;
 
        /* Boring grids (floors, etc) */
@@ -1196,8 +1193,6 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
        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 */
@@ -1237,7 +1232,6 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                        /* Hack -- hallucination */
                        if (p_ptr->image) image_object(ap, cp);
 
-                       /* Done */
                        break;
                }
        }
@@ -1405,7 +1399,7 @@ void move_cursor_relative(int row, int col)
 /*
  * Place an attr/char pair at the given map coordinate, if legal.
  */
-void print_rel(char c, byte a, int y, int x)
+void print_rel(char c, byte a, TERM_LEN y, TERM_LEN x)
 {
        /* Only do "legal" locations */
        if (panel_contains(y, x))
@@ -1466,12 +1460,10 @@ void print_rel(char c, byte a, int y, int x)
  * optimized primarily for the most common cases, that is, for the
  * non-marked floor grids.
  */
-void note_spot(int y, int x)
+void note_spot(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Blind players see nothing */
        if (p_ptr->blind) return;
@@ -1565,11 +1557,11 @@ void note_spot(int y, int x)
 
 void display_dungeon(void)
 {
-       int x, y;
-       byte a;
+       TERM_LEN x, y;
+       TERM_COLOR a;
        char c;
 
-       byte ta = 0;
+       TERM_COLOR ta = 0;
        char tc = '\0';
 
        for (x = p_ptr->x - Term->wid / 2 + 1; x <= p_ptr->x + Term->wid / 2; x++)
@@ -1619,15 +1611,15 @@ void display_dungeon(void)
  *
  * This function should only be called on "legal" grids
  */
-void lite_spot(int y, int x)
+void lite_spot(POSITION y, POSITION x)
 {
        /* Redraw if on screen */
        if (panel_contains(y, x) && in_bounds2(y, x))
        {
-               byte a;
+               TERM_COLOR a;
                char c;
 
-               byte ta;
+               TERM_COLOR ta;
                char tc;
 
                /* Examine the grid */
@@ -1667,7 +1659,6 @@ void prt_map(void)
 
        int wid, hgt;
 
-       /* Get size */
        Term_get_size(&wid, &hgt);
 
        /* Remove map offset */
@@ -1706,10 +1697,10 @@ void prt_map(void)
                /* Scan the columns of row "y" */
                for (x = xmin; x <= xmax; x++)
                {
-                       byte a;
+                       TERM_COLOR a;
                        char c;
 
-                       byte ta;
+                       TERM_COLOR ta;
                        char tc;
 
                        /* Determine what is there */
@@ -1740,7 +1731,7 @@ void prt_map(void)
 /*
  * print project path
  */
-void prt_path(int y, int x)
+void prt_path(POSITION y, POSITION x)
 {
        int i;
        int path_n;
@@ -1754,25 +1745,22 @@ void prt_path(int y, int x)
        /* Get projection path */
        path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), p_ptr->y, p_ptr->x, y, x, PROJECT_PATH|PROJECT_THRU);
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
-
-       /* Redraw stuff */
        redraw_stuff();
 
        /* Draw path */
        for (i = 0; i < path_n; i++)
        {
-               int ny = GRID_Y(path_g[i]);
-               int nx = GRID_X(path_g[i]);
+               POSITION ny = GRID_Y(path_g[i]);
+               POSITION nx = GRID_X(path_g[i]);
                cave_type *c_ptr = &cave[ny][nx];
 
                if (panel_contains(ny, nx))
                {
-                       byte a = default_color;
+                       TERM_COLOR a = default_color;
                        char c;
 
-                       byte ta;
+                       TERM_COLOR ta;
                        char tc;
 
                        if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
@@ -1840,7 +1828,7 @@ static void display_shortened_item_name(object_type *o_ptr, int y)
        char buf[MAX_NLEN];
        char *c = buf;
        int len = 0;
-       byte attr;
+       TERM_COLOR attr;
 
        object_desc(buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
        attr = tval_to_attr[o_ptr->tval % 128];
@@ -1911,16 +1899,16 @@ void display_map(int *cy, int *cx)
 {
        int i, j, x, y;
 
-       byte ta;
+       TERM_COLOR ta;
        char tc;
 
        byte tp;
 
-       byte **bigma;
+       TERM_COLOR **bigma;
        char **bigmc;
        byte **bigmp;
 
-       byte **ma;
+       TERM_COLOR **ma;
        char **mc;
        byte **mp;
 
@@ -1933,7 +1921,6 @@ void display_map(int *cy, int *cx)
        int **match_autopick_yx;
        object_type ***object_autopick_yx;
 
-       /* Get size */
        Term_get_size(&wid, &hgt);
        hgt -= 2;
        wid -= 14;
@@ -1947,7 +1934,7 @@ void display_map(int *cy, int *cx)
        view_granite_lite = FALSE;
 
        /* Allocate the maps */
-       C_MAKE(ma, (hgt + 2), byte_ptr);
+       C_MAKE(ma, (hgt + 2), TERM_COLOR *);
        C_MAKE(mc, (hgt + 2), char_ptr);
        C_MAKE(mp, (hgt + 2), byte_ptr);
        C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
@@ -1957,7 +1944,7 @@ void display_map(int *cy, int *cx)
        for (y = 0; y < (hgt + 2); y++)
        {
                /* Allocate one row each array */
-               C_MAKE(ma[y], (wid + 2), byte);
+               C_MAKE(ma[y], (wid + 2), TERM_COLOR);
                C_MAKE(mc[y], (wid + 2), char);
                C_MAKE(mp[y], (wid + 2), byte);
                C_MAKE(match_autopick_yx[y], (wid + 2), int);
@@ -1978,7 +1965,7 @@ void display_map(int *cy, int *cx)
        }
 
        /* Allocate the maps */
-       C_MAKE(bigma, (cur_hgt + 2), byte_ptr);
+       C_MAKE(bigma, (cur_hgt + 2), TERM_COLOR *);
        C_MAKE(bigmc, (cur_hgt + 2), char_ptr);
        C_MAKE(bigmp, (cur_hgt + 2), byte_ptr);
 
@@ -1986,7 +1973,7 @@ void display_map(int *cy, int *cx)
        for (y = 0; y < (cur_hgt + 2); y++)
        {
                /* Allocate one row each array */
-               C_MAKE(bigma[y], (cur_wid + 2), byte);
+               C_MAKE(bigma[y], (cur_wid + 2), TERM_COLOR);
                C_MAKE(bigmc[y], (cur_wid + 2), char);
                C_MAKE(bigmp[y], (cur_wid + 2), byte);
 
@@ -2006,7 +1993,6 @@ void display_map(int *cy, int *cx)
        {
                for (j = 0; j < cur_hgt; ++j)
                {
-                       /* Location */
                        x = i / xrat + 1;
                        y = j / yrat + 1;
 
@@ -2040,7 +2026,6 @@ void display_map(int *cy, int *cx)
        {
                for (i = 0; i < cur_wid; ++i)
                {
-                       /* Location */
                        x = i / xrat + 1;
                        y = j / yrat + 1;
 
@@ -2160,7 +2145,7 @@ void display_map(int *cy, int *cx)
        for (y = 0; y < (hgt + 2); y++)
        {
                /* Free one row each array */
-               C_KILL(ma[y], (wid + 2), byte);
+               C_KILL(ma[y], (wid + 2), TERM_COLOR);
                C_KILL(mc[y], (wid + 2), char);
                C_KILL(mp[y], (wid + 2), byte);
                C_KILL(match_autopick_yx[y], (wid + 2), int);
@@ -2168,7 +2153,7 @@ void display_map(int *cy, int *cx)
        }
 
        /* Free each line map */
-       C_KILL(ma, (hgt + 2), byte_ptr);
+       C_KILL(ma, (hgt + 2), TERM_COLOR *);
        C_KILL(mc, (hgt + 2), char_ptr);
        C_KILL(mp, (hgt + 2), byte_ptr);
        C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
@@ -2178,13 +2163,13 @@ void display_map(int *cy, int *cx)
        for (y = 0; y < (cur_hgt + 2); y++)
        {
                /* Free one row each array */
-               C_KILL(bigma[y], (cur_wid + 2), byte);
+               C_KILL(bigma[y], (cur_wid + 2), TERM_COLOR);
                C_KILL(bigmc[y], (cur_wid + 2), char);
                C_KILL(bigmp[y], (cur_wid + 2), byte);
        }
 
        /* Free each line map */
-       C_KILL(bigma, (cur_hgt + 2), byte_ptr);
+       C_KILL(bigma, (cur_hgt + 2), TERM_COLOR *);
        C_KILL(bigmc, (cur_hgt + 2), char_ptr);
        C_KILL(bigmp, (cur_hgt + 2), byte_ptr);
 }
@@ -2193,7 +2178,7 @@ void display_map(int *cy, int *cx)
 /*
  * Display a "small-scale" map of the dungeon for the player
  *
- * Currently, the "player" is displayed on the map.  XXX XXX XXX
+ * Currently, the "player" is displayed on the map.  
  */
 void do_cmd_view_map(void)
 {
@@ -2206,7 +2191,6 @@ void do_cmd_view_map(void)
        /* Note */
        prt(_("お待ち下さい...", "Please wait..."), 0, 0);
 
-       /* Flush */
        Term_fresh();
 
        /* Clear the screen */
@@ -2513,7 +2497,6 @@ void forget_lite(void)
                /* Forget "LITE" flag */
                cave[y][x].info &= ~(CAVE_LITE);
 
-               /* Redraw */
                /* lite_spot(y, x); Perhaps don't need? */
        }
 
@@ -2547,8 +2530,6 @@ void forget_lite(void)
 
 
 /*
- * XXX XXX XXX
- *
  * This macro allows us to efficiently add a grid to the "lite" array,
  * note that we are never called for illegal grids, or for grids which
  * have already been placed into the "lite" array, and we are never
@@ -3338,10 +3319,8 @@ void forget_view(void)
        /* Clear them all */
        for (i = 0; i < view_n; i++)
        {
-               int y = view_y[i];
-               int x = view_x[i];
-
-               /* Access the grid */
+               POSITION y = view_y[i];
+               POSITION x = view_x[i];
                c_ptr = &cave[y][x];
 
                /* Forget that the grid is viewable */
@@ -3393,7 +3372,7 @@ void forget_view(void)
  *
  * This function now returns "TRUE" if vision is "blocked" by grid (y,x).
  */
-static bool update_view_aux(int y, int x, int y1, int x1, int y2, int x2)
+static bool update_view_aux(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
 {
        bool f1, f2, v1, v2, z1, z2, wall;
 
@@ -3422,8 +3401,6 @@ static bool update_view_aux(int y, int x, int y1, int x1, int y2, int x2)
        /* Totally blocked by "unviewable neighbors" */
        if (!v1 && !v2) return (TRUE);
 
-
-       /* Access the grid */
        c_ptr = &cave[y][x];
 
 
@@ -3623,8 +3600,6 @@ void update_view(void)
        {
                y = view_y[n];
                x = view_x[n];
-
-               /* Access the grid */
                c_ptr = &cave[y][x];
 
                /* Mark the grid as not in "view" */
@@ -3647,8 +3622,6 @@ void update_view(void)
        /* Now start on the player */
        y = p_ptr->y;
        x = p_ptr->x;
-
-       /* Access the grid */
        c_ptr = &cave[y][x];
 
        /* Assume the player grid is easily viewable */
@@ -3996,8 +3969,6 @@ void update_view(void)
        {
                y = view_y[n];
                x = view_x[n];
-
-               /* Access the grid */
                c_ptr = &cave[y][x];
 
                /* Clear the "CAVE_XTRA" flag */
@@ -4015,8 +3986,6 @@ void update_view(void)
        {
                y = temp_y[n];
                x = temp_x[n];
-
-               /* Access the grid */
                c_ptr = &cave[y][x];
 
                /* No longer in the array */
@@ -4051,8 +4020,6 @@ void delayed_visual_update(void)
        {
                y = redraw_y[i];
                x = redraw_x[i];
-
-               /* Access the grid */
                c_ptr = &cave[y][x];
 
                /* Update only needed grids (prevent multiple updating) */
@@ -4061,11 +4028,10 @@ void delayed_visual_update(void)
                /* If required, note */
                if (c_ptr->info & CAVE_NOTE) note_spot(y, x);
 
-               /* Redraw */
                lite_spot(y, x);
 
                /* Hack -- Visual update of monster on this grid */
-               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+               if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
 
                /* No longer in the array */
                c_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
@@ -4081,7 +4047,7 @@ void delayed_visual_update(void)
  */
 void forget_flow(void)
 {
-       int x, y;
+       POSITION x, y;
 
        /* Check the entire dungeon */
        for (y = 0; y < cur_hgt; y++)
@@ -4232,8 +4198,8 @@ static int scent_when = 0;
  */
 void update_smell(void)
 {
-       int i, j;
-       int y, x;
+       POSITION i, j;
+       POSITION y, x;
 
        /* Create a table that controls the spread of scent */
        const int scent_adjust[5][5] = 
@@ -4298,12 +4264,13 @@ void update_smell(void)
 /*
  * Hack -- map the current panel (plus some) ala "magic mapping"
  */
-void map_area(int range)
+void map_area(POSITION range)
 {
-       int             i, x, y;
-       cave_type       *c_ptr;
-       s16b            feat;
-       feature_type    *f_ptr;
+       int i;
+       POSITION x, y;
+       cave_type *c_ptr;
+       FEAT_IDX feat;
+       feature_type *f_ptr;
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
@@ -4353,10 +4320,8 @@ void map_area(int range)
                }
        }
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
 
@@ -4380,8 +4345,9 @@ void map_area(int range)
  */
 void wiz_lite(bool ninja)
 {
-       int i, y, x;
-       s16b feat;
+       OBJECT_IDX i;
+       POSITION y, x;
+       FEAT_IDX feat;
        feature_type *f_ptr;
 
        /* Memorize objects */
@@ -4420,8 +4386,8 @@ void wiz_lite(bool ninja)
                                /* Scan all neighbors */
                                for (i = 0; i < 9; i++)
                                {
-                                       int yy = y + ddy_ddd[i];
-                                       int xx = x + ddx_ddd[i];
+                                       POSITION yy = y + ddy_ddd[i];
+                                       POSITION xx = x + ddx_ddd[i];
 
                                        /* Get the grid */
                                        c_ptr = &cave[yy][xx];
@@ -4457,13 +4423,8 @@ void wiz_lite(bool ninja)
                }
        }
 
-       /* Update the monsters */
        p_ptr->update |= (PU_MONSTERS);
-
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
-
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 
        if (p_ptr->special_defense & NINJA_S_STEALTH)
@@ -4478,8 +4439,8 @@ void wiz_lite(bool ninja)
  */
 void wiz_dark(void)
 {
-       int i, y, x;
-
+       OBJECT_IDX i;
+       POSITION y, x;
 
        /* Forget every grid */
        for (y = 1; y < cur_hgt - 1; y++)
@@ -4526,30 +4487,17 @@ void wiz_dark(void)
        /* Forget travel route when we have forgotten map */
        forget_travel_flow();
 
-       /* Mega-Hack -- Forget the view and lite */
        p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
-
-       /* Update the view and lite */
        p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
-
-       /* Update the monsters */
        p_ptr->update |= (PU_MONSTERS);
-
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
-
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
 
-
-
-
-
 /*
  * Change the "feat" flag for a grid, and notice/redraw the grid
  */
-void cave_set_feat(POSITION y, POSITION x, IDX feat)
+void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat)
 {
        cave_type *c_ptr = &cave[y][x];
        feature_type *f_ptr = &f_info[feat];
@@ -4566,7 +4514,8 @@ void cave_set_feat(POSITION y, POSITION x, IDX feat)
                /* Hack -- glow the GLOW terrain */
                if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
                {
-                       int i, yy, xx;
+                       DIRECTION i;
+                       POSITION yy, xx;
 
                        for (i = 0; i < 9; i++)
                        {
@@ -4602,14 +4551,10 @@ void cave_set_feat(POSITION y, POSITION x, IDX feat)
 
        /* Check for change to boring grid */
        if (!have_flag(f_ptr->flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
+       if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
 
-       /* Update the monster */
-       if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
-
-       /* Notice */
        note_spot(y, x);
 
-       /* Redraw */
        lite_spot(y, x);
 
        /* Check if los has changed */
@@ -4629,7 +4574,8 @@ void cave_set_feat(POSITION y, POSITION x, IDX feat)
        /* Hack -- glow the GLOW terrain */
        if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
        {
-               int i, yy, xx;
+               DIRECTION i;
+               POSITION yy, xx;
                cave_type *cc_ptr;
 
                for (i = 0; i < 9; i++)
@@ -4642,13 +4588,10 @@ void cave_set_feat(POSITION y, POSITION x, IDX feat)
 
                        if (player_has_los_grid(cc_ptr))
                        {
-                               /* Update the monster */
-                               if (cc_ptr->m_idx) update_mon(cc_ptr->m_idx, FALSE);
+                               if (cc_ptr->m_idx) update_monster(cc_ptr->m_idx, FALSE);
 
-                               /* Notice */
                                note_spot(yy, xx);
 
-                               /* Redraw */
                                lite_spot(yy, xx);
                        }
 
@@ -4663,7 +4606,7 @@ void cave_set_feat(POSITION y, POSITION x, IDX feat)
 }
 
 
-IDX conv_dungeon_feat(IDX newfeat)
+FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
 {
        feature_type *f_ptr = &f_info[newfeat];
 
@@ -4697,7 +4640,7 @@ IDX conv_dungeon_feat(IDX newfeat)
  * Take a feature, determine what that feature becomes
  * through applying the given action.
  */
-IDX feat_state(IDX feat, int action)
+FEAT_IDX feat_state(FEAT_IDX feat, int action)
 {
        feature_type *f_ptr = &f_info[feat];
        int i;
@@ -4717,7 +4660,7 @@ IDX feat_state(IDX feat, int action)
  * Takes a location and action and changes the feature at that 
  * location through applying the given action.
  */
-void cave_alter_feat(int y, int x, int action)
+void cave_alter_feat(POSITION y, POSITION x, int action)
 {
        /* Set old feature */
        IDX oldfeat = cave[y][x].feat;
@@ -4773,7 +4716,7 @@ void cave_alter_feat(int y, int x, int action)
 
 
 /* Remove a mirror */
-void remove_mirror(int y, int x)
+void remove_mirror(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
 
@@ -4785,17 +4728,13 @@ void remove_mirror(int y, int x)
        {
                c_ptr->info &= ~(CAVE_GLOW);
                if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
-
-               /* Update the monster */
-               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+               if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
 
                update_local_illumination(y, x);
        }
 
-       /* Notice */
        note_spot(y, x);
 
-       /* Redraw */
        lite_spot(y, x);
 }
 
@@ -4840,9 +4779,9 @@ bool is_explosive_rune_grid(cave_type *c_ptr)
  * Calculate "incremental motion". Used by project() and shoot().
  * Assumes that (*y,*x) lies on the path from (y1,x1) to (y2,x2).
  */
-void mmove2(int *y, int *x, int y1, int x1, int y2, int x2)
+void mmove2(POSITION *y, POSITION *x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
 {
-       int dy, dx, dist, shift;
+       POSITION dy, dx, dist, shift;
 
        /* Extract the distance travelled */
        dy = (*y < y1) ? y1 - *y : *y - y1;
@@ -4934,13 +4873,10 @@ bool projectable(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
  *
  * Currently the "m" parameter is unused.
  */
-void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, int m)
+void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode)
 {
        POSITION nx, ny;
 
-       /* Unused */
-       m = m;
-
        /* Pick a location */
        while (TRUE)
        {
@@ -4954,8 +4890,15 @@ void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, int
                /* Ignore "excessively distant" locations */
                if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
 
-               /* Require "line of projection" */
-               if (projectable(y, x, ny, nx)) break;
+               if (mode & PROJECT_LOS)
+               {
+                       if(los(y, x, ny, nx)) break;
+               }
+               else
+               {
+                       if(projectable(y, x, ny, nx)) break;
+               }
+
        }
 
        /* Save the location */
@@ -4991,7 +4934,6 @@ void monster_race_track(MONRACE_IDX r_idx)
        /* Save this monster ID */
        p_ptr->monster_race_idx = r_idx;
 
-       /* Window stuff */
        p_ptr->window |= (PW_MONSTER);
 }
 
@@ -5000,12 +4942,11 @@ void monster_race_track(MONRACE_IDX r_idx)
 /*
  * Hack -- track the given object kind
  */
-void object_kind_track(IDX k_idx)
+void object_kind_track(KIND_OBJECT_IDX k_idx)
 {
        /* Save this monster ID */
        p_ptr->object_kind_idx = k_idx;
 
-       /* Window stuff */
        p_ptr->window |= (PW_OBJECT);
 }
 
@@ -5020,7 +4961,7 @@ void object_kind_track(IDX k_idx)
  *
  * All disturbance cancels repeated commands, resting, and running.
  */
-void disturb(int stop_search, int stop_travel)
+void disturb(bool stop_search, bool stop_travel)
 {
 #ifndef TRAVEL
        /* Unused */
@@ -5087,7 +5028,8 @@ void disturb(int stop_search, int stop_travel)
  */
 void glow_deep_lava_and_bldg(void)
 {
-       int y, x, i, yy, xx;
+       POSITION y, x, yy, xx;
+       DIRECTION i;
        cave_type *c_ptr;
 
        /* Not in the darkness dungeon */
@@ -5117,6 +5059,83 @@ void glow_deep_lava_and_bldg(void)
        /* Update the view and lite */
        p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 }
+
+/*!
+* @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
+* @param m_idx モンスターID
+* @param y 移動先Y座標
+* @param x 移動先X座標
+* @param mode オプション
+* @return テレポート先として妥当ならばtrue
+*/
+bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, POSITION y, POSITION x, BIT_FLAGS mode)
+{
+       monster_type *m_ptr = &m_list[m_idx];
+       cave_type    *c_ptr = &cave[y][x];
+       feature_type *f_ptr = &f_info[c_ptr->feat];
+
+       /* Require "teleportable" space */
+       if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
+
+       if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
+       if (player_bold(y, x)) return FALSE;
+
+       /* Hack -- no teleport onto glyph of warding */
+       if (is_glyph_grid(c_ptr)) return FALSE;
+       if (is_explosive_rune_grid(c_ptr)) return FALSE;
+
+       if (!(mode & TELEPORT_PASSIVE))
+       {
+               if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
+       }
+
+       return TRUE;
+}
+
+/*!
+* @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
+* @param y 移動先Y座標
+* @param x 移動先X座標
+* @param mode オプション
+* @return テレポート先として妥当ならばtrue
+*/
+bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode)
+{
+       cave_type    *c_ptr = &cave[y][x];
+       feature_type *f_ptr = &f_info[c_ptr->feat];
+
+       /* Require "teleportable" space */
+       if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
+
+       /* No magical teleporting into vaults and such */
+       if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
+
+       if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
+
+       /* don't teleport on a trap. */
+       if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
+
+       if (!(mode & TELEPORT_PASSIVE))
+       {
+               if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
+
+               if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
+               {
+                       if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
+               }
+
+               if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
+               {
+                       /* Always forbid deep lava */
+                       if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
+
+                       /* Forbid shallow lava when the player don't have levitation */
+                       if (!p_ptr->levitation) return FALSE;
+               }
+
+       }
+
+       return TRUE;
+}