OSDN Git Service

[Refactor] #37353 知識の石の処理を perilous_secrets() に分離。 / Separate Stone of Lore to perilo...
[hengband/hengband.git] / src / spells-floor.c
1 #include "angband.h"
2 #include "spells-floor.h"
3
4 /*
5  * Light up the dungeon using "clairvoyance"
6  *
7  * This function "illuminates" every grid in the dungeon, memorizes all
8  * "objects", memorizes all grids as with magic mapping, and, under the
9  * standard option settings (view_perma_grids but not view_torch_grids)
10  * memorizes all floor grids too.
11  *
12  * Note that if "view_perma_grids" is not set, we do not memorize floor
13  * grids, since this would defeat the purpose of "view_perma_grids", not
14  * that anyone seems to play without this option.
15  *
16  * Note that if "view_torch_grids" is set, we do not memorize floor grids,
17  * since this would prevent the use of "view_torch_grids" as a method to
18  * keep track of what grids have been observed directly.
19  */
20 void wiz_lite(bool ninja)
21 {
22         OBJECT_IDX i;
23         POSITION y, x;
24         FEAT_IDX feat;
25         feature_type *f_ptr;
26
27         /* Memorize objects */
28         for (i = 1; i < o_max; i++)
29         {
30                 object_type *o_ptr = &o_list[i];
31
32                 /* Skip dead objects */
33                 if (!o_ptr->k_idx) continue;
34
35                 /* Skip held objects */
36                 if (o_ptr->held_m_idx) continue;
37
38                 /* Memorize */
39                 o_ptr->marked |= OM_FOUND;
40         }
41
42         /* Scan all normal grids */
43         for (y = 1; y < cur_hgt - 1; y++)
44         {
45                 /* Scan all normal grids */
46                 for (x = 1; x < cur_wid - 1; x++)
47                 {
48                         grid_type *g_ptr = &grid_array[y][x];
49
50                         /* Memorize terrain of the grid */
51                         g_ptr->info |= (CAVE_KNOWN);
52
53                         /* Feature code (applying "mimic" field) */
54                         feat = get_feat_mimic(g_ptr);
55                         f_ptr = &f_info[feat];
56
57                         /* Process all non-walls */
58                         if (!have_flag(f_ptr->flags, FF_WALL))
59                         {
60                                 /* Scan all neighbors */
61                                 for (i = 0; i < 9; i++)
62                                 {
63                                         POSITION yy = y + ddy_ddd[i];
64                                         POSITION xx = x + ddx_ddd[i];
65                                         g_ptr = &grid_array[yy][xx];
66
67                                         /* Feature code (applying "mimic" field) */
68                                         f_ptr = &f_info[get_feat_mimic(g_ptr)];
69
70                                         /* Perma-lite the grid */
71                                         if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
72                                         {
73                                                 g_ptr->info |= (CAVE_GLOW);
74                                         }
75
76                                         /* Memorize normal features */
77                                         if (have_flag(f_ptr->flags, FF_REMEMBER))
78                                         {
79                                                 /* Memorize the grid */
80                                                 g_ptr->info |= (CAVE_MARK);
81                                         }
82
83                                         /* Perma-lit grids (newly and previously) */
84                                         else if (g_ptr->info & CAVE_GLOW)
85                                         {
86                                                 /* Normally, memorize floors (see above) */
87                                                 if (view_perma_grids && !view_torch_grids)
88                                                 {
89                                                         /* Memorize the grid */
90                                                         g_ptr->info |= (CAVE_MARK);
91                                                 }
92                                         }
93                                 }
94                         }
95                 }
96         }
97
98         p_ptr->update |= (PU_MONSTERS);
99         p_ptr->redraw |= (PR_MAP);
100         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
101
102         if (p_ptr->special_defense & NINJA_S_STEALTH)
103         {
104                 if (grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
105         }
106 }
107
108
109 /*
110  * Forget the dungeon map (ala "Thinking of Maud...").
111  */
112 void wiz_dark(void)
113 {
114         OBJECT_IDX i;
115         POSITION y, x;
116
117         /* Forget every grid */
118         for (y = 1; y < cur_hgt - 1; y++)
119         {
120                 for (x = 1; x < cur_wid - 1; x++)
121                 {
122                         grid_type *g_ptr = &grid_array[y][x];
123
124                         /* Process the grid */
125                         g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
126                         g_ptr->info |= (CAVE_UNSAFE);
127                 }
128         }
129
130         /* Forget every grid on horizontal edge */
131         for (x = 0; x < cur_wid; x++)
132         {
133                 grid_array[0][x].info &= ~(CAVE_MARK);
134                 grid_array[cur_hgt - 1][x].info &= ~(CAVE_MARK);
135         }
136
137         /* Forget every grid on vertical edge */
138         for (y = 1; y < (cur_hgt - 1); y++)
139         {
140                 grid_array[y][0].info &= ~(CAVE_MARK);
141                 grid_array[y][cur_wid - 1].info &= ~(CAVE_MARK);
142         }
143
144         /* Forget all objects */
145         for (i = 1; i < o_max; i++)
146         {
147                 object_type *o_ptr = &o_list[i];
148
149                 /* Skip dead objects */
150                 if (!o_ptr->k_idx) continue;
151
152                 /* Skip held objects */
153                 if (o_ptr->held_m_idx) continue;
154
155                 /* Forget the object */
156                 o_ptr->marked &= OM_TOUCHED;
157         }
158
159         /* Forget travel route when we have forgotten map */
160         forget_travel_flow();
161
162         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
163         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
164         p_ptr->update |= (PU_MONSTERS);
165         p_ptr->redraw |= (PR_MAP);
166         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
167 }