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