… | |
… | |
150 | // > down |
150 | // > down |
151 | // C "center" (of onion layout) |
151 | // C "center" (of onion layout) |
152 | // . ?? (rogue) |
152 | // . ?? (rogue) |
153 | // |
153 | // |
154 | |
154 | |
155 | struct LayoutData : zero_initialised |
155 | struct LayoutData |
156 | { |
156 | { |
157 | char **col; |
157 | char **col; |
158 | int w, h; |
158 | int w, h; |
159 | |
159 | |
160 | LayoutData (int w, int h); |
160 | LayoutData (int w, int h); |
… | |
… | |
163 | operator char **() |
163 | operator char **() |
164 | { |
164 | { |
165 | return col; |
165 | return col; |
166 | } |
166 | } |
167 | |
167 | |
|
|
168 | void fill (char fill); |
168 | void clear (char fill = 0); |
169 | void clear () { fill (0); } |
169 | void border (char fill = '#'); |
170 | void border (char fill = '#'); |
|
|
171 | void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive |
|
|
172 | |
|
|
173 | // makes sure all areas are connected. dirty=true carves rounder but also |
|
|
174 | // mroe walls, dirty=false carves narrow corridors. |
|
|
175 | void isolation_remover (bool dirty = 0); |
170 | }; |
176 | }; |
171 | |
177 | |
172 | struct Layout |
178 | struct Layout |
173 | { |
179 | { |
174 | LayoutData *ptr; |
180 | LayoutData *ptr; |
… | |
… | |
221 | int i = find_free_spot (ob, m, x, y, start, stop); |
227 | int i = find_free_spot (ob, m, x, y, start, stop); |
222 | swap (rmg_rndm, rndm); |
228 | swap (rmg_rndm, rndm); |
223 | return i; |
229 | return i; |
224 | } |
230 | } |
225 | |
231 | |
|
|
232 | struct point |
|
|
233 | { |
|
|
234 | short x; |
|
|
235 | short y; |
|
|
236 | |
|
|
237 | point () |
|
|
238 | { |
|
|
239 | } |
|
|
240 | |
|
|
241 | point (int x, int y) |
|
|
242 | : x(x), y(y) |
|
|
243 | { |
|
|
244 | } |
|
|
245 | }; |
|
|
246 | |
|
|
247 | template<typename T> |
|
|
248 | struct fixed_stack |
|
|
249 | { |
|
|
250 | T *data; |
|
|
251 | int size; |
|
|
252 | int max; |
|
|
253 | |
|
|
254 | fixed_stack () |
|
|
255 | : size (0), data (0) |
|
|
256 | { |
|
|
257 | } |
|
|
258 | |
|
|
259 | fixed_stack (int max) |
|
|
260 | : size (0), max (max) |
|
|
261 | { |
|
|
262 | data = salloc<T> (max); |
|
|
263 | } |
|
|
264 | |
|
|
265 | void reset (int new_max) |
|
|
266 | { |
|
|
267 | sfree (data, max); |
|
|
268 | size = 0; |
|
|
269 | max = new_max; |
|
|
270 | data = salloc<T> (max); |
|
|
271 | } |
|
|
272 | |
|
|
273 | void free () |
|
|
274 | { |
|
|
275 | sfree (data, max); |
|
|
276 | data = 0; |
|
|
277 | } |
|
|
278 | |
|
|
279 | ~fixed_stack () |
|
|
280 | { |
|
|
281 | sfree (data, max); |
|
|
282 | } |
|
|
283 | |
|
|
284 | T &operator[](int idx) |
|
|
285 | { |
|
|
286 | return data [idx]; |
|
|
287 | } |
|
|
288 | |
|
|
289 | void push (T v) |
|
|
290 | { |
|
|
291 | data [size++] = v; |
|
|
292 | } |
|
|
293 | |
|
|
294 | T &pop () |
|
|
295 | { |
|
|
296 | return data [--size]; |
|
|
297 | } |
|
|
298 | |
|
|
299 | T remove (int idx) |
|
|
300 | { |
|
|
301 | T v = data [idx]; |
|
|
302 | |
|
|
303 | data [idx] = data [--size]; |
|
|
304 | |
|
|
305 | return v; |
|
|
306 | } |
|
|
307 | }; |
|
|
308 | |
226 | #endif |
309 | #endif |
227 | |
310 | |