OSDN Git Service

山脈を2種類の地形に分けた。また山脈だけを特別扱いするコードをほとんど廃止。
[hengband/hengband.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
28 #define is_floor_bold(Y,X) (cave[Y][X].info & CAVE_FLOOR)
29 #define is_extra_bold(Y,X) (cave[Y][X].info & CAVE_EXTRA)
30 #define is_inner_bold(Y,X) (cave[Y][X].info & CAVE_INNER)
31 #define is_outer_bold(Y,X) (cave[Y][X].info & CAVE_OUTER)
32 #define is_solid_bold(Y,X) (cave[Y][X].info & CAVE_SOLID)
33
34 #define is_floor_grid(C) ((C)->info & CAVE_FLOOR)
35 #define is_extra_grid(C) ((C)->info & CAVE_EXTRA)
36 #define is_inner_grid(C) ((C)->info & CAVE_INNER)
37 #define is_outer_grid(C) ((C)->info & CAVE_OUTER)
38 #define is_solid_grid(C) ((C)->info & CAVE_SOLID)
39
40 #define place_floor_bold(Y, X) \
41 { \
42         set_cave_feat(Y,X,floor_type[randint0(100)]); \
43         cave[Y][X].info &= ~(CAVE_MASK); \
44         add_cave_info(Y,X,CAVE_FLOOR); \
45 }
46
47 #define place_floor_grid(C) \
48 { \
49         (C)->feat = floor_type[randint0(100)]; \
50         (C)->info &= ~(CAVE_MASK); \
51         (C)->info |= CAVE_FLOOR; \
52 }
53
54 #define place_extra_bold(Y, X) \
55 { \
56         set_cave_feat(Y,X,fill_type[randint0(100)]); \
57         cave[Y][X].info &= ~(CAVE_MASK); \
58         add_cave_info(Y,X,CAVE_EXTRA); \
59 }
60
61 #define place_extra_grid(C) \
62 { \
63         (C)->feat = fill_type[randint0(100)]; \
64         (C)->info &= ~(CAVE_MASK); \
65         (C)->info |= CAVE_EXTRA; \
66 }
67
68 #define place_extra_noperm_bold(Y, X) \
69 { \
70         feature_type *_f_ptr; \
71         set_cave_feat(Y,X,fill_type[randint0(100)]); \
72         _f_ptr = &f_info[cave[Y][X].feat]; \
73         if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
74                 cave[Y][X].feat = feat_state(cave[Y][X].feat, FF_UNPERM); \
75         cave[Y][X].info &= ~(CAVE_MASK); \
76         add_cave_info(Y,X,CAVE_EXTRA); \
77 }
78
79 #define place_inner_bold(Y, X) \
80 { \
81         set_cave_feat(Y,X,feat_wall_inner); \
82         cave[Y][X].info &= ~(CAVE_MASK); \
83         add_cave_info(Y,X,CAVE_INNER); \
84 }
85
86 #define place_inner_grid(C) \
87 { \
88         (C)->feat = feat_wall_inner; \
89         (C)->info &= ~(CAVE_MASK); \
90         (C)->info |= CAVE_INNER; \
91 }
92
93 #define place_outer_bold(Y, X) \
94 { \
95         set_cave_feat(Y,X,feat_wall_outer); \
96         cave[Y][X].info &= ~(CAVE_MASK); \
97         add_cave_info(Y,X,CAVE_OUTER); \
98 }
99
100 #define place_outer_grid(C) \
101 { \
102         (C)->feat = feat_wall_outer; \
103         (C)->info &= ~(CAVE_MASK); \
104         (C)->info |= CAVE_OUTER; \
105 }
106
107 #define place_outer_noperm_bold(Y, X) \
108 { \
109         feature_type *_f_ptr = &f_info[feat_wall_outer]; \
110         if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
111                 set_cave_feat(Y, X, feat_state(feat_wall_outer, FF_UNPERM)); \
112         else set_cave_feat(Y,X,feat_wall_outer); \
113         cave[Y][X].info &= ~(CAVE_MASK); \
114         add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
115 }
116
117 #define place_outer_noperm_grid(C) \
118 { \
119         feature_type *_f_ptr = &f_info[feat_wall_outer]; \
120         if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
121                 (C)->feat = feat_state(feat_wall_outer, FF_UNPERM); \
122         else (C)->feat = feat_wall_outer; \
123         (C)->info &= ~(CAVE_MASK); \
124         (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
125 }
126
127 #define place_solid_bold(Y, X) \
128 { \
129         set_cave_feat(Y,X,feat_wall_solid); \
130         cave[Y][X].info &= ~(CAVE_MASK); \
131         add_cave_info(Y,X,CAVE_SOLID); \
132 }
133
134 #define place_solid_grid(C) \
135 { \
136         (C)->feat = feat_wall_solid; \
137         (C)->info &= ~(CAVE_MASK); \
138         (C)->info |= CAVE_SOLID; \
139 }
140
141 #define place_solid_noperm_bold(Y, X) \
142 { \
143         feature_type *_f_ptr = &f_info[feat_wall_solid]; \
144         if ((cave[Y][X].info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
145                 set_cave_feat(Y, X, feat_state(feat_wall_solid, FF_UNPERM)); \
146         else set_cave_feat(Y,X,feat_wall_solid); \
147         cave[Y][X].info &= ~(CAVE_MASK); \
148         add_cave_info(Y,X,CAVE_SOLID); \
149 }
150
151 #define place_solid_noperm_grid(C) \
152 { \
153         feature_type *_f_ptr = &f_info[feat_wall_solid]; \
154         if (((C)->info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
155                 (C)->feat = feat_state(feat_wall_solid, FF_UNPERM); \
156         else (C)->feat = feat_wall_solid; \
157         (C)->info &= ~(CAVE_MASK); \
158         (C)->info |= CAVE_SOLID; \
159 }
160
161
162 /* Externs */
163
164 extern bool new_player_spot(void);
165
166 extern void place_random_stairs(int y, int x);
167 extern void place_random_door(int y, int x, bool room);
168 extern void place_closed_door(int y, int x);
169 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
170 extern void place_room(int x1, int x2, int y1, int y2, bool light);
171 extern void vault_monsters(int y1, int x1, int num);
172 extern void vault_objects(int y, int x, int num);
173 extern void vault_trap_aux(int y, int x, int yd, int xd);
174 extern void vault_traps(int y, int x, int yd, int xd, int num);
175
176 extern int next_to_walls(int y, int x);
177 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
178
179 extern void rand_dir(int *rdir, int *cdir);
180
181 extern bool get_is_floor(int x, int y);
182 extern void set_floor(int x, int y);
183
184 extern void build_tunnel(int row1, int col1, int row2, int col2);
185 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);