OSDN Git Service

[Refactor] #37353 PROJECT_* 定義を新規ファイル projection.h へ移動。 / Move PROJECT_* definition...
[hengband/hengband.git] / src / cave.c
index 64414fb..5a0118f 100644 (file)
@@ -17,6 +17,8 @@
 
 
 #include "angband.h"
+#include "world.h"
+#include "projection.h"
 
 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
 static int match_autopick;
@@ -67,7 +69,7 @@ POSITION distance (POSITION y1, POSITION x1, POSITION y2, POSITION x2)
  * @param feat 地形情報のID
  * @return 罠持ちの地形ならばTRUEを返す。
  */
-bool is_trap(IDX feat)
+bool is_trap(FEAT_IDX feat)
 {
        return have_flag(f_info[feat].flags, FF_TRAP);
 }
@@ -90,7 +92,7 @@ bool is_known_trap(cave_type *c_ptr)
  * @param feat 地形情報のID
  * @return 閉じたドアのある地形ならばTRUEを返す。
  */
-bool is_closed_door(IDX feat)
+bool is_closed_door(FEAT_IDX feat)
 {
        feature_type *f_ptr = &f_info[feat];
 
@@ -160,22 +162,22 @@ bool los(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
        POSITION dx, dy;
 
        /* Absolute */
-       int ax, ay;
+       POSITION ax, ay;
 
        /* Signs */
-       int sx, sy;
+       POSITION sx, sy;
 
        /* Fractions */
-       int qx, qy;
+       POSITION qx, qy;
 
        /* Scanners */
-       int tx, ty;
+       POSITION tx, ty;
 
        /* Scale factors */
-       int f1, f2;
+       POSITION f1, f2;
 
        /* Slope, or 1/Slope, of LOS */
-       int m;
+       POSITION m;
 
 
        /* Extract the offset */
@@ -423,7 +425,7 @@ static bool check_local_illumination(POSITION y, POSITION 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)); \
@@ -626,8 +628,6 @@ bool cave_valid_bold(POSITION y, POSITION 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 */
@@ -795,10 +795,10 @@ static byte lighting_colours[16][2] =
  * @brief 調査中
  * @todo コメントを付加すること
  */
-void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
+void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_char[F_LIT_MAX])
 {
        TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
-       byte s_char = f_char[F_LIT_STANDARD];
+       SYMBOL_CODE s_char = f_char[F_LIT_STANDARD];
        int i;
 
        if (is_ascii_graphics(s_attr)) /* For ASCII */
@@ -1195,8 +1195,6 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap,
        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 */
@@ -1236,7 +1234,6 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap,
                        /* Hack -- hallucination */
                        if (p_ptr->image) image_object(ap, cp);
 
-                       /* Done */
                        break;
                }
        }
@@ -1656,15 +1653,14 @@ void lite_spot(POSITION y, POSITION x)
  */
 void prt_map(void)
 {
-       int     x, y;
-       int     v;
+       POSITION x, y;
+       int v;
 
        /* map bounds */
-       s16b xmin, xmax, ymin, ymax;
+       POSITION xmin, xmax, ymin, ymax;
 
-       int wid, hgt;
+       TERM_LEN wid, hgt;
 
-       /* Get size */
        Term_get_size(&wid, &hgt);
 
        /* Remove map offset */
@@ -1704,10 +1700,10 @@ void prt_map(void)
                for (x = xmin; x <= xmax; x++)
                {
                        TERM_COLOR a;
-                       char c;
+                       SYMBOL_CODE c;
 
                        TERM_COLOR ta;
-                       char tc;
+                       SYMBOL_CODE tc;
 
                        /* Determine what is there */
                        map_info(y, x, &a, &c, &ta, &tc);
@@ -1751,17 +1747,14 @@ void prt_path(POSITION y, POSITION 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();
+       handle_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))
@@ -1769,8 +1762,8 @@ void prt_path(POSITION y, POSITION x)
                        TERM_COLOR a = default_color;
                        char c;
 
-                       TERM_COLOR ta;
-                       char tc;
+                       TERM_COLOR ta = default_color;
+                       char tc = '*';
 
                        if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
                        {
@@ -1807,7 +1800,7 @@ void prt_path(POSITION y, POSITION x)
 }
 
 
-static cptr simplify_list[][2] =
+static concptr simplify_list[][2] =
 {
 #ifdef JP
        {"の魔法書", ""},
@@ -1853,7 +1846,7 @@ static void display_shortened_item_name(object_type *o_ptr, int y)
                int i;
                for (i = 0; simplify_list[i][1]; i++)
                {
-                       cptr org_w = simplify_list[i][0];
+                       concptr org_w = simplify_list[i][0];
 
                        if (*org_w == '^')
                        {
@@ -1866,7 +1859,7 @@ static void display_shortened_item_name(object_type *o_ptr, int y)
                        if (!strncmp(c, org_w, strlen(org_w)))
                        {
                                char *s = c;
-                               cptr tmp = simplify_list[i][1];
+                               concptr tmp = simplify_list[i][1];
                                while (*tmp)
                                        *s++ = *tmp++;
                                tmp = c + strlen(org_w);
@@ -1930,7 +1923,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;
@@ -2003,7 +1995,6 @@ void display_map(int *cy, int *cx)
        {
                for (j = 0; j < cur_hgt; ++j)
                {
-                       /* Location */
                        x = i / xrat + 1;
                        y = j / yrat + 1;
 
@@ -2037,7 +2028,6 @@ void display_map(int *cy, int *cx)
        {
                for (i = 0; i < cur_wid; ++i)
                {
-                       /* Location */
                        x = i / xrat + 1;
                        y = j / yrat + 1;
 
@@ -2190,23 +2180,18 @@ 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)
 {
        int cy, cx;
 
-
-       /* Save the screen */
        screen_save();
 
        /* Note */
        prt(_("お待ち下さい...", "Please wait..."), 0, 0);
 
-       /* Flush */
        Term_fresh();
-
-       /* Clear the screen */
        Term_clear();
 
        display_autopick = 0;
@@ -2269,8 +2254,6 @@ void do_cmd_view_map(void)
                /* Get any key */
                inkey();
        }
-
-       /* Restore the screen */
        screen_load();
 }
 
@@ -2510,7 +2493,6 @@ void forget_lite(void)
                /* Forget "LITE" flag */
                cave[y][x].info &= ~(CAVE_LITE);
 
-               /* Redraw */
                /* lite_spot(y, x); Perhaps don't need? */
        }
 
@@ -2544,8 +2526,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
@@ -3337,8 +3317,6 @@ void forget_view(void)
        {
                POSITION y = view_y[i];
                POSITION x = view_x[i];
-
-               /* Access the grid */
                c_ptr = &cave[y][x];
 
                /* Forget that the grid is viewable */
@@ -3419,8 +3397,6 @@ static bool update_view_aux(POSITION y, POSITION x, POSITION y1, POSITION x1, PO
        /* Totally blocked by "unviewable neighbors" */
        if (!v1 && !v2) return (TRUE);
 
-
-       /* Access the grid */
        c_ptr = &cave[y][x];
 
 
@@ -3620,8 +3596,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" */
@@ -3644,8 +3618,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 */
@@ -3993,8 +3965,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 */
@@ -4012,8 +3982,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 */
@@ -4048,8 +4016,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) */
@@ -4058,11 +4024,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);
@@ -4229,8 +4194,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] = 
@@ -4297,10 +4262,11 @@ void update_smell(void)
  */
 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;
 
@@ -4350,10 +4316,8 @@ void map_area(POSITION range)
                }
        }
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
 
@@ -4377,7 +4341,8 @@ void map_area(POSITION range)
  */
 void wiz_lite(bool ninja)
 {
-       int i, y, x;
+       OBJECT_IDX i;
+       POSITION y, x;
        FEAT_IDX feat;
        feature_type *f_ptr;
 
@@ -4454,13 +4419,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)
@@ -4475,8 +4435,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++)
@@ -4523,26 +4483,13 @@ 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
  */
@@ -4563,7 +4510,8 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_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++)
                        {
@@ -4599,14 +4547,10 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_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 */
@@ -4626,7 +4570,8 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_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++)
@@ -4639,13 +4584,10 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_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);
                        }
 
@@ -4660,7 +4602,7 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat)
 }
 
 
-IDX conv_dungeon_feat(IDX newfeat)
+FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
 {
        feature_type *f_ptr = &f_info[newfeat];
 
@@ -4694,7 +4636,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,10 +4659,10 @@ IDX feat_state(IDX feat, int action)
 void cave_alter_feat(POSITION y, POSITION x, int action)
 {
        /* Set old feature */
-       IDX oldfeat = cave[y][x].feat;
+       FEAT_IDX oldfeat = cave[y][x].feat;
 
        /* Get the new feat */
-       IDX newfeat = feat_state(oldfeat, action);
+       FEAT_IDX newfeat = feat_state(oldfeat, action);
 
        /* No change */
        if (newfeat == oldfeat) return;
@@ -4782,17 +4724,13 @@ void remove_mirror(POSITION y, POSITION 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);
 }
 
@@ -4992,7 +4930,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);
 }
 
@@ -5001,12 +4938,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);
 }
 
@@ -5021,7 +4957,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 */
@@ -5088,7 +5024,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 */
@@ -5118,7 +5055,6 @@ 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);
 }