… | |
… | |
94 | LAYOUT_MAZE, |
94 | LAYOUT_MAZE, |
95 | LAYOUT_SPIRAL, |
95 | LAYOUT_SPIRAL, |
96 | LAYOUT_ROGUELIKE, |
96 | LAYOUT_ROGUELIKE, |
97 | LAYOUT_SNAKE, |
97 | LAYOUT_SNAKE, |
98 | LAYOUT_SQUARE_SPIRAL, |
98 | LAYOUT_SQUARE_SPIRAL, |
|
|
99 | LAYOUT_CAVE, |
99 | NROFLAYOUTS, |
100 | NROFLAYOUTS, |
100 | }; |
101 | }; |
101 | |
102 | |
102 | /* |
103 | /* |
103 | * Move these defines out of room_gen_onion.c to here, as |
104 | * Move these defines out of room_gen_onion.c to here, as |
… | |
… | |
139 | // 12 has been experimentally :( determined ot be a lot more stable |
140 | // 12 has been experimentally :( determined ot be a lot more stable |
140 | // than 11 or 10, leading to the assumption that something inherently |
141 | // than 11 or 10, leading to the assumption that something inherently |
141 | // needs a minimum size of at least 12 |
142 | // needs a minimum size of at least 12 |
142 | #define MIN_RANDOM_MAP_SIZE 12 |
143 | #define MIN_RANDOM_MAP_SIZE 12 |
143 | |
144 | |
|
|
145 | // we often use signed chars for coordinates (and U8 for distances) |
|
|
146 | #define MAX_RANDOM_MAP_SIZE 120 |
|
|
147 | |
144 | // reference |
148 | // reference |
145 | // |
149 | // |
146 | // \0 floor only |
150 | // \0 floor only |
147 | // # wall |
151 | // # wall |
148 | // D door |
152 | // D door |
… | |
… | |
150 | // > down |
154 | // > down |
151 | // C "center" (of onion layout) |
155 | // C "center" (of onion layout) |
152 | // . ?? (rogue) |
156 | // . ?? (rogue) |
153 | // |
157 | // |
154 | |
158 | |
|
|
159 | // use this in new code |
155 | struct LayoutData |
160 | struct LayoutData |
156 | { |
161 | { |
157 | char **col; |
162 | char **col; |
158 | int w, h; |
163 | int w, h; |
159 | |
164 | |
… | |
… | |
163 | operator char **() |
168 | operator char **() |
164 | { |
169 | { |
165 | return col; |
170 | return col; |
166 | } |
171 | } |
167 | |
172 | |
|
|
173 | // for debugging, print layout to stdout |
|
|
174 | void print (); |
|
|
175 | |
|
|
176 | // simple inpainting |
168 | void fill (char fill); |
177 | void fill (char fill); |
169 | void clear () { fill (0); } |
178 | void clear () { fill (0); } |
170 | void border (char fill = '#'); |
179 | void border (char fill = '#'); |
171 | void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive |
180 | void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive |
172 | |
181 | |
|
|
182 | void fill_rand (int perc); |
|
|
183 | |
173 | // makes sure all areas are connected. dirty=true carves rounder but also |
184 | // makes sure all areas are connected. dirty=true carves rounder but also |
174 | // mroe walls, dirty=false carves narrow corridors. |
185 | // more walls, dirty=false carves narrow corridors. |
175 | void isolation_remover (bool dirty = 0); |
186 | void isolation_remover (bool dirty = 0); |
176 | }; |
|
|
177 | |
187 | |
|
|
188 | // generates a cave, subtype 0 is a rough cave, randomly open or closed |
|
|
189 | void gen_cave (int subtype); |
|
|
190 | void erode_1_2 (int c1, int c2 = -1, int repeat = 1); |
|
|
191 | |
|
|
192 | void swap (LayoutData &layout) |
|
|
193 | { |
|
|
194 | ::swap (layout.col, col); |
|
|
195 | ::swap (layout.w , w ); |
|
|
196 | ::swap (layout.h , h ); |
|
|
197 | } |
|
|
198 | }; |
|
|
199 | |
|
|
200 | // basically a layoutdata pointer - do not use in new code |
178 | struct Layout |
201 | struct Layout |
179 | { |
202 | { |
180 | LayoutData *ptr; |
203 | LayoutData *ptr; |
181 | |
204 | |
182 | Layout () |
205 | Layout () |
… | |
… | |
206 | operator char **() const |
229 | operator char **() const |
207 | { |
230 | { |
208 | return *ptr; |
231 | return *ptr; |
209 | } |
232 | } |
210 | |
233 | |
211 | void swap (const Layout &layout) const |
234 | void swap (Layout &layout) |
212 | { |
235 | { |
213 | ::swap (layout.ptr->col, ptr->col); |
236 | ::swap (layout.ptr, ptr); |
214 | ::swap (layout.ptr->w , ptr->w ); |
|
|
215 | ::swap (layout.ptr->h , ptr->h ); |
|
|
216 | } |
237 | } |
217 | |
|
|
218 | // for debugging, print layout to stdout |
|
|
219 | void print (); |
|
|
220 | }; |
238 | }; |
221 | |
239 | |
222 | // utility functions, to use rmg_rndm instead of rndm. |
240 | // utility functions, to use rmg_rndm instead of rndm. |
223 | static inline int |
241 | static inline int |
224 | rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
242 | rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
… | |
… | |
227 | int i = find_free_spot (ob, m, x, y, start, stop); |
245 | int i = find_free_spot (ob, m, x, y, start, stop); |
228 | swap (rmg_rndm, rndm); |
246 | swap (rmg_rndm, rndm); |
229 | return i; |
247 | return i; |
230 | } |
248 | } |
231 | |
249 | |
|
|
250 | // a simple point helper struct |
232 | struct point |
251 | struct point |
233 | { |
252 | { |
234 | short x; |
253 | short x; |
235 | short y; |
254 | short y; |
236 | |
255 | |
… | |
… | |
242 | : x(x), y(y) |
261 | : x(x), y(y) |
243 | { |
262 | { |
244 | } |
263 | } |
245 | }; |
264 | }; |
246 | |
265 | |
|
|
266 | // something like a vector or stack, but without |
|
|
267 | // out of bounds checking |
247 | template<typename T> |
268 | template<typename T> |
248 | struct fixed_stack |
269 | struct fixed_stack |
249 | { |
270 | { |
250 | T *data; |
271 | T *data; |
251 | int size; |
272 | int size; |