OSDN Git Service

[Refactor] #38997 clear_mon_lite() に floor_type * 引数を追加.
[hengband/hengband.git] / src / floor-events.c
index cf9f525..8ecb563 100644 (file)
@@ -89,7 +89,7 @@ void night_falls(void)
                                }
                        }
 
-                       glow_deep_lava_and_bldg();
+                       glow_deep_lava_and_bldg(current_floor_ptr);
                }
        }
 
@@ -108,18 +108,18 @@ void night_falls(void)
  * @brief 現在フロアに残っている敵モンスターの数を返す /
  * @return 現在の敵モンスターの数
  */
-MONSTER_NUMBER count_all_hostile_monsters(void)
+MONSTER_NUMBER count_all_hostile_monsters(floor_type *floor_ptr)
 {
        POSITION x, y;
        MONSTER_NUMBER number_mon = 0;
 
-       for (x = 0; x < current_floor_ptr->width; ++x)
+       for (x = 0; x < floor_ptr->width; ++x)
        {
-               for (y = 0; y < current_floor_ptr->height; ++y)
+               for (y = 0; y < floor_ptr->height; ++y)
                {
-                       MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
+                       MONSTER_IDX m_idx = floor_ptr->grid_array[y][x].m_idx;
 
-                       if (m_idx > 0 && is_hostile(&current_floor_ptr->m_list[m_idx]))
+                       if (m_idx > 0 && is_hostile(&floor_ptr->m_list[m_idx]))
                        {
                                ++number_mon;
                        }
@@ -141,19 +141,19 @@ MONSTER_NUMBER count_all_hostile_monsters(void)
   * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
   * @return 算出されたダンジョンの雰囲気ランク
   */
-byte get_dungeon_feeling(void)
+byte get_dungeon_feeling(floor_type *floor_ptr)
 {
        const int base = 10;
        int rating = 0;
        MONSTER_IDX i;
 
        /* Hack -- no feeling in the town */
-       if (!current_floor_ptr->dun_level) return 0;
+       if (!floor_ptr->dun_level) return 0;
 
        /* Examine each monster */
-       for (i = 1; i < current_floor_ptr->m_max; i++)
+       for (i = 1; i < floor_ptr->m_max; i++)
        {
-               monster_type *m_ptr = &current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &floor_ptr->m_list[i];
                monster_race *r_ptr;
                int delta = 0;
                if (!monster_is_valid(m_ptr)) continue;
@@ -165,19 +165,19 @@ byte get_dungeon_feeling(void)
                if (r_ptr->flags1 & (RF1_UNIQUE))
                {
                        /* Nearly out-of-depth unique monsters */
-                       if (r_ptr->level + 10 > current_floor_ptr->dun_level)
+                       if (r_ptr->level + 10 > floor_ptr->dun_level)
                        {
                                /* Boost rating by twice delta-depth */
-                               delta += (r_ptr->level + 10 - current_floor_ptr->dun_level) * 2 * base;
+                               delta += (r_ptr->level + 10 - floor_ptr->dun_level) * 2 * base;
                        }
                }
                else
                {
                        /* Out-of-depth monsters */
-                       if (r_ptr->level > current_floor_ptr->dun_level)
+                       if (r_ptr->level > floor_ptr->dun_level)
                        {
                                /* Boost rating by delta-depth */
-                               delta += (r_ptr->level - current_floor_ptr->dun_level) * base;
+                               delta += (r_ptr->level - floor_ptr->dun_level) * base;
                        }
                }
 
@@ -196,9 +196,9 @@ byte get_dungeon_feeling(void)
        }
 
        /* Examine each unidentified object */
-       for (i = 1; i < current_floor_ptr->o_max; i++)
+       for (i = 1; i < floor_ptr->o_max; i++)
        {
-               object_type *o_ptr = &current_floor_ptr->o_list[i];
+               object_type *o_ptr = &floor_ptr->o_list[i];
                object_kind *k_ptr = &k_info[o_ptr->k_idx];
                int delta = 0;
 
@@ -246,10 +246,10 @@ byte get_dungeon_feeling(void)
                if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
 
                /* Out-of-depth objects */
-               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > current_floor_ptr->dun_level)
+               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > floor_ptr->dun_level)
                {
                        /* Rating increase */
-                       delta += (k_ptr->level - current_floor_ptr->dun_level) * base;
+                       delta += (k_ptr->level - floor_ptr->dun_level) * base;
                }
 
                rating += RATING_BOOST(delta);
@@ -273,26 +273,26 @@ byte get_dungeon_feeling(void)
  * / Update dungeon feeling, and announce it if changed
  * @return なし
  */
-void update_dungeon_feeling(void)
+void update_dungeon_feeling(floor_type *floor_ptr)
 {
        byte new_feeling;
        int quest_num;
        int delay;
 
        /* No feeling on the surface */
-       if (!current_floor_ptr->dun_level) return;
+       if (!floor_ptr->dun_level) return;
 
        /* No feeling in the arena */
        if (p_ptr->phase_out) return;
 
        /* Extract delay time */
-       delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - current_floor_ptr->dun_level) * TURNS_PER_TICK / 100;
+       delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - floor_ptr->dun_level) * TURNS_PER_TICK / 100;
 
        /* Not yet felt anything */
        if (current_world_ptr->game_turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
 
        /* Extract quest number (if any) */
-       quest_num = quest_number(current_floor_ptr->dun_level);
+       quest_num = quest_number(floor_ptr->dun_level);
 
        /* No feeling in a quest */
        if (quest_num &&
@@ -302,7 +302,7 @@ void update_dungeon_feeling(void)
 
 
        /* Get new dungeon feeling */
-       new_feeling = get_dungeon_feeling();
+       new_feeling = get_dungeon_feeling(floor_ptr);
 
        /* Remember last time updated */
        p_ptr->feeling_turn = current_world_ptr->game_turn;
@@ -328,7 +328,7 @@ void update_dungeon_feeling(void)
 /*
  * Glow deep lava and building entrances in the floor
  */
-void glow_deep_lava_and_bldg(void)
+void glow_deep_lava_and_bldg(floor_type *floor_ptr)
 {
        POSITION y, x, yy, xx;
        DIRECTION i;
@@ -337,11 +337,11 @@ void glow_deep_lava_and_bldg(void)
        /* Not in the darkness dungeon */
        if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) return;
 
-       for (y = 0; y < current_floor_ptr->height; y++)
+       for (y = 0; y < floor_ptr->height; y++)
        {
-               for (x = 0; x < current_floor_ptr->width; x++)
+               for (x = 0; x < floor_ptr->width; x++)
                {
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       g_ptr = &floor_ptr->grid_array[y][x];
 
                        /* Feature code (applying "mimic" field) */
 
@@ -352,7 +352,7 @@ void glow_deep_lava_and_bldg(void)
                                        yy = y + ddy_ddd[i];
                                        xx = x + ddx_ddd[i];
                                        if (!in_bounds2(yy, xx)) continue;
-                                       current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
+                                       floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
                                }
                        }
                }
@@ -1491,7 +1491,7 @@ static void mon_dark_hack(POSITION y, POSITION x)
  * updating.  Only squares in view of the player, whos state
  * changes are drawn via lite_spot().
  */
-void update_mon_lite(void)
+void update_mon_lite(floor_type *floor_ptr)
 {
        int i, rad;
        grid_type *g_ptr;
@@ -1507,10 +1507,10 @@ void update_mon_lite(void)
                (MAX_SIGHT / 2 + 1) : (MAX_SIGHT + 3);
 
        /* Clear all monster lit squares */
-       for (i = 0; i < current_floor_ptr->mon_lite_n; i++)
+       for (i = 0; i < floor_ptr->mon_lite_n; i++)
        {
                /* Point to grid */
-               g_ptr = &current_floor_ptr->grid_array[current_floor_ptr->mon_lite_y[i]][current_floor_ptr->mon_lite_x[i]];
+               g_ptr = &floor_ptr->grid_array[floor_ptr->mon_lite_y[i]][floor_ptr->mon_lite_x[i]];
 
                /* Set temp or xtra flag */
                g_ptr->info |= (g_ptr->info & CAVE_MNLT) ? CAVE_TEMP : CAVE_XTRA;
@@ -1529,9 +1529,9 @@ void update_mon_lite(void)
                monster_race *r_ptr;
 
                /* Loop through monsters, adding newly lit squares to changes list */
-               for (i = 1; i < current_floor_ptr->m_max; i++)
+               for (i = 1; i < floor_ptr->m_max; i++)
                {
-                       m_ptr = &current_floor_ptr->m_list[i];
+                       m_ptr = &floor_ptr->m_list[i];
                        r_ptr = &r_info[m_ptr->r_idx];
                        if (!monster_is_valid(m_ptr)) continue;
 
@@ -1551,14 +1551,14 @@ void update_mon_lite(void)
                        if (!rad) continue;
                        else if (rad > 0)
                        {
-                               if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (MON_CSLEEP(m_ptr) || (!current_floor_ptr->dun_level && is_daytime()) || p_ptr->phase_out)) continue;
+                               if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (MON_CSLEEP(m_ptr) || (!floor_ptr->dun_level && is_daytime()) || p_ptr->phase_out)) continue;
                                if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) rad = 1;
                                add_mon_lite = mon_lite_hack;
                                f_flag = FF_LOS;
                        }
                        else
                        {
-                               if (!(r_ptr->flags7 & (RF7_SELF_DARK_1 | RF7_SELF_DARK_2)) && (MON_CSLEEP(m_ptr) || (!current_floor_ptr->dun_level && !is_daytime()))) continue;
+                               if (!(r_ptr->flags7 & (RF7_SELF_DARK_1 | RF7_SELF_DARK_2)) && (MON_CSLEEP(m_ptr) || (!floor_ptr->dun_level && !is_daytime()))) continue;
                                add_mon_lite = mon_dark_hack;
                                f_flag = FF_PROJECT;
                                rad = -rad; /* Use absolute value */
@@ -1568,7 +1568,7 @@ void update_mon_lite(void)
                        mon_fy = m_ptr->fy;
 
                        /* Is the monster visible? */
-                       mon_invis = !(current_floor_ptr->grid_array[mon_fy][mon_fx].info & CAVE_VIEW);
+                       mon_invis = !(floor_ptr->grid_array[mon_fy][mon_fx].info & CAVE_VIEW);
 
                        /* The square it is on */
                        add_mon_lite(mon_fy, mon_fx);
@@ -1593,7 +1593,7 @@ void update_mon_lite(void)
                                        add_mon_lite(mon_fy + 2, mon_fx);
                                        add_mon_lite(mon_fy + 2, mon_fx - 1);
 
-                                       g_ptr = &current_floor_ptr->grid_array[mon_fy + 2][mon_fx];
+                                       g_ptr = &floor_ptr->grid_array[mon_fy + 2][mon_fx];
 
                                        /* Radius 3 */
                                        if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
@@ -1611,7 +1611,7 @@ void update_mon_lite(void)
                                        add_mon_lite(mon_fy - 2, mon_fx);
                                        add_mon_lite(mon_fy - 2, mon_fx - 1);
 
-                                       g_ptr = &current_floor_ptr->grid_array[mon_fy - 2][mon_fx];
+                                       g_ptr = &floor_ptr->grid_array[mon_fy - 2][mon_fx];
 
                                        /* Radius 3 */
                                        if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
@@ -1629,7 +1629,7 @@ void update_mon_lite(void)
                                        add_mon_lite(mon_fy, mon_fx + 2);
                                        add_mon_lite(mon_fy - 1, mon_fx + 2);
 
-                                       g_ptr = &current_floor_ptr->grid_array[mon_fy][mon_fx + 2];
+                                       g_ptr = &floor_ptr->grid_array[mon_fy][mon_fx + 2];
 
                                        /* Radius 3 */
                                        if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
@@ -1647,7 +1647,7 @@ void update_mon_lite(void)
                                        add_mon_lite(mon_fy, mon_fx - 2);
                                        add_mon_lite(mon_fy - 1, mon_fx - 2);
 
-                                       g_ptr = &current_floor_ptr->grid_array[mon_fy][mon_fx - 2];
+                                       g_ptr = &floor_ptr->grid_array[mon_fy][mon_fx - 2];
 
                                        /* Radius 3 */
                                        if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
@@ -1695,15 +1695,15 @@ void update_mon_lite(void)
        /*
         * Look at old set flags to see if there are any changes.
         */
-       for (i = 0; i < current_floor_ptr->mon_lite_n; i++)
+       for (i = 0; i < floor_ptr->mon_lite_n; i++)
        {
-               fx = current_floor_ptr->mon_lite_x[i];
-               fy = current_floor_ptr->mon_lite_y[i];
+               fx = floor_ptr->mon_lite_x[i];
+               fy = floor_ptr->mon_lite_y[i];
 
                /* We trust this grid is in bounds */
 
                /* Point to grid */
-               g_ptr = &current_floor_ptr->grid_array[fy][fx];
+               g_ptr = &floor_ptr->grid_array[fy][fx];
 
                if (g_ptr->info & CAVE_TEMP) /* Pervious lit */
                {
@@ -1733,7 +1733,7 @@ void update_mon_lite(void)
        }
 
        /* Clear the lite array */
-       current_floor_ptr->mon_lite_n = 0;
+       floor_ptr->mon_lite_n = 0;
 
        /* Copy the temp array into the lit array lighting the new squares. */
        for (i = 0; i < end_temp; i++)
@@ -1744,7 +1744,7 @@ void update_mon_lite(void)
                /* We trust this grid is in bounds */
 
                /* Point to grid */
-               g_ptr = &current_floor_ptr->grid_array[fy][fx];
+               g_ptr = &floor_ptr->grid_array[fy][fx];
 
                if (g_ptr->info & CAVE_MNLT) /* Lit */
                {
@@ -1768,9 +1768,9 @@ void update_mon_lite(void)
                }
 
                /* Save in the monster lit or darkened array */
-               current_floor_ptr->mon_lite_x[current_floor_ptr->mon_lite_n] = fx;
-               current_floor_ptr->mon_lite_y[current_floor_ptr->mon_lite_n] = fy;
-               current_floor_ptr->mon_lite_n++;
+               floor_ptr->mon_lite_x[floor_ptr->mon_lite_n] = fx;
+               floor_ptr->mon_lite_y[floor_ptr->mon_lite_n] = fy;
+               floor_ptr->mon_lite_n++;
        }
 
        /* Clear the temp flag for the old lit or darken grids */
@@ -1778,7 +1778,7 @@ void update_mon_lite(void)
        {
                /* We trust this grid is in bounds */
 
-               current_floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
+               floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
        }
 
        /* Finished with tmp_pos.n */
@@ -1787,7 +1787,7 @@ void update_mon_lite(void)
        /* Mega-Hack -- Visual update later */
        p_ptr->update |= (PU_DELAY_VIS);
 
-       p_ptr->monlite = (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_MNLT) ? TRUE : FALSE;
+       p_ptr->monlite = (floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_MNLT) ? TRUE : FALSE;
 
        if (p_ptr->special_defense & NINJA_S_STEALTH)
        {
@@ -1806,23 +1806,23 @@ void update_mon_lite(void)
        p_ptr->old_monlite = p_ptr->monlite;
 }
 
-void clear_mon_lite(void)
+void clear_mon_lite(floor_type *floor_ptr)
 {
        int i;
        grid_type *g_ptr;
 
        /* Clear all monster lit squares */
-       for (i = 0; i < current_floor_ptr->mon_lite_n; i++)
+       for (i = 0; i < floor_ptr->mon_lite_n; i++)
        {
                /* Point to grid */
-               g_ptr = &current_floor_ptr->grid_array[current_floor_ptr->mon_lite_y[i]][current_floor_ptr->mon_lite_x[i]];
+               g_ptr = &floor_ptr->grid_array[floor_ptr->mon_lite_y[i]][floor_ptr->mon_lite_x[i]];
 
                /* Clear monster illumination flag */
                g_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK);
        }
 
        /* Empty the array */
-       current_floor_ptr->mon_lite_n = 0;
+       floor_ptr->mon_lite_n = 0;
 }