OSDN Git Service

[Fix] #38993 current_floor -> current_floor_ptr
[hengband/hengband.git] / src / monster-process.c
index c0c616a..f623d6d 100644 (file)
 #include "cmd-pet.h"
 #include "monsterrace-hook.h"
 #include "melee.h"
+#include "projection.h"
+#include "spells-summon.h"
+#include "quest.h"
+#include "avatar.h"
+#include "realm-hex.h"
+#include "object-hook.h"
+#include "feature.h"
+#include "grid.h"
 
 
 /*!
@@ -467,7 +475,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        int i, best = 999;
        POSITION y, x, y1, x1;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
        bool can_open_door = FALSE;
        int now_cost;
 
@@ -482,7 +490,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        if (projectable(y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
 
        /* Set current grid cost */
-       now_cost = cave[y1][x1].cost;
+       now_cost = current_floor_ptr->grid_array[y1][x1].cost;
        if (now_cost == 0) now_cost = 999;
 
        /* Can monster bash or open doors? */
@@ -505,15 +513,15 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                /* Simply move to player */
                if (player_bold(y, x)) return (FALSE);
 
-               c_ptr = &cave[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
-               cost = c_ptr->cost;
+               cost = g_ptr->cost;
 
                /* Monster cannot kill or pass walls */
                if (!(((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) || ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding))))
                {
                        if (cost == 0) continue;
-                       if (!can_open_door && is_closed_door(c_ptr->feat)) continue;
+                       if (!can_open_door && is_closed_door(g_ptr->feat)) continue;
                }
 
                /* Hack -- for kill or pass wall monster.. */
@@ -572,7 +580,7 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        int i, best;
        POSITION y, x, y1, x1;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
        bool use_scent = FALSE;
 
        monster_type *m_ptr = &m_list[m_idx];
