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.39 by root, Sat Jul 3 01:49:18 2010 UTC vs.
Revision 1.45 by root, Mon Jul 5 00:07:21 2010 UTC

34 int xsize, ysize; 34 int xsize, ysize;
35 int expand2x; 35 int expand2x;
36 int layoutoptions1; 36 int layoutoptions1;
37 int layoutoptions2; 37 int layoutoptions2;
38 int layoutoptions3; 38 int layoutoptions3;
39 int symmetry;
40 int difficulty; 39 int difficulty;
41 int difficulty_given; 40 int difficulty_given;
42 float difficulty_increase; 41 float difficulty_increase;
43 42
44 int dungeon_level; 43 int dungeon_level;
45 int dungeon_depth; 44 int dungeon_depth;
46 45
47 int orientation;
48 uint32_t random_seed; 46 uint32_t random_seed;
49 uint64_t total_map_hp; 47 uint64_t total_map_hp;
50 int map_layout_style;
51 int symmetry_used;
52 48
53 HV *hv; 49 HV *hv;
54 void hv_clone (); // replaces the hv by a clone'd copy (%new_hv = { %hv })
55 50
56 shstr_tmp as_shstr () const; 51 shstr_tmp as_shstr () const;
57 52
58 // fetch something from the options hash 53 // fetch something from the options hash
59 SV *get_sv (const char *option) const; 54 SV *get_sv (const char *option) const;
72 67
73 // "private", adjusted sizes 68 // "private", adjusted sizes
74 int Xsize; 69 int Xsize;
75 int Ysize; 70 int Ysize;
76 71
72 int map_layout_style;
73 int symmetry_used;
74
77 random_map_params (); 75 random_map_params ();
76 random_map_params (random_map_params *RP);
78 random_map_params (HV *hv); 77 random_map_params (HV *hv);
79 ~random_map_params (); 78 ~random_map_params ();
80}; 79};
81 80
82enum { 81enum {
86 LAYOUT_SPIRAL, 85 LAYOUT_SPIRAL,
87 LAYOUT_ROGUELIKE, 86 LAYOUT_ROGUELIKE,
88 LAYOUT_SNAKE, 87 LAYOUT_SNAKE,
89 LAYOUT_SQUARE_SPIRAL, 88 LAYOUT_SQUARE_SPIRAL,
90 LAYOUT_CAVE, 89 LAYOUT_CAVE,
90 LAYOUT_CASTLE,
91 LAYOUT_MULTIPLE,
91 NROFLAYOUTS, 92 NROFLAYOUTS,
92}; 93};
93 94
94/* 95/*
95 * Move these defines out of room_gen_onion.c to here, as 96 * Move these defines out of room_gen_onion.c to here, as
134#define MIN_RANDOM_MAP_SIZE 12 135#define MIN_RANDOM_MAP_SIZE 12
135 136
136// we often use signed chars for coordinates (and U8 for distances) 137// we often use signed chars for coordinates (and U8 for distances)
137#define MAX_RANDOM_MAP_SIZE 120 138#define MAX_RANDOM_MAP_SIZE 120
138 139
140// a simple point helper struct
141struct point
142{
143 int x;
144 int y;
145
146 point ()
147 {
148 }
149
150 point (int x, int y)
151 : x(x), y(y)
152 {
153 }
154};
155
156//
139// reference 157// reference
140// 158//
141// \0 floor only 159// \0 floor only
142// # wall 160// # wall
143// D door 161// D door
144// < up 162// < entrance (traditionally up)
145// > down 163// > exit (traditionally down)
146// C "center" (of onion maze) 164// C "center" (of onion maze)
147// . ?? (rogue) 165// . ?? (rogue)
148// 166//
149 167
150// use this in new code 168// use this in new code
156 cell **data; 174 cell **data;
157 int w, h; 175 int w, h;
158 176
159 layout (int w, int h); 177 layout (int w, int h);
160 layout (layout &copy); 178 layout (layout &copy);
179
180 // reference rect in other layout - will not keep the data alive,
181 // so never swap with it's orig, or free the orig when in use.
182 layout (layout &orig, int x1, int y1, int x2, int y2);
183
161 ~layout (); 184 ~layout ();
162 185
163 operator cell **() const 186 operator cell **() const
164 { 187 {
165 return data; 188 return data;
166 } 189 }
167 190
168 void swap (layout &maze) 191 void swap (layout &maze)
169 { 192 {
170 ::swap (maze.data, data); 193 ::swap (maze.data, data);
171 ::swap (maze.w , w ); 194 ::swap (maze.w , w );
172 ::swap (maze.h , h ); 195 ::swap (maze.h , h );
196 ::swap (maze.size, size);
173 } 197 }
174 198
175 MTH void swap (layout *maze) { swap (*maze); } 199 MTH void swap (layout *maze) { swap (*maze); }
176 200
177 // for debugging, print maze to stdout 201 // for debugging, print maze to stdout
183 MTH void border (char fill = '#'); 207 MTH void border (char fill = '#');
184 MTH void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive 208 MTH void rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive
185 MTH void fill_rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive 209 MTH void fill_rect (int x1, int y1, int x2, int y2, char fill); // x2, y2 exclusive
186 210
187 MTH void fill_rand (int perc); 211 MTH void fill_rand (int perc);
212 MTH void replace (char from, char to);
213
214 point find (char target, int mode = 0); // mode 0=random, 1=upleft, 2=upright, 3=downright, 4=downleft
188 215
189 // makes sure all areas are connected 216 // makes sure all areas are connected
217 // perturb = 0 - very horz/vert tunnels
218 // perturb = 1 - straight but round
219 // perturb = 2 - snaky tunnels
190 MTH void isolation_remover (); 220 MTH void isolation_remover (int perturb = 2);
191 221
192 // generates a cave, subtype 0 is a rough cave, randomly open or closed 222 // generates a cave, subtype 0 is a rough cave, randomly open or closed
193 MTH void gen_cave (int subtype); 223 MTH void gen_cave (int subtype);
224 MTH void gen_castle (); // generates straightish structures
194 225
195 // helper functions to modify the maze 226 // helper functions to modify the maze
196 MTH void erode_1_2 (int c1, int c2 = -1, int repeat = 1); 227 MTH void erode_1_2 (int c1, int c2 = -1, int repeat = 1);
197 MTH void doorify (); 228 MTH void doorify ();
198 MTH void roomify (); // make some rooms in it, works best on onions 229 MTH void roomify (); // make some rooms in it, works best on onions
200 MTH void symmetrize (int symmetry); 231 MTH void symmetrize (int symmetry);
201 MTH void rotate (int rotation); // rotate by 1=90, 2=180, 3=270 degrees 232 MTH void rotate (int rotation); // rotate by 1=90, 2=180, 3=270 degrees
202 233
203 void generate (random_map_params *RP); 234 void generate (random_map_params *RP);
204private: 235private:
236 int size;
205 void alloc (int w, int h); 237 void alloc (int w, int h);
206}; 238};
207 239
208// utility functions, to use rmg_rndm instead of rndm. 240// utility functions, to use rmg_rndm instead of rndm.
209static inline int 241static inline int
213 int i = find_free_spot (ob, m, x, y, start, stop); 245 int i = find_free_spot (ob, m, x, y, start, stop);
214 swap (rmg_rndm, rndm); 246 swap (rmg_rndm, rndm);
215 return i; 247 return i;
216} 248}
217 249
218// a simple point helper struct
219struct point
220{
221 short x;
222 short y;
223
224 point ()
225 {
226 }
227
228 point (int x, int y)
229 : x(x), y(y)
230 {
231 }
232};
233
234// something like a vector or stack, but without 250// something like a vector or stack, but without
235// out of bounds checking 251// out of bounds checking
236template<typename T> 252template<typename T>
237struct fixed_stack 253struct fixed_stack
238{ 254{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines