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.32 by root, Thu Jul 1 01:22:44 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 Layout 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 Layout (int w, int h); 168 layout (int w, int h);
169 layout (layout &copy);
166 ~Layout (); 170 ~layout ();
167 171
168 operator char **() 172 operator cell **() const
169 { 173 {
170 return col; 174 return data;
171 } 175 }
172 176
173 void swap (Layout &layout) 177 void swap (layout &maze)
174 { 178 {
175 ::swap (layout.col, col); 179 ::swap (maze.data, data);
176 ::swap (layout.w , w ); 180 ::swap (maze.w , w );
177 ::swap (layout.h , h ); 181 ::swap (maze.h , h );
178 } 182 }
179 183
184 MTH void swap (layout *maze) { swap (*maze); }
185
180 // for debugging, print layout to stdout 186 // for debugging, print maze to stdout
181 void print (); 187 MTH void print () const;
182 188
183 // simple inpainting 189 // simple inpainting
184 void fill (char fill); 190 MTH void fill (char fill);
185 void clear () { fill (0); } 191 MTH void clear () { fill (0); }
186 void border (char fill = '#'); 192 MTH void border (char fill = '#');
187 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
188 195
189 void fill_rand (int perc); 196 MTH void fill_rand (int perc);
190 197
191 // makes sure all areas are connected. dirty=true carves rounder but also 198 // makes sure all areas are connected
192 // more walls, dirty=false carves narrow corridors.
193 void isolation_remover (bool dirty = 0); 199 MTH void isolation_remover ();
194 200
195 // 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
196 void gen_cave (int subtype); 202 MTH void gen_cave (int subtype);
203
204 // helper functions to modify the maze
197 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
198 211
199 void generate (random_map_params *RP); 212 void generate (random_map_params *RP);
213private:
214 void alloc (int w, int h);
200}; 215};
201 216
202// utility functions, to use rmg_rndm instead of rndm. 217// utility functions, to use rmg_rndm instead of rndm.
203static inline int 218static inline int
204rmg_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