@@ -602,19 +610,19 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        if (player_has_los_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
 
        /* Monster grid */
-       c_ptr = &cave[y1][x1];
+       g_ptr = &current_floor_ptr->grid_array[y1][x1];
 
        /* If we can hear noises, advance towards them */
-       if (c_ptr->cost)
+       if (g_ptr->cost)
        {
                best = 999;
        }
 
        /* Otherwise, try to follow a scent trail */
-       else if (c_ptr->when)
+       else if (g_ptr->when)
        {
                /* Too old smell */
-               if (cave[p_ptr->y][p_ptr->x].when - c_ptr->when > 127) return (FALSE);
+               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when - g_ptr->when > 127) return (FALSE);
 
                use_scent = TRUE;
                best = 0;
@@ -635,12 +643,12 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
                /* Ignore locations off of edge */
                if (!in_bounds2(y, x)) continue;
 
-               c_ptr = &cave[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* We're following a scent trail */
                if (use_scent)
                {
-                       int when = c_ptr->when;
+                       int when = g_ptr->when;
 
                        /* Accept younger scent */
                        if (best > when) continue;
@@ -653,8 +661,8 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
                        int cost;
 
                        if (r_ptr->flags2 & (RF2_BASH_DOOR | RF2_OPEN_DOOR))
-                               cost = c_ptr->dist;
-                       else cost = c_ptr->cost;
+                               cost = g_ptr->dist;
+                       else cost = g_ptr->cost;
 
                        /* Accept louder sounds */
                        if ((cost == 0) || (best < cost)) continue;
@@ -714,13 +722,13 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                if (!in_bounds2(y, x)) continue;
 
                /* Don't move toward player */
-               /* if (cave[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
+               /* if (current_floor_ptr->grid_array[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
 
                /* Calculate distance of this grid from our destination */
                dis = distance(y, x, y1, x1);
 
                /* Score this grid */
-               s = 5000 / (dis + 3) - 500 / (cave[y][x].dist + 1);
+               s = 5000 / (dis + 3) - 500 / (current_floor_ptr->grid_array[y][x].dist + 1);
 
                /* No negative scores */
                if (s < 0) s = 0;
@@ -890,7 +898,7 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        POSITION *y_offsets;
        POSITION *x_offsets;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        /* Start with adjacent locations, spread further */
        for (d = 1; d < 10; d++)
@@ -910,19 +918,19 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                        /* Skip illegal locations */
                        if (!in_bounds(y, x)) continue;
 
-                       c_ptr = &cave[y][x];
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Skip locations in a wall */
-                       if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
+                       if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
 
                        /* Check for "availability" (if monsters can flow) */
                        if (!(m_ptr->mflag2 & MFLAG2_NOFLOW))
                        {
                                /* Ignore grids very far from the player */
-                               if (c_ptr->dist == 0) continue;
+                               if (g_ptr->dist == 0) continue;
 
                                /* Ignore too-distant grids */
-                               if (c_ptr->dist > cave[fy][fx].dist + 2 * d) continue;
+                               if (g_ptr->dist > current_floor_ptr->grid_array[fy][fx].dist + 2 * d) continue;
                        }
 
                        /* Check for absence of shot (more or less) */
@@ -1055,14 +1063,14 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
        POSITION     x2 = p_ptr->x;
        bool         done = FALSE;
        bool         will_run = mon_will_run(m_idx);
-       cave_type    *c_ptr;
-       bool         no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (cave[m_ptr->fy][m_ptr->fx].cost > 2));
+       grid_type    *g_ptr;
+       bool         no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].cost > 2));
        bool         can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall));
 
        /* Counter attack to an enemy monster */
        if (!will_run && m_ptr->target_y)
        {
-               int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+               int t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                /* The monster must be an enemy, and in LOS */
                if (t_m_idx &&
@@ -1080,7 +1088,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
        if (!done && !will_run && is_hostile(m_ptr) &&
            (r_ptr->flags1 & RF1_FRIENDS) &&
            ((los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
-           (cave[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
+           (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
        {
        /*
         * Animal packs try to get the player out of corridors
@@ -1099,16 +1107,16 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
 
                                if (!in_bounds2(yy, xx)) continue;
 
-                               c_ptr = &cave[yy][xx];
+                               g_ptr = &current_floor_ptr->grid_array[yy][xx];
 
                                /* Check grid */
-                               if (monster_can_cross_terrain(c_ptr->feat, r_ptr, 0))
+                               if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
                                {
                                        /* One more room grid */
                                        room++;
                                }
                        }
-                       if (cave[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+                       if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
                        if (!r_ptr->flags4 && !r_ptr->a_ability_flags1 && !r_ptr->a_ability_flags2) room -= 2;
 
                        /* Not in a room and strong player */
@@ -1121,7 +1129,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
                }
 
                /* Monster groups try to surround the player */
-               if (!done && (cave[m_ptr->fy][m_ptr->fx].dist < 3))
+               if (!done && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
                {
                        int i;
 
@@ -1448,7 +1456,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
        /* Not allowed to attack */
        if (r_ptr->flags1 & RF1_NEVER_BLOW) return FALSE;
 
-       if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) return (FALSE);
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE) return (FALSE);
 
        /* Total armor */
        ac = tr_ptr->ac;
@@ -2079,7 +2087,7 @@ void process_monster(MONSTER_IDX m_idx)
 
        DIRECTION mm[8];
 
-       cave_type       *c_ptr;
+       grid_type       *g_ptr;
        feature_type    *f_ptr;
 
        monster_type    *y_ptr;
@@ -2336,7 +2344,7 @@ void process_monster(MONSTER_IDX m_idx)
                        {
                                /* Ignore locations off of edge */
                                if (!in_bounds2(y, x)) continue;
-                               if (cave[y][x].m_idx) k++;
+                               if (current_floor_ptr->grid_array[y][x].m_idx) k++;
                        }
                }
 
@@ -2441,7 +2449,7 @@ void process_monster(MONSTER_IDX m_idx)
                /* Give priority to counter attack? */
                if (m_ptr->target_y)
                {
-                       MONSTER_IDX t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+                       MONSTER_IDX t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                        /* The monster must be an enemy, and projectable */
                        if (t_m_idx && are_enemies(m_ptr, &m_list[t_m_idx]) &&
@@ -2614,13 +2622,13 @@ void process_monster(MONSTER_IDX m_idx)
                /* Ignore locations off of edge */
                if (!in_bounds2(ny, nx)) continue;
 
-               /* Access that cave grid */
-               c_ptr = &cave[ny][nx];
-               f_ptr = &f_info[c_ptr->feat];
-               can_cross = monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
+               /* Access that grid */
+               g_ptr = &current_floor_ptr->grid_array[ny][nx];
+               f_ptr = &f_info[g_ptr->feat];
+               can_cross = monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
 
-               /* Access that cave grid's contents */
-               y_ptr = &m_list[c_ptr->m_idx];
+               /* Access that grid's contents */
+               y_ptr = &m_list[g_ptr->m_idx];
 
                /* Hack -- player 'in' wall */
                if (player_bold(ny, nx))
@@ -2629,7 +2637,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Possibly a monster to attack */
-               else if (c_ptr->m_idx)
+               else if (g_ptr->m_idx)
                {
                        do_move = TRUE;
                }
@@ -2664,7 +2672,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Handle doors and secret doors */
-               else if (is_closed_door(c_ptr->feat))
+               else if (is_closed_door(g_ptr->feat))
                {
                        bool may_bash = TRUE;
 
@@ -2733,7 +2741,7 @@ void process_monster(MONSTER_IDX m_idx)
                        if (did_open_door || did_bash_door)
                        {
                                /* Break down the door */
-                               if (did_bash_door && ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
+                               if (did_bash_door && ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
                                {
                                        cave_alter_feat(ny, nx, FF_BASH);
 
@@ -2754,7 +2762,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        cave_alter_feat(ny, nx, FF_OPEN);
                                }
 
-                               f_ptr = &f_info[c_ptr->feat];
+                               f_ptr = &f_info[g_ptr->feat];
 
                                /* Handle viewable doors */
                                do_view = TRUE;
@@ -2762,7 +2770,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Hack -- check for Glyph of Warding */
-               if (do_move && is_glyph_grid(c_ptr) &&
+               if (do_move && is_glyph_grid(g_ptr) &&
                    !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
                {
                        /* Assume no move allowed */
@@ -2772,17 +2780,17 @@ void process_monster(MONSTER_IDX m_idx)
                        if (!is_pet(m_ptr) && (randint1(BREAK_GLYPH) < r_ptr->level))
                        {
                                /* Describe observable breakage */
-                               if (c_ptr->info & CAVE_MARK)
+                               if (g_ptr->info & CAVE_MARK)
                                {
                                        msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
                                }
 
                                /* Forget the rune */
-                               c_ptr->info &= ~(CAVE_MARK);
+                               g_ptr->info &= ~(CAVE_MARK);
 
                                /* Break the rune */
-                               c_ptr->info &= ~(CAVE_OBJECT);
-                               c_ptr->mimic = 0;
+                               g_ptr->info &= ~(CAVE_OBJECT);
+                               g_ptr->mimic = 0;
 
                                /* Allow movement */
                                do_move = TRUE;
@@ -2790,7 +2798,7 @@ void process_monster(MONSTER_IDX m_idx)
                                note_spot(ny, nx);
                        }
                }
-               else if (do_move && is_explosive_rune_grid(c_ptr) &&
+               else if (do_move && is_explosive_rune_grid(g_ptr) &&
                         !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
                {
                        /* Assume no move allowed */
@@ -2803,7 +2811,7 @@ void process_monster(MONSTER_IDX m_idx)
                                if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
                                {
                                        /* Describe observable breakage */
-                                       if (c_ptr->info & CAVE_MARK)
+                                       if (g_ptr->info & CAVE_MARK)
                                        {
                                                msg_print(_("ルーンが爆発した!", "The rune explodes!"));
                                                project(0, 2, ny, nx, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
@@ -2815,11 +2823,11 @@ void process_monster(MONSTER_IDX m_idx)
                                }
 
                                /* Forget the rune */
-                               c_ptr->info &= ~(CAVE_MARK);
+                               g_ptr->info &= ~(CAVE_MARK);
 
                                /* Break the rune */
-                               c_ptr->info &= ~(CAVE_OBJECT);
-                               c_ptr->mimic = 0;
+                               g_ptr->info &= ~(CAVE_OBJECT);
+                               g_ptr->mimic = 0;
 
                                note_spot(ny, nx);
                                lite_spot(ny, nx);
@@ -2844,7 +2852,7 @@ void process_monster(MONSTER_IDX m_idx)
                        }
 
                        /* In anti-melee dungeon, stupid or confused monster takes useless turn */
-                       if (do_move && (d_info[dungeon_type].flags1 & DF1_NO_MELEE))
+                       if (do_move && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
                        {
                                if (!MON_CONFUSED(m_ptr))
                                {
@@ -2874,7 +2882,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* A monster is in the way */
-               if (do_move && c_ptr->m_idx)
+               if (do_move && g_ptr->m_idx)
                {
                        monster_race *z_ptr = &r_info[y_ptr->r_idx];
 
@@ -2884,7 +2892,7 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Attack 'enemies' */
                        if (((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW) &&
                                 (r_ptr->mexp * r_ptr->level > z_ptr->mexp * z_ptr->level) &&
-                                can_cross && (c_ptr->m_idx != p_ptr->riding)) ||
+                                can_cross && (g_ptr->m_idx != p_ptr->riding)) ||
                                are_enemies(m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
                        {
                                if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
@@ -2897,10 +2905,10 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* attack */
                                        if (y_ptr->r_idx && (y_ptr->hp >= 0))
                                        {
-                                               if (monst_attack_monst(m_idx, c_ptr->m_idx)) return;
+                                               if (monst_attack_monst(m_idx, g_ptr->m_idx)) return;
 
                                                /* In anti-melee dungeon, stupid or confused monster takes useless turn */
-                                               else if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
+                                               else if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)
                                                {
                                                        if (MON_CONFUSED(m_ptr)) return;
                                                        else if (r_ptr->flags2 & RF2_STUPID)
@@ -2916,8 +2924,8 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Push past weaker monsters (unless leaving a wall) */
                        else if ((r_ptr->flags2 & RF2_MOVE_BODY) && !(r_ptr->flags1 & RF1_NEVER_MOVE) &&
                                (r_ptr->mexp > z_ptr->mexp) &&
-                               can_cross && (c_ptr->m_idx != p_ptr->riding) &&
-                               monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
+                               can_cross && (g_ptr->m_idx != p_ptr->riding) &&
+                               monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
                        {
                                /* Allow movement */
                                do_move = TRUE;
@@ -2926,7 +2934,7 @@ void process_monster(MONSTER_IDX m_idx)
                                did_move_body = TRUE;
 
                                /* Wake up the moved monster */
-                               (void)set_monster_csleep(c_ptr->m_idx, 0);
+                               (void)set_monster_csleep(g_ptr->m_idx, 0);
 
                                /* Message */
                        }
@@ -2959,7 +2967,7 @@ void process_monster(MONSTER_IDX m_idx)
                                return;
                        }
 
-                       f_ptr = &f_info[c_ptr->feat];
+                       f_ptr = &f_info[g_ptr->feat];
 
                        /* Note changes to viewable region */
                        do_view = TRUE;
@@ -2968,7 +2976,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                if (must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
                {
-                       if (!monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
+                       if (!monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
                        {
                                /* Assume no move allowed */
                                do_move = FALSE;
@@ -3013,21 +3021,21 @@ void process_monster(MONSTER_IDX m_idx)
                        if (!is_riding_mon)
                        {
                                /* Hack -- Update the old location */
-                               cave[oy][ox].m_idx = c_ptr->m_idx;
+                               current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
 
                                /* Mega-Hack -- move the old monster, if any */
-                               if (c_ptr->m_idx)
+                               if (g_ptr->m_idx)
                                {
                                        /* Move the old monster */
                                        y_ptr->fy = oy;
                                        y_ptr->fx = ox;
 
                                        /* Update the old monster */
-                                       update_monster(c_ptr->m_idx, TRUE);
+                                       update_monster(g_ptr->m_idx, TRUE);
                                }
 
                                /* Hack -- Update the new location */
-                               c_ptr->m_idx = m_idx;
+                               g_ptr->m_idx = m_idx;
 
                                /* Move the monster */
                                m_ptr->fy = ny;
@@ -3040,8 +3048,6 @@ void process_monster(MONSTER_IDX m_idx)
                        else
                        {
                                /* sound(SOUND_WALK); */
-
-                               /* Move the player */
                                if (!move_player_effect(ny, nx, MPE_DONT_PICKUP)) break;
                        }
 
@@ -3056,14 +3062,14 @@ void process_monster(MONSTER_IDX m_idx)
                        }
 
                        /* Take or Kill objects on the floor */
-                       if (c_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
+                       if (g_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
                            (!is_pet(m_ptr) || ((p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) && (r_ptr->flags2 & RF2_TAKE_ITEM))))
                        {
                                OBJECT_IDX this_o_idx, next_o_idx;
                                bool do_take = (r_ptr->flags2 & RF2_TAKE_ITEM) ? TRUE : FALSE;
 
                                /* Scan all objects in the grid */
-                               for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+                               for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                                {
                                        BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
                                        GAME_TEXT m_name[MAX_NLEN], o_name[MAX_NLEN];
@@ -3418,14 +3424,14 @@ void process_monsters(void)
                        test = TRUE;
                }
 
-#if 0 /* (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) is always FALSE... */
+#if 0 /* (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[fy][fx].when) is always FALSE... */
                /* Hack -- Monsters can "smell" the player from far away */
                /* Note that most monsters have "aaf" of "20" or so */
                else if (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
                        cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_MOVE) &&
-                       (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) &&
-                       (cave[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
-                       (cave[fy][fx].dist < r_ptr->aaf))
+                       (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[fy][fx].when) &&
+                       (current_floor_ptr->grid_array[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
+                       (current_floor_ptr->grid_array[fy][fx].dist < r_ptr->aaf))
                {
                        /* We can "smell" the player */
                        test = TRUE;