OSDN Git Service

[Refactor] #37353 複数のフロアに関するマクロを floor.h へ移動。
[hengband/hengband.git] / src / floor-events.c
1 #include "angband.h"
2 #include "floor.h"
3 #include "grid.h"
4 #include "monster.h"
5
6 void day_break()
7 {
8         POSITION y, x;
9         msg_print(_("夜が明けた。", "The sun has risen."));
10
11         if (!p_ptr->wild_mode)
12         {
13                 /* Hack -- Scan the town */
14                 for (y = 0; y < current_floor_ptr->height; y++)
15                 {
16                         for (x = 0; x < current_floor_ptr->width; x++)
17                         {
18                                 grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
19
20                                 /* Assume lit */
21                                 g_ptr->info |= (CAVE_GLOW);
22
23                                 /* Hack -- Memorize lit grids if allowed */
24                                 if (view_perma_grids) g_ptr->info |= (CAVE_MARK);
25
26                                 /* Hack -- Notice spot */
27                                 note_spot(y, x);
28                         }
29                 }
30         }
31
32         p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
33         p_ptr->redraw |= (PR_MAP);
34         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
35
36         if (p_ptr->special_defense & NINJA_S_STEALTH)
37         {
38                 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
39         }
40
41 }
42
43 void night_falls(void)
44 {
45         POSITION y, x;
46         msg_print(_("日が沈んだ。", "The sun has fallen."));
47
48         if (!p_ptr->wild_mode)
49         {
50                 /* Hack -- Scan the town */
51                 for (y = 0; y < current_floor_ptr->height; y++)
52                 {
53                         for (x = 0; x < current_floor_ptr->width; x++)
54                         {
55                                 grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
56
57                                 /* Feature code (applying "mimic" field) */
58                                 feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
59
60                                 if (!is_mirror_grid(g_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
61                                         !have_flag(f_ptr->flags, FF_ENTRANCE))
62                                 {
63                                         /* Assume dark */
64                                         g_ptr->info &= ~(CAVE_GLOW);
65
66                                         if (!have_flag(f_ptr->flags, FF_REMEMBER))
67                                         {
68                                                 /* Forget the normal floor grid */
69                                                 g_ptr->info &= ~(CAVE_MARK);
70
71                                                 /* Hack -- Notice spot */
72                                                 note_spot(y, x);
73                                         }
74                                 }
75                         }
76
77                         /* Glow deep lava and building entrances */
78                         glow_deep_lava_and_bldg();
79                 }
80         }
81
82         p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
83         p_ptr->redraw |= (PR_MAP);
84         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
85
86         if (p_ptr->special_defense & NINJA_S_STEALTH)
87         {
88                 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
89         }
90
91 }
92
93 /*!
94  * @brief 現在フロアに残っている敵モンスターの数を返す /
95  * @return 現在の敵モンスターの数
96  */
97 MONSTER_NUMBER count_all_hostile_monsters(void)
98 {
99         POSITION x, y;
100         MONSTER_NUMBER number_mon = 0;
101
102         for (x = 0; x < current_floor_ptr->width; ++x)
103         {
104                 for (y = 0; y < current_floor_ptr->height; ++y)
105                 {
106                         MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
107
108                         if (m_idx > 0 && is_hostile(&current_floor_ptr->m_list[m_idx]))
109                         {
110                                 ++number_mon;
111                         }
112                 }
113         }
114
115         return number_mon;
116 }
117