OSDN Git Service

[Refactor] #38993 floor_type 構造体作成。 / Create floor_type structure.
[hengbandforosx/hengbandosx.git] / src / cmd2.c
index 6be7906..bfb6664 100644 (file)
 #include "realm-hex.h"
 #include "geometry.h"
 #include "wild.h"
+#include "grid.h"
+#include "feature.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
  * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
  * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
  */
-bool confirm_leave_level(bool down_stair)
+static bool confirm_leave_level(bool down_stair)
 {
        quest_type *q_ptr = &quest[p_ptr->inside_quest];
 
@@ -138,7 +140,7 @@ void do_cmd_go_up(void)
        bool go_up = FALSE;
 
        /* Player grid */
-       grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
+       grid_type *g_ptr = &current_floor->grid_array[p_ptr->y][p_ptr->x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        int up_num = 0;
@@ -282,7 +284,7 @@ void do_cmd_go_up(void)
 void do_cmd_go_down(void)
 {
        /* Player grid */
-       grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
+       grid_type *g_ptr = &current_floor->grid_array[p_ptr->y][p_ptr->x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        bool fall_trap = FALSE;
@@ -463,7 +465,7 @@ void do_cmd_search(void)
                /* Cancel the arg */
                command_arg = 0;
        }
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Search */
        search();
@@ -479,7 +481,7 @@ void do_cmd_search(void)
  */
 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Scan all objects in the grid */
@@ -521,7 +523,7 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Attempt to unlock it */
        if (o_ptr->pval > 0)
@@ -606,8 +608,8 @@ static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under
                yy = p_ptr->y + ddy_ddd[d];
                xx = p_ptr->x + ddx_ddd[d];
 
-               /* Get the grid_array */
-               g_ptr = &grid_array[yy][xx];
+               /* Get the current_floor->grid_array */
+               g_ptr = &current_floor->grid_array[yy][xx];
 
                /* Must have knowledge */
                if (!(g_ptr->info & (CAVE_MARK))) continue;
@@ -701,11 +703,11 @@ static bool do_cmd_open_aux(POSITION y, POSITION x)
        int i, j;
 
        /* Get requested grid */
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
        bool more = FALSE;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -837,7 +839,7 @@ void do_cmd_open(void)
                x = p_ptr->x + ddx[dir];
 
                /* Get requested grid */
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -854,7 +856,7 @@ void do_cmd_open(void)
                /* Monster in the way */
                else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
                        py_attack(y, x, 0);
                }
@@ -893,11 +895,11 @@ void do_cmd_open(void)
  */
 static bool do_cmd_close_aux(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
        FEAT_IDX old_feat = g_ptr->feat;
        bool more = FALSE;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -982,7 +984,7 @@ void do_cmd_close(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -996,7 +998,7 @@ void do_cmd_close(void)
                /* Monster in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1026,7 +1028,7 @@ void do_cmd_close(void)
  */
 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
 
        /* Must have knowledge */
        if (!(g_ptr->info & CAVE_MARK))
@@ -1070,9 +1072,9 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
        /* Verify legality */
        if (!do_cmd_tunnel_test(y, x)) return (FALSE);
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
-       g_ptr = &grid_array[y][x];
+       g_ptr = &current_floor->grid_array[y][x];
        f_ptr = &f_info[g_ptr->feat];
        power = f_ptr->power;
 
@@ -1218,7 +1220,7 @@ void do_cmd_tunnel(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1238,7 +1240,7 @@ void do_cmd_tunnel(void)
                /* A monster is in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1276,7 +1278,7 @@ bool easy_open_door(POSITION y, POSITION x)
 {
        int i, j;
 
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        /* Must be a closed door */
@@ -1368,7 +1370,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Get the "disarm" factor */
        i = p_ptr->skill_dis;
@@ -1447,7 +1449,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 
 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor->grid_array[y][x];
 
        /* Get feature */
        feature_type *f_ptr = &f_info[g_ptr->feat];
@@ -1463,7 +1465,7 @@ bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
        int i = p_ptr->skill_dis;
        int j;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Penalize some conditions */
        if (p_ptr->blind || no_lite()) i = i / 10;
@@ -1572,7 +1574,7 @@ void do_cmd_disarm(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1629,7 +1631,7 @@ void do_cmd_disarm(void)
  */
 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 {
-       grid_type       *g_ptr = &grid_array[y][x];
+       grid_type       *g_ptr = &current_floor->grid_array[y][x];
 
        /* Get feature */
        feature_type *f_ptr = &f_info[g_ptr->feat];
@@ -1645,7 +1647,7 @@ static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 
        concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
 
@@ -1753,7 +1755,7 @@ void do_cmd_bash(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1767,7 +1769,7 @@ void do_cmd_bash(void)
                /* Monster in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1835,13 +1837,13 @@ void do_cmd_alter(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
                f_ptr = &f_info[feat];
 
-               take_turn(p_ptr, 100);;
+               take_turn(p_ptr, 100);
 
                if (g_ptr->m_idx)
                {
@@ -1957,7 +1959,7 @@ void do_cmd_spike(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1977,7 +1979,7 @@ void do_cmd_spike(void)
                /* Is a monster in the way? */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1988,7 +1990,7 @@ void do_cmd_spike(void)
                /* Go for it */
                else
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        /* Successful jamming */
                        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
@@ -2031,7 +2033,7 @@ void do_cmd_walk(bool pickup)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, FALSE))
        {
-               take_turn(p_ptr, 100);;
+               take_turn(p_ptr, 100);
 
                if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
                {
@@ -2127,7 +2129,7 @@ void do_cmd_stay(bool pickup)
                command_arg = 0;
        }
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        if (pickup) mpe_mode |= MPE_DO_PICKUP;
        (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
@@ -2194,7 +2196,7 @@ void do_cmd_rest(void)
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
 
        /* Take a turn (?) */
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* The sin of sloth */
        if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
@@ -2499,7 +2501,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                p_ptr->redraw |= (PR_EQUIPPY);
        }
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Rogue and Ninja gets bonus */
        if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
@@ -2539,7 +2541,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
                {
                        hit_wall = TRUE;
-                       if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
+                       if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !current_floor->grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
                }
 
                /* The player can see the (on screen) missile */
@@ -2575,9 +2577,9 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                cur_dis++;
 
                /* Monster here, Try to hit it */
-               if (grid_array[y][x].m_idx)
+               if (current_floor->grid_array[y][x].m_idx)
                {
-                       grid_type *g_ptr = &grid_array[y][x];
+                       grid_type *g_ptr = &current_floor->grid_array[y][x];
                        monster_type *m_ptr = &m_list[g_ptr->m_idx];
 
                        /* Check the visibility */
@@ -2711,17 +2713,17 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
                        if (potion_smash_effect(0, y, x, q_ptr->k_idx))
                        {
-                               monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
+                               monster_type *m_ptr = &m_list[current_floor->grid_array[y][x].m_idx];
 
                                /* ToDo (Robert): fix the invulnerability */
-                               if (grid_array[y][x].m_idx &&
-                                   is_friendly(&m_list[grid_array[y][x].m_idx]) &&
+                               if (current_floor->grid_array[y][x].m_idx &&
+                                   is_friendly(&m_list[current_floor->grid_array[y][x].m_idx]) &&
                                    !MON_INVULNER(m_ptr))
                                {
                                        GAME_TEXT m_name[MAX_NLEN];
-                                       monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
+                                       monster_desc(m_name, &m_list[current_floor->grid_array[y][x].m_idx], 0);
                                        msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
-                                       set_hostile(&m_list[grid_array[y][x].m_idx]);
+                                       set_hostile(&m_list[current_floor->grid_array[y][x].m_idx]);
                                }
                        }
                        do_drop = FALSE;