… | |
… | |
155 | // C "center" (of onion layout) |
155 | // C "center" (of onion layout) |
156 | // . ?? (rogue) |
156 | // . ?? (rogue) |
157 | // |
157 | // |
158 | |
158 | |
159 | // use this in new code |
159 | // use this in new code |
160 | struct LayoutData |
160 | struct Layout |
161 | { |
161 | { |
162 | char **col; |
162 | char **col; |
163 | int w, h; |
163 | int w, h; |
164 | |
164 | |
165 | LayoutData (int w, int h); |
165 | Layout (int w, int h); |
166 | ~LayoutData (); |
166 | ~Layout (); |
167 | |
167 | |
168 | operator char **() |
168 | operator char **() const |
169 | { |
169 | { |
170 | return col; |
170 | return col; |
171 | } |
171 | } |
172 | |
172 | |
|
|
173 | void swap (Layout &layout) |
|
|
174 | { |
|
|
175 | ::swap (layout.col, col); |
|
|
176 | ::swap (layout.w , w ); |
|
|
177 | ::swap (layout.h , h ); |
|
|
178 | } |
|
|
179 | |
173 | // for debugging, print layout to stdout |
180 | // for debugging, print layout to stdout |
174 | void print (); |
181 | void print () const; |
175 | |
182 | |
176 | // simple inpainting |
183 | // simple inpainting |
177 | void fill (char fill); |
184 | void fill (char fill); |
178 | void clear () { fill (0); } |
185 | void clear () { fill (0); } |
179 | void border (char fill = '#'); |
186 | void border (char fill = '#'); |
… | |
… | |
185 | // more walls, dirty=false carves narrow corridors. |
192 | // more walls, dirty=false carves narrow corridors. |
186 | void isolation_remover (bool dirty = 0); |
193 | void isolation_remover (bool dirty = 0); |
187 | |
194 | |
188 | // generates a cave, subtype 0 is a rough cave, randomly open or closed |
195 | // generates a cave, subtype 0 is a rough cave, randomly open or closed |
189 | void gen_cave (int subtype); |
196 | void gen_cave (int subtype); |
|
|
197 | |
|
|
198 | // helper functions to modify the layout |
190 | void erode_1_2 (int c1, int c2 = -1, int repeat = 1); |
199 | void erode_1_2 (int c1, int c2 = -1, int repeat = 1); |
|
|
200 | void doorify (); |
|
|
201 | void roomify (); // make some rooms in it, works best on onions |
|
|
202 | void expand2x (); |
|
|
203 | void symmetrize (int symmetry); |
|
|
204 | void rotate (int rotation); // rotate by 1=90, 2=180, 3=270 degrees |
191 | |
205 | |
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 |
|
|
201 | struct Layout |
|
|
202 | { |
|
|
203 | LayoutData *ptr; |
|
|
204 | |
|
|
205 | Layout () |
|
|
206 | { |
|
|
207 | } |
|
|
208 | |
|
|
209 | Layout (int xsize, int ysize) |
|
|
210 | : ptr (new LayoutData (xsize, ysize)) |
|
|
211 | { |
|
|
212 | } |
|
|
213 | |
|
|
214 | Layout (random_map_params *RP) |
206 | void generate (random_map_params *RP); |
215 | : ptr (new LayoutData (RP->Xsize, RP->Ysize)) |
|
|
216 | { |
|
|
217 | } |
|
|
218 | |
|
|
219 | void free () |
|
|
220 | { |
|
|
221 | delete ptr; |
|
|
222 | } |
|
|
223 | |
|
|
224 | LayoutData *operator ->() const |
|
|
225 | { |
|
|
226 | return ptr; |
|
|
227 | } |
|
|
228 | |
|
|
229 | operator char **() const |
|
|
230 | { |
|
|
231 | return *ptr; |
|
|
232 | } |
|
|
233 | |
|
|
234 | void swap (Layout &layout) |
|
|
235 | { |
|
|
236 | ::swap (layout.ptr, ptr); |
|
|
237 | } |
|
|
238 | }; |
207 | }; |
239 | |
208 | |
240 | // utility functions, to use rmg_rndm instead of rndm. |
209 | // utility functions, to use rmg_rndm instead of rndm. |
241 | static inline int |
210 | static inline int |
242 | rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
211 | rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |