ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/random_map.h
(Generate patch)

Comparing deliantra/server/random_maps/random_map.h (file contents):
Revision 1.30 by root, Wed Jun 30 23:03:40 2010 UTC vs.
Revision 1.33 by root, Fri Jul 2 03:40:14 2010 UTC

140// 12 has been experimentally :( determined ot be a lot more stable 140// 12 has been experimentally :( determined ot be a lot more stable
141// than 11 or 10, leading to the assumption that something inherently 141// than 11 or 10, leading to the assumption that something inherently
142// needs a minimum size of at least 12 142// needs a minimum size of at least 12
143#define MIN_RANDOM_MAP_SIZE 12 143#define MIN_RANDOM_MAP_SIZE 12
144 144
145// we often use signed chars for coordinates (and U8 for distances)
146#define MAX_RANDOM_MAP_SIZE 120
147
145// reference 148// reference
146// 149//
147// \0 floor only 150// \0 floor only
148// # wall 151// # wall
149// D door 152// D door
152// C "center" (of onion layout) 155// C "center" (of onion layout)
153// . ?? (rogue) 156// . ?? (rogue)
154// 157//
155 158
156// use this in new code 159// use this in new code
157struct LayoutData 160struct Layout
158{ 161{
159 char **col; 162 char **col;
160 int w, h; 163 int w, h;
161 164
162 LayoutData (int w, int h); 165 Layout (int w, int h);
163 ~LayoutData (); 166 ~Layout ();
164 167
165 operator char **() 168 operator char **() const
166 { 169 {
167 return col; 170 return col;
168 } 171 }
169 172
173 void swap (Layout &layout)
174 {
175 ::swap (layout.col, col);
176 ::swap (layout.w , w );
177 ::swap (layout.h , h );
178 }
179
170 // for debugging, print layout to stdout 180 // for debugging, print layout to stdout
171 void print (); 181 void print () const;
172 182
173 // simple inpainting 183 // simple inpainting
174 void fill (char fill); 184 void fill (char fill);
175 void clear () { fill (0); } 185 void clear () { fill (0); }
176 void border (char fill = '#'); 186 void border (char fill = '#');
182 // more walls, dirty=false carves narrow corridors. 192 // more walls, dirty=false carves narrow corridors.
183 void isolation_remover (bool dirty = 0); 193 void isolation_remover (bool dirty = 0);
184 194
185 // 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
186 void gen_cave (int subtype); 196 void gen_cave (int subtype);
197
198 // helper functions to modify the layout
187 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
188 205
189 void swap (LayoutData &layout)
190 {
191 ::swap (layout.col, col);
192 ::swap (layout.w , w );
193 ::swap (layout.h , h );
194 }
195};
196
197// basically a layoutdata point - do not use in new code
198struct Layout
199{
200 LayoutData *ptr;
201
202 Layout ()
203 {
204 }
205
206 Layout (int xsize, int ysize)
207 : ptr (new LayoutData (xsize, ysize))
208 {
209 }
210
211 Layout (random_map_params *RP) 206 void generate (random_map_params *RP);
212 : ptr (new LayoutData (RP->Xsize, RP->Ysize))
213 {
214 }
215
216 void free ()
217 {
218 delete ptr;
219 }
220
221 LayoutData *operator ->() const
222 {
223 return ptr;
224 }
225
226 operator char **() const
227 {
228 return *ptr;
229 }
230
231 void swap (Layout &layout)
232 {
233 ::swap (layout.ptr, ptr);
234 }
235}; 207};
236 208
237// utility functions, to use rmg_rndm instead of rndm. 209// utility functions, to use rmg_rndm instead of rndm.
238static inline int 210static inline int
239rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) 211rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines