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.31 by root, Wed Jun 30 23:15:56 2010 UTC vs.
Revision 1.37 by root, Sat Jul 3 00:39:57 2010 UTC

150// \0 floor only 150// \0 floor only
151// # wall 151// # wall
152// D door 152// D door
153// < up 153// < up
154// > down 154// > down
155// C "center" (of onion layout) 155// C "center" (of onion maze)
156// . ?? (rogue) 156// . ?? (rogue)
157// 157//
158 158
159// use this in new code 159// use this in new code
160INTERFACE_CLASS(layout)
160struct LayoutData 161struct layout
161{ 162{
162 char **col; 163 typedef char cell;
164
165 cell **data;
163 int w, h; 166 int w, h;
164 167
165 LayoutData (int w, int h); 168 layout (int w, int h);
169 layout (layout &copy);
166 ~LayoutData (); 170 ~layout ();
167 171
168 operator char **() 172 operator cell **() const
169 { 173 {
170 return col; 174 return data;
171 } 175 }
172 176
177 void swap (layout &maze)
178 {
179 ::swap (maze.data, data);
180 ::swap (maze.w , w );
181 ::swap (maze.h , h );
182 }
183
184 MTH void swap (layout *maze) { swap (*maze); }
185
173 // for debugging, print layout to stdout 186 // for debugging, print maze to stdout
174 void print (); 187 MTH void print () const;
175 188
176 // simple inpainting 189 // simple inpainting
177 void fill (char fill); 190 MTH void fill (char fill);
178 void clear () { fill (0); } 191 MTH void clear () { fill (0); }
179 void border (char fill = '#'); 192 MTH void border (char fill = '#');
180 void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive 193 MTH void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive
194 MTH void fill_rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive
181 195
182 void fill_rand (int perc); 196 MTH void fill_rand (int perc);
183 197
184 // makes sure all areas are connected. dirty=true carves rounder but also 198 // makes sure all areas are connected
185 // more walls, dirty=false carves narrow corridors.
186 void isolation_remover (bool dirty = 0); 199 MTH void isolation_remover ();
187 200
188 // generates a cave, subtype 0 is a rough cave, randomly open or closed 201 // generates a cave, subtype 0 is a rough cave, randomly open or closed
189 void gen_cave (int subtype); 202 MTH void gen_cave (int subtype);
203
204 // helper functions to modify the maze
190 void erode_1_2 (int c1, int c2 = -1, int repeat = 1); 205 MTH void erode_1_2 (int c1, int c2 = -1, int repeat = 1);
206 MTH void doorify ();
207 MTH void roomify (); // make some rooms in it, works best on onions
208 MTH void expand2x ();
209 MTH void symmetrize (int symmetry);
210 MTH void rotate (int rotation); // rotate by 1=90, 2=180, 3=270 degrees
191 211
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
201struct 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) 212 void generate (random_map_params *RP);
215 : ptr (new LayoutData (RP->Xsize, RP->Ysize)) 213private:
216 { 214 void alloc (int w, int h);
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}; 215};
239 216
240// utility functions, to use rmg_rndm instead of rndm. 217// utility functions, to use rmg_rndm instead of rndm.
241static inline int 218static inline int
242rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) 219rmg_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