OSDN Git Service

[Refactor] #37353 spells.hにスペルに関する共通定義を追加。。 / Add common definition to spells.h.
[hengband/hengband.git] / src / cave.c
index f56d30b..f0a6800 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 */
@@ -572,7 +574,6 @@ bool player_can_see_bold(POSITION y, POSITION x)
        /* Blind players see nothing */
        if (p_ptr->blind) return FALSE;
 
-       /* Access the cave grid */
        c_ptr = &cave[y][x];
 
        /* Note that "torch-lite" yields "illumination" */
@@ -659,7 +660,7 @@ static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_monster(TERM_COLOR *ap, char *cp)
+static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
 {
        /* Random symbol from set above */
        if (use_graphics)
@@ -687,7 +688,7 @@ static void image_monster(TERM_COLOR *ap, char *cp)
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_object(TERM_COLOR *ap, char *cp)
+static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
 {
        if (use_graphics)
        {
@@ -714,7 +715,7 @@ static void image_object(TERM_COLOR *ap, char *cp)
  * @param cp 本来のシンボル
  * @return なし
  */
-static void image_random(TERM_COLOR *ap, char *cp)
+static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
 {
        /* Normally, assume monsters */
        if (randint0(100) < 75)
@@ -940,7 +941,7 @@ void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_cha
  * "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(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap, char *tcp)
+void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
 {
        /* Get the cave */
        cave_type *c_ptr = &cave[y][x];
@@ -954,7 +955,7 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap,
        feature_type *f_ptr = &f_info[feat];
 
        TERM_COLOR a;
-       byte c;
+       SYMBOL_CODE c;
 
        /* Boring grids (floors, etc) */
        if (!have_flag(f_ptr->flags, FF_REMEMBER))
@@ -1359,13 +1360,8 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, char *cp, TERM_COLOR *tap,
        if (player_bold(y, x))
        {
                monster_race *r_ptr = &r_info[0];
-
-               /* Get the "player" attr */
                *ap = r_ptr->x_attr;
-
-               /* Get the "player" char */
                *cp = r_ptr->x_char;
-
                feat_priority = 31;
        }
 }
@@ -1399,7 +1395,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, TERM_LEN y, TERM_LEN x)
+void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
 {
        /* Only do "legal" locations */
        if (panel_contains(y, x))
@@ -1509,14 +1505,12 @@ void note_spot(POSITION y, POSITION x)
                        if (view_torch_grids &&
                            ((c_ptr->info & (CAVE_LITE | CAVE_MNLT)) || p_ptr->see_nocto))
                        {
-                               /* Memorize */
                                c_ptr->info |= (CAVE_MARK);
                        }
 
                        /* Option -- memorize all perma-lit floors */
                        else if (view_perma_grids && ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW))
                        {
-                               /* Memorize */
                                c_ptr->info |= (CAVE_MARK);
                        }
                }
@@ -1524,28 +1518,24 @@ void note_spot(POSITION y, POSITION x)
                /* Memorize normal grids */
                else if (have_flag(f_ptr->flags, FF_LOS))
                {
-                       /* Memorize */
                        c_ptr->info |= (CAVE_MARK);
                }
 
                /* Memorize torch-lit walls */
                else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
                {
-                       /* Memorize */
                        c_ptr->info |= (CAVE_MARK);
                }
 
                /* Memorize walls seen by noctovision of Ninja */
                else if (p_ptr->see_nocto)
                {
-                       /* Memorize */
                        c_ptr->info |= (CAVE_MARK);
                }
 
                /* Memorize certain non-torch-lit wall grids */
                else if (check_local_illumination(y, x))
                {
-                       /* Memorize */
                        c_ptr->info |= (CAVE_MARK);
                }
        }
@@ -1559,10 +1549,10 @@ void display_dungeon(void)
 {
        TERM_LEN x, y;
        TERM_COLOR a;
-       char c;
+       SYMBOL_CODE c;
 
        TERM_COLOR ta = 0;
-       char tc = '\0';
+       SYMBOL_CODE tc = '\0';
 
        for (x = p_ptr->x - Term->wid / 2 + 1; x <= p_ptr->x + Term->wid / 2; x++)
        {
@@ -1617,10 +1607,10 @@ void lite_spot(POSITION y, POSITION x)
        if (panel_contains(y, x) && in_bounds2(y, x))
        {
                TERM_COLOR a;
-               char c;
+               SYMBOL_CODE c;
 
                TERM_COLOR ta;
-               char tc;
+               SYMBOL_CODE tc;
 
                /* Examine the grid */
                map_info(y, x, &a, &c, &ta, &tc);
@@ -1651,13 +1641,13 @@ 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;
 
        Term_get_size(&wid, &hgt);
 
@@ -1698,10 +1688,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);
@@ -1798,7 +1788,7 @@ void prt_path(POSITION y, POSITION x)
 }
 
 
-static cptr simplify_list[][2] =
+static concptr simplify_list[][2] =
 {
 #ifdef JP
        {"の魔法書", ""},
@@ -1844,7 +1834,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 == '^')
                        {
@@ -1857,7 +1847,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);
@@ -1900,23 +1890,23 @@ void display_map(int *cy, int *cx)
        int i, j, x, y;
 
        TERM_COLOR ta;
-       char tc;
+       SYMBOL_CODE tc;
 
        byte tp;
 
        TERM_COLOR **bigma;
-       char **bigmc;
+       SYMBOL_CODE **bigmc;
        byte **bigmp;
 
        TERM_COLOR **ma;
-       char **mc;
+       SYMBOL_CODE **mc;
        byte **mp;
 
        /* Save lighting effects */
        bool old_view_special_lite = view_special_lite;
        bool old_view_granite_lite = view_granite_lite;
 
-       int hgt, wid, yrat, xrat;
+       TERM_LEN hgt, wid, yrat, xrat;
 
        int **match_autopick_yx;
        object_type ***object_autopick_yx;
@@ -2146,7 +2136,7 @@ void display_map(int *cy, int *cx)
        {
                /* Free one row each array */
                C_KILL(ma[y], (wid + 2), TERM_COLOR);
-               C_KILL(mc[y], (wid + 2), char);
+               C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
                C_KILL(mp[y], (wid + 2), byte);
                C_KILL(match_autopick_yx[y], (wid + 2), int);
                C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
@@ -2164,7 +2154,7 @@ void display_map(int *cy, int *cx)
        {
                /* Free one row each array */
                C_KILL(bigma[y], (cur_wid + 2), TERM_COLOR);
-               C_KILL(bigmc[y], (cur_wid + 2), char);
+               C_KILL(bigmc[y], (cur_wid + 2), SYMBOL_CODE);
                C_KILL(bigmp[y], (cur_wid + 2), byte);
        }
 
@@ -2186,7 +2176,6 @@ void do_cmd_view_map(void)
 
        screen_save();
 
-       /* Note */
        prt(_("お待ち下さい...", "Please wait..."), 0, 0);
 
        Term_fresh();
@@ -2252,8 +2241,6 @@ void do_cmd_view_map(void)
                /* Get any key */
                inkey();
        }
-
-       /* Restore the screen */
        screen_load();
 }
 
@@ -4659,10 +4646,10 @@ FEAT_IDX feat_state(FEAT_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;
@@ -5135,3 +5122,14 @@ bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode)
 
        return TRUE;
 }
+
+/*!
+ * @brief 地形は開くものであって、かつ開かれているかを返す /
+ * Attempt to open the given chest at the given location
+ * @param feat 地形ID
+ * @return 開いた地形である場合TRUEを返す /  Return TRUE if the given feature is an open door
+ */
+bool is_open(FEAT_IDX feat)
+{
+       return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
+}