OSDN Git Service

[Refactor] #38997 count_all_hostile_monsters() に floor_type * 引数を追加.
[hengband/hengband.git] / src / floor-events.c
index b4bca96..2f2fd00 100644 (file)
 #include "player-move.h"
 #include "world.h"
 #include "player-effects.h"
+#include "objectkind.h"
+#include "object-ego.h"
+#include "cmd-dump.h"
+#include "view-mainwindow.h"
 
 static bool mon_invis;
 static POSITION mon_fy, mon_fx;
@@ -36,7 +40,6 @@ void day_break()
                                /* Hack -- Memorize lit grids if allowed */
                                if (view_perma_grids) g_ptr->info |= (CAVE_MARK);
 
-                               /* Hack -- Notice spot */
                                note_spot(y, x);
                        }
                }
@@ -48,7 +51,7 @@ void day_break()
 
        if (p_ptr->special_defense & NINJA_S_STEALTH)
        {
-               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
+               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
        }
 
 }
@@ -81,13 +84,11 @@ void night_falls(void)
                                                /* Forget the normal floor grid */
                                                g_ptr->info &= ~(CAVE_MARK);
 
-                                               /* Hack -- Notice spot */
                                                note_spot(y, x);
                                        }
                                }
                        }
 
-                       /* Glow deep lava and building entrances */
                        glow_deep_lava_and_bldg();
                }
        }
@@ -98,7 +99,7 @@ void night_falls(void)
 
        if (p_ptr->special_defense & NINJA_S_STEALTH)
        {
-               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
+               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
        }
 
 }
@@ -107,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;
                        }
@@ -144,13 +145,13 @@ byte get_dungeon_feeling(void)
 {
        const int base = 10;
        int rating = 0;
-       IDX i;
+       MONSTER_IDX i;
 
        /* Hack -- no feeling in the town */
        if (!current_floor_ptr->dun_level) return 0;
 
        /* Examine each monster */
-       for (i = 1; i < m_max; i++)
+       for (i = 1; i < current_floor_ptr->m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr;
@@ -201,8 +202,7 @@ byte get_dungeon_feeling(void)
                object_kind *k_ptr = &k_info[o_ptr->k_idx];
                int delta = 0;
 
-               /* Skip dead objects */
-               if (!o_ptr->k_idx) continue;
+               if (!OBJECT_IS_VALID(o_ptr)) continue;
 
                /* Skip known objects */
                if (object_is_known(o_ptr))
@@ -283,7 +283,7 @@ void update_dungeon_feeling(void)
        if (!current_floor_ptr->dun_level) return;
 
        /* No feeling in the arena */
-       if (p_ptr->inside_battle) return;
+       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;
@@ -314,7 +314,7 @@ void update_dungeon_feeling(void)
        p_ptr->feeling = new_feeling;
 
        /* Announce feeling */
-       do_cmd_feeling();
+       do_cmd_feeling(p_ptr);
 
        select_floor_music();
 
@@ -1529,7 +1529,7 @@ void update_mon_lite(void)
                monster_race *r_ptr;
 
                /* Loop through monsters, adding newly lit squares to changes list */
-               for (i = 1; i < m_max; i++)
+               for (i = 1; i < current_floor_ptr->m_max; i++)
                {
                        m_ptr = &current_floor_ptr->m_list[i];
                        r_ptr = &r_info[m_ptr->r_idx];
@@ -1551,7 +1551,7 @@ 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->inside_battle)) continue;
+                               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 (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) rad = 1;
                                add_mon_lite = mon_lite_hack;
                                f_flag = FF_LOS;