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.29 by root, Wed Jun 30 20:51:02 2010 UTC vs.
Revision 1.30 by root, Wed Jun 30 23:03:40 2010 UTC

94 LAYOUT_MAZE, 94 LAYOUT_MAZE,
95 LAYOUT_SPIRAL, 95 LAYOUT_SPIRAL,
96 LAYOUT_ROGUELIKE, 96 LAYOUT_ROGUELIKE,
97 LAYOUT_SNAKE, 97 LAYOUT_SNAKE,
98 LAYOUT_SQUARE_SPIRAL, 98 LAYOUT_SQUARE_SPIRAL,
99 LAYOUT_CAVE,
99 NROFLAYOUTS, 100 NROFLAYOUTS,
100}; 101};
101 102
102/* 103/*
103 * Move these defines out of room_gen_onion.c to here, as 104 * Move these defines out of room_gen_onion.c to here, as
150// > down 151// > down
151// C "center" (of onion layout) 152// C "center" (of onion layout)
152// . ?? (rogue) 153// . ?? (rogue)
153// 154//
154 155
156// use this in new code
155struct LayoutData 157struct LayoutData
156{ 158{
157 char **col; 159 char **col;
158 int w, h; 160 int w, h;
159 161
163 operator char **() 165 operator char **()
164 { 166 {
165 return col; 167 return col;
166 } 168 }
167 169
170 // for debugging, print layout to stdout
171 void print ();
172
173 // simple inpainting
168 void fill (char fill); 174 void fill (char fill);
169 void clear () { fill (0); } 175 void clear () { fill (0); }
170 void border (char fill = '#'); 176 void border (char fill = '#');
171 void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive 177 void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive
172 178
179 void fill_rand (int perc);
180
173 // makes sure all areas are connected. dirty=true carves rounder but also 181 // makes sure all areas are connected. dirty=true carves rounder but also
174 // mroe walls, dirty=false carves narrow corridors. 182 // more walls, dirty=false carves narrow corridors.
175 void isolation_remover (bool dirty = 0); 183 void isolation_remover (bool dirty = 0);
176};
177 184
185 // generates a cave, subtype 0 is a rough cave, randomly open or closed
186 void gen_cave (int subtype);
187 void erode_1_2 (int c1, int c2 = -1, int repeat = 1);
188
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
178struct Layout 198struct Layout
179{ 199{
180 LayoutData *ptr; 200 LayoutData *ptr;
181 201
182 Layout () 202 Layout ()
206 operator char **() const 226 operator char **() const
207 { 227 {
208 return *ptr; 228 return *ptr;
209 } 229 }
210 230
211 void swap (const Layout &layout) const 231 void swap (Layout &layout)
212 { 232 {
213 ::swap (layout.ptr->col, ptr->col); 233 ::swap (layout.ptr, ptr);
214 ::swap (layout.ptr->w , ptr->w );
215 ::swap (layout.ptr->h , ptr->h );
216 } 234 }
217
218 // for debugging, print layout to stdout
219 void print ();
220}; 235};
221 236
222// utility functions, to use rmg_rndm instead of rndm. 237// utility functions, to use rmg_rndm instead of rndm.
223static inline int 238static inline int
224rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) 239rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)
227 int i = find_free_spot (ob, m, x, y, start, stop); 242 int i = find_free_spot (ob, m, x, y, start, stop);
228 swap (rmg_rndm, rndm); 243 swap (rmg_rndm, rndm);
229 return i; 244 return i;
230} 245}
231 246
247// a simple point helper struct
232struct point 248struct point
233{ 249{
234 short x; 250 short x;
235 short y; 251 short y;
236 252
242 : x(x), y(y) 258 : x(x), y(y)
243 { 259 {
244 } 260 }
245}; 261};
246 262
263// something like a vector or stack, but without
264// out of bounds checking
247template<typename T> 265template<typename T>
248struct fixed_stack 266struct fixed_stack
249{ 267{
250 T *data; 268 T *data;
251 int size; 269 int size;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines