OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / grid.c
index 3e4a490..ffbc76b 100644 (file)
@@ -28,6 +28,7 @@
 #include "monster.h"
 #include "quest.h"
 #include "feature.h"
+#include "monster-status.h"
 
 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
 static int match_autopick;
@@ -1376,8 +1377,6 @@ bool cave_valid_bold(POSITION y, POSITION x)
        {
                object_type *o_ptr;
                o_ptr = &current_floor_ptr->o_list[this_o_idx];
-
-               /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
 
                /* Forbid artifact grids */
@@ -1943,8 +1942,6 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLO
        {
                object_type *o_ptr;
                o_ptr = &current_floor_ptr->o_list[this_o_idx];
-
-               /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
 
                /* Memorized objects */
@@ -2151,7 +2148,7 @@ void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
                /* Hack -- fake monochrome */
                if (!use_graphics)
                {
-                       if (world_monster) a = TERM_DARK;
+                       if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
                        else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                }
@@ -2231,8 +2228,6 @@ void note_spot(POSITION y, POSITION x)
        for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
-
-               /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
 
                /* Memorize objects */
@@ -2315,7 +2310,7 @@ void display_dungeon(void)
                                /* Hack -- fake monochrome */
                                if (!use_graphics)
                                {
-                                       if (world_monster) a = TERM_DARK;
+                                       if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
                                        else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
                                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                                }
@@ -2366,7 +2361,7 @@ void lite_spot(POSITION y, POSITION x)
                /* Hack -- fake monochrome */
                if (!use_graphics)
                {
-                       if (world_monster) a = TERM_DARK;
+                       if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
                        else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                }
@@ -2447,7 +2442,7 @@ void prt_map(void)
                        /* Hack -- fake monochrome */
                        if (!use_graphics)
                        {
-                               if (world_monster) a = TERM_DARK;
+                               if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
                                else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
                                else if (p_ptr->wraith_form) a = TERM_L_DARK;
                        }
@@ -2516,7 +2511,7 @@ void prt_path(POSITION y, POSITION x)
 
                        if (!use_graphics)
                        {
-                               if (world_monster) a = TERM_DARK;
+                               if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
                                else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
                                else if (p_ptr->wraith_form) a = TERM_L_DARK;
                        }
@@ -2828,7 +2823,7 @@ void display_map(int *cy, int *cx)
                        /* Hack -- fake monochrome */
                        if (!use_graphics)
                        {
-                               if (world_monster) ta = TERM_DARK;
+                               if (current_world_ptr->timewalk_m_idx) ta = TERM_DARK;
                                else if (IS_INVULN() || p_ptr->timewalk) ta = TERM_WHITE;
                                else if (p_ptr->wraith_form) ta = TERM_L_DARK;
                        }
@@ -3214,7 +3209,8 @@ void do_cmd_view_map(void)
   */
 void forget_lite(void)
 {
-       int i, x, y;
+       int i;
+       POSITION x, y;
 
        /* None to forget */
        if (!current_floor_ptr->lite_n) return;
@@ -3254,8 +3250,8 @@ void forget_lite(void)
        if (!((C)->info & CAVE_REDRAW)) \
        { \
                (C)->info |= CAVE_REDRAW; \
-               redraw_y[redraw_n] = (Y); \
-               redraw_x[redraw_n++] = (X); \
+               current_floor_ptr->redraw_y[current_floor_ptr->redraw_n] = (Y); \
+               current_floor_ptr->redraw_x[current_floor_ptr->redraw_n++] = (X); \
        } \
 }
 
@@ -3305,7 +3301,7 @@ void update_lite(void)
 {
        int i;
        POSITION x, y, min_x, max_x, min_y, max_y;
-       int p = p_ptr->cur_lite;
+       POSITION p = p_ptr->cur_lite;
        grid_type *g_ptr;
 
        /*** Special case ***/
@@ -3337,9 +3333,9 @@ void update_lite(void)
                current_floor_ptr->grid_array[y][x].info |= (CAVE_TEMP);
 
                /* Add it to the "seen" set */
-               temp_y[temp_n] = y;
-               temp_x[temp_n] = x;
-               temp_n++;
+               tmp_pos.y[tmp_pos.n] = y;
+               tmp_pos.x[tmp_pos.n] = x;
+               tmp_pos.n++;
        }
 
        /* None left */
@@ -3497,10 +3493,10 @@ void update_lite(void)
        }
 
        /* Clear them all */
-       for (i = 0; i < temp_n; i++)
+       for (i = 0; i < tmp_pos.n; i++)
        {
-               y = temp_y[i];
-               x = temp_x[i];
+               y = tmp_pos.y[i];
+               x = tmp_pos.x[i];
 
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
@@ -3515,7 +3511,7 @@ void update_lite(void)
        }
 
        /* None left */
-       temp_n = 0;
+       tmp_pos.n = 0;
 
        /* Mega-Hack -- Visual update later */
        p_ptr->update |= (PU_DELAY_VIS);
@@ -3589,15 +3585,15 @@ static void mon_lite_hack(POSITION y, POSITION x)
                }
        }
 
-       /* We trust temp_n does not exceed TEMP_MAX */
+       /* We trust tmp_pos.n does not exceed TEMP_MAX */
 
        /* New grid */
        if (!(g_ptr->info & CAVE_MNDK))
        {
                /* Save this square */
-               temp_x[temp_n] = x;
-               temp_y[temp_n] = y;
-               temp_n++;
+               tmp_pos.x[tmp_pos.n] = x;
+               tmp_pos.y[tmp_pos.n] = y;
+               tmp_pos.n++;
        }
 
        /* Darkened grid */
@@ -3675,12 +3671,12 @@ static void mon_dark_hack(POSITION y, POSITION x)
                }
        }
 
-       /* We trust temp_n does not exceed TEMP_MAX */
+       /* We trust tmp_pos.n does not exceed TEMP_MAX */
 
        /* Save this square */
-       temp_x[temp_n] = x;
-       temp_y[temp_n] = y;
-       temp_n++;
+       tmp_pos.x[tmp_pos.n] = x;
+       tmp_pos.y[tmp_pos.n] = y;
+       tmp_pos.n++;
 
        /* Darken it */
        g_ptr->info |= CAVE_MNDK;
@@ -3726,10 +3722,10 @@ void update_mon_lite(void)
        }
 
        /* Empty temp list of new squares to lite up */
-       temp_n = 0;
+       tmp_pos.n = 0;
 
        /* If a monster stops time, don't process */
-       if (!world_monster)
+       if (!current_world_ptr->timewalk_m_idx)
        {
                monster_type *m_ptr;
                monster_race *r_ptr;
@@ -3739,9 +3735,7 @@ void update_mon_lite(void)
                {
                        m_ptr = &current_floor_ptr->m_list[i];
                        r_ptr = &r_info[m_ptr->r_idx];
-
-                       /* Skip dead monsters */
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        /* Is it too far away? */
                        if (m_ptr->cdis > dis_lim) continue;
@@ -3899,7 +3893,7 @@ void update_mon_lite(void)
        }
 
        /* Save end of list of new squares */
-       end_temp = temp_n;
+       end_temp = tmp_pos.n;
 
        /*
         * Look at old set flags to see if there are any changes.
@@ -3936,9 +3930,9 @@ void update_mon_lite(void)
                }
 
                /* Add to end of temp array */
-               temp_x[temp_n] = fx;
-               temp_y[temp_n] = fy;
-               temp_n++;
+               tmp_pos.x[tmp_pos.n] = fx;
+               tmp_pos.y[tmp_pos.n] = fy;
+               tmp_pos.n++;
        }
 
        /* Clear the lite array */
@@ -3947,8 +3941,8 @@ void update_mon_lite(void)
        /* Copy the temp array into the lit array lighting the new squares. */
        for (i = 0; i < end_temp; i++)
        {
-               fx = temp_x[i];
-               fy = temp_y[i];
+               fx = tmp_pos.x[i];
+               fy = tmp_pos.y[i];
 
                /* We trust this grid is in bounds */
 
@@ -3983,15 +3977,15 @@ void update_mon_lite(void)
        }
 
        /* Clear the temp flag for the old lit or darken grids */
-       for (i = end_temp; i < temp_n; i++)
+       for (i = end_temp; i < tmp_pos.n; i++)
        {
                /* We trust this grid is in bounds */
 
-               current_floor_ptr->grid_array[temp_y[i]][temp_x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
+               current_floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
        }
 
-       /* Finished with temp_n */
-       temp_n = 0;
+       /* Finished with tmp_pos.n */
+       tmp_pos.n = 0;
 
        /* Mega-Hack -- Visual update later */
        p_ptr->update |= (PU_DELAY_VIS);
@@ -4046,13 +4040,13 @@ void forget_view(void)
        grid_type *g_ptr;
 
        /* None to forget */
-       if (!view_n) return;
+       if (!current_floor_ptr->view_n) return;
 
        /* Clear them all */
-       for (i = 0; i < view_n; i++)
+       for (i = 0; i < current_floor_ptr->view_n; i++)
        {
-               POSITION y = view_y[i];
-               POSITION x = view_x[i];
+               POSITION y = current_floor_ptr->view_y[i];
+               POSITION x = current_floor_ptr->view_x[i];
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Forget that the grid is viewable */
@@ -4065,7 +4059,7 @@ void forget_view(void)
        }
 
        /* None left */
-       view_n = 0;
+       current_floor_ptr->view_n = 0;
 }
 
 
@@ -4080,9 +4074,9 @@ void forget_view(void)
 {\
     if (!((C)->info & (CAVE_VIEW))){\
     (C)->info |= (CAVE_VIEW); \
-    view_y[view_n] = (Y); \
-    view_x[view_n] = (X); \
-    view_n++;}\
+    current_floor_ptr->view_y[current_floor_ptr->view_n] = (Y); \
+    current_floor_ptr->view_x[current_floor_ptr->view_n] = (X); \
+    current_floor_ptr->view_n++;}\
 }
 
 
@@ -4328,10 +4322,10 @@ void update_view(void)
        /*** Step 0 -- Begin ***/
 
        /* Save the old "view" grids for later */
-       for (n = 0; n < view_n; n++)
+       for (n = 0; n < current_floor_ptr->view_n; n++)
        {
-               y = view_y[n];
-               x = view_x[n];
+               y = current_floor_ptr->view_y[n];
+               x = current_floor_ptr->view_x[n];
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Mark the grid as not in "view" */
@@ -4341,13 +4335,13 @@ void update_view(void)
                g_ptr->info |= (CAVE_TEMP);
 
                /* Add it to the "seen" set */
-               temp_y[temp_n] = y;
-               temp_x[temp_n] = x;
-               temp_n++;
+               tmp_pos.y[tmp_pos.n] = y;
+               tmp_pos.x[tmp_pos.n] = x;
+               tmp_pos.n++;
        }
 
        /* Start over with the "view" array */
-       view_n = 0;
+       current_floor_ptr->view_n = 0;
 
        /*** Step 1 -- adjacent grids ***/
 
@@ -4695,10 +4689,10 @@ void update_view(void)
        /*** Step 5 -- Complete the algorithm ***/
 
        /* Update all the new grids */
-       for (n = 0; n < view_n; n++)
+       for (n = 0; n < current_floor_ptr->view_n; n++)
        {
-               y = view_y[n];
-               x = view_x[n];
+               y = current_floor_ptr->view_y[n];
+               x = current_floor_ptr->view_x[n];
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Clear the "CAVE_XTRA" flag */
@@ -4712,10 +4706,10 @@ void update_view(void)
        }
 
        /* Wipe the old grids, update as needed */
-       for (n = 0; n < temp_n; n++)
+       for (n = 0; n < tmp_pos.n; n++)
        {
-               y = temp_y[n];
-               x = temp_x[n];
+               y = tmp_pos.y[n];
+               x = tmp_pos.x[n];
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* No longer in the array */
@@ -4729,7 +4723,7 @@ void update_view(void)
        }
 
        /* None left */
-       temp_n = 0;
+       tmp_pos.n = 0;
 
        /* Mega-Hack -- Visual update later */
        p_ptr->update |= (PU_DELAY_VIS);
@@ -4747,10 +4741,10 @@ void delayed_visual_update(void)
        grid_type *g_ptr;
 
        /* Update needed grids */
-       for (i = 0; i < redraw_n; i++)
+       for (i = 0; i < current_floor_ptr->redraw_n; i++)
        {
-               y = redraw_y[i];
-               x = redraw_x[i];
+               y = current_floor_ptr->redraw_y[i];
+               x = current_floor_ptr->redraw_x[i];
                g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Update only needed grids (prevent multiple updating) */
@@ -4769,7 +4763,7 @@ void delayed_visual_update(void)
        }
 
        /* None left */
-       redraw_n = 0;
+       current_floor_ptr->redraw_n = 0;
 }
 
 
@@ -4825,7 +4819,7 @@ void update_flow(void)
        int flow_tail = 0;
 
        /* Paranoia -- make sure the array is empty */
-       if (temp_n) return;
+       if (tmp_pos.n) return;
 
        /* The last way-point is on the map */
        if (running && in_bounds(flow_y, flow_x))
@@ -4849,8 +4843,8 @@ void update_flow(void)
        flow_x = p_ptr->x;
 
        /* Add the player's grid to the queue */
-       temp_y[0] = p_ptr->y;
-       temp_x[0] = p_ptr->x;
+       tmp_pos.y[0] = p_ptr->y;
+       tmp_pos.x[0] = p_ptr->x;
 
        /* Now process the queue */
        while (flow_head != flow_tail)
@@ -4858,8 +4852,8 @@ void update_flow(void)
                int ty, tx;
 
                /* Extract the next entry */
-               ty = temp_y[flow_tail];
-               tx = temp_x[flow_tail];
+               ty = tmp_pos.y[flow_tail];
+               tx = tmp_pos.x[flow_tail];
 
                /* Forget that entry */
                if (++flow_tail == TEMP_MAX) flow_tail = 0;
@@ -4897,8 +4891,8 @@ void update_flow(void)
                        if (n == MONSTER_FLOW_DEPTH) continue;
 
                        /* Enqueue that entry */
-                       temp_y[flow_head] = y;
-                       temp_x[flow_head] = x;
+                       tmp_pos.y[flow_head] = y;
+                       tmp_pos.x[flow_head] = x;
 
                        /* Advance the queue */
                        if (++flow_head == TEMP_MAX) flow_head = 0;
@@ -5517,77 +5511,6 @@ void object_kind_track(KIND_OBJECT_IDX k_idx)
 
 
 /*
- * Something has happened to disturb the player.
- *
- * The first arg indicates a major disturbance, which affects search.
- *
- * The second arg is currently unused, but could induce output flush.
- *
- * All disturbance cancels repeated commands, resting, and running.
- */
-void disturb(bool stop_search, bool stop_travel)
-{
-#ifndef TRAVEL
-       /* Unused */
-       stop_travel = stop_travel;
-#endif
-
-       /* Cancel auto-commands */
-       /* command_new = 0; */
-
-       /* Cancel repeated commands */
-       if (command_rep)
-       {
-               /* Cancel */
-               command_rep = 0;
-
-               /* Redraw the state (later) */
-               p_ptr->redraw |= (PR_STATE);
-       }
-
-       /* Cancel Resting */
-       if ((p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH) || (stop_search && (p_ptr->action == ACTION_SEARCH)))
-       {
-               /* Cancel */
-               set_action(ACTION_NONE);
-       }
-
-       /* Cancel running */
-       if (running)
-       {
-               /* Cancel */
-               running = 0;
-
-               /* Check for new panel if appropriate */
-               if (center_player && !center_running) verify_panel();
-
-               /* Calculate torch radius */
-               p_ptr->update |= (PU_TORCH);
-
-               /* Update monster flow */
-               p_ptr->update |= (PU_FLOW);
-       }
-
-#ifdef TRAVEL
-       if (stop_travel)
-       {
-               /* Cancel */
-               travel.run = 0;
-
-               /* Check for new panel if appropriate */
-               if (center_player && !center_running) verify_panel();
-
-               /* Calculate torch radius */
-               p_ptr->update |= (PU_TORCH);
-       }
-#endif
-
-       /* Flush the input if requested */
-       if (flush_disturb) flush();
-}
-
-
-/*
  * Glow deep lava and building entrances in the floor
  */
 void glow_deep_lava_and_bldg(void)