OSDN Git Service

360951da4143e447acb57353f3f17b00e4e096aa
[hengbandforosx/hengbandosx.git] / src / grid.h
1 /*
2  * File: grid.h
3  * Purpose: header file for grid.c, used only in dungeon generation
4  * files (generate.c, rooms.c)
5  */
6
7 /*
8  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
9  *
10  * This software may be copied and distributed for educational, research, and
11  * not for profit purposes provided that this copyright and statement are
12  * included in all such copies.
13  */
14
15
16 /* Macros */
17
18 #define set_cave_feat(Y,X,F)    (cave[(Y)][(X)].feat = (F))
19 #define add_cave_info(Y,X,I)    (cave[(Y)][(X)].info |= (I))
20
21 /* This should not be used */
22 /*#define set_cave_info(Y,X,I)    (cave[(Y)][(X)].info = (I)) */
23
24 #define place_rubble(Y,X)       set_cave_feat(Y,X,FEAT_RUBBLE)
25 #define place_up_stairs(Y,X)    set_cave_feat(Y,X,FEAT_LESS)
26 #define place_down_stairs(Y,X)  set_cave_feat(Y,X,FEAT_MORE)
27 #define place_invis_wall(Y,X)   set_cave_feat(Y,X,FEAT_WALL_INVIS)
28
29 #define is_floor_bold(Y,X) (cave[Y][X].info & CAVE_FLOOR)
30 #define is_extra_bold(Y,X) (cave[Y][X].info & CAVE_EXTRA)
31 #define is_inner_bold(Y,X) (cave[Y][X].info & CAVE_INNER)
32 #define is_outer_bold(Y,X) (cave[Y][X].info & CAVE_OUTER)
33 #define is_solid_bold(Y,X) (cave[Y][X].info & CAVE_SOLID)
34
35 #define is_floor_grid(C) ((C)->info & CAVE_FLOOR)
36 #define is_extra_grid(C) ((C)->info & CAVE_EXTRA)
37 #define is_inner_grid(C) ((C)->info & CAVE_INNER)
38 #define is_outer_grid(C) ((C)->info & CAVE_OUTER)
39 #define is_solid_grid(C) ((C)->info & CAVE_SOLID)
40
41 #define place_floor_bold(Y, X) \
42 { \
43   set_cave_feat(Y,X,floor_type[randint0(100)]); \
44   cave[Y][X].info &= ~(CAVE_MASK); \
45   add_cave_info(Y,X,CAVE_FLOOR); \
46 }
47
48 #define place_floor_grid(C) \
49 { \
50   (C)->feat = floor_type[randint0(100)]; \
51   (C)->info &= ~(CAVE_MASK); \
52   (C)->info |= CAVE_FLOOR; \
53 }
54
55 #define place_extra_bold(Y, X) \
56 { \
57   set_cave_feat(Y,X,fill_type[randint0(100)]); \
58   cave[Y][X].info &= ~(CAVE_MASK); \
59   add_cave_info(Y,X,CAVE_EXTRA); \
60 }
61
62 #define place_extra_grid(C) \
63 { \
64   (C)->feat = fill_type[randint0(100)]; \
65   (C)->info &= ~(CAVE_MASK); \
66   (C)->info |= CAVE_EXTRA; \
67 }
68
69 #define place_extra_noperm_bold(Y, X) \
70 { \
71   set_cave_feat(Y,X,fill_type[randint0(100)]); \
72   if ((cave[Y][X].feat >= FEAT_PERM_EXTRA) && (cave[Y][X].feat <= FEAT_PERM_SOLID)) cave[Y][X].feat -= 0x04; \
73   else if (cave[Y][X].feat == FEAT_MOUNTAIN) cave[Y][X].feat = feat_wall_inner; \
74   cave[Y][X].info &= ~(CAVE_MASK); \
75   add_cave_info(Y,X,CAVE_EXTRA); \
76 }
77
78 #define place_inner_bold(Y, X) \
79 { \
80   set_cave_feat(Y,X,feat_wall_inner); \
81   cave[Y][X].info &= ~(CAVE_MASK); \
82   add_cave_info(Y,X,CAVE_INNER); \
83 }
84
85 #define place_inner_grid(C) \
86 { \
87   (C)->feat = feat_wall_inner; \
88   (C)->info &= ~(CAVE_MASK); \
89   (C)->info |= CAVE_INNER; \
90 }
91
92 #define place_outer_bold(Y, X) \
93 { \
94   set_cave_feat(Y,X,feat_wall_outer); \
95   cave[Y][X].info &= ~(CAVE_MASK); \
96   add_cave_info(Y,X,CAVE_OUTER); \
97 }
98
99 #define place_outer_grid(C) \
100 { \
101   (C)->feat = feat_wall_outer; \
102   (C)->info &= ~(CAVE_MASK); \
103   (C)->info |= CAVE_OUTER; \
104 }
105
106 #define place_outer_noperm_bold(Y, X) \
107 { \
108   if ((feat_wall_outer >= FEAT_PERM_EXTRA) && (feat_wall_outer <= FEAT_PERM_SOLID)) set_cave_feat(Y, X, feat_wall_outer-0x04); \
109   else if (feat_wall_outer == FEAT_MOUNTAIN) cave[Y][X].feat = feat_wall_inner; \
110   else set_cave_feat(Y,X,feat_wall_outer); \
111   cave[Y][X].info &= ~(CAVE_MASK); \
112   add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
113 }
114
115 #define place_outer_noperm_grid(C) \
116 { \
117   if ((feat_wall_outer >= FEAT_PERM_EXTRA) && (feat_wall_outer <= FEAT_PERM_SOLID)) (C)->feat = feat_wall_outer-0x04; \
118   else if (feat_wall_outer == FEAT_MOUNTAIN) (C)->feat = feat_wall_inner; \
119   else (C)->feat = feat_wall_outer; \
120   (C)->info &= ~(CAVE_MASK); \
121   (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
122 }
123
124 #define place_solid_bold(Y, X) \
125 { \
126   set_cave_feat(Y,X,feat_wall_solid); \
127   cave[Y][X].info &= ~(CAVE_MASK); \
128   add_cave_info(Y,X,CAVE_SOLID); \
129 }
130
131 #define place_solid_grid(C) \
132 { \
133   (C)->feat = feat_wall_solid; \
134   (C)->info &= ~(CAVE_MASK); \
135   (C)->info |= CAVE_SOLID; \
136 }
137
138 #define place_solid_noperm_bold(Y, X) \
139 { \
140   if ((cave[Y][X].info & CAVE_VAULT) && (feat_wall_solid >= FEAT_PERM_EXTRA) && (feat_wall_solid <= FEAT_PERM_SOLID)) set_cave_feat(Y, X, feat_wall_solid-0x04); \
141   else set_cave_feat(Y,X,feat_wall_solid); \
142   cave[Y][X].info &= ~(CAVE_MASK); \
143   add_cave_info(Y,X,CAVE_SOLID); \
144 }
145
146 #define place_solid_noperm_grid(C) \
147 { \
148   if ((c_ptr->info & CAVE_VAULT) && (feat_wall_solid >= FEAT_PERM_EXTRA) && (feat_wall_solid <= FEAT_PERM_SOLID)) (C)->feat = feat_wall_solid-0x04; \
149   else (C)->feat = feat_wall_solid; \
150   (C)->info &= ~(CAVE_MASK); \
151   (C)->info |= CAVE_SOLID; \
152 }
153
154
155 /* Externs */
156
157 extern bool new_player_spot(void);
158
159 extern void place_random_stairs(int y, int x);
160 extern void place_random_door(int y, int x, bool room);
161 extern void place_closed_door(int y, int x);
162 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
163 extern void place_room(int x1, int x2, int y1, int y2, bool light);
164 extern void vault_monsters(int y1, int x1, int num);
165 extern void vault_objects(int y, int x, int num);
166 extern void vault_trap_aux(int y, int x, int yd, int xd);
167 extern void vault_traps(int y, int x, int yd, int xd, int num);
168
169 extern int next_to_walls(int y, int x);
170 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
171
172 extern void rand_dir(int *rdir, int *cdir);
173
174 extern bool get_is_floor(int x, int y);
175 extern void set_floor(int x, int y);
176
177 extern void build_tunnel(int row1, int col1, int row2, int col2);
178 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);