ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/maze_gen.C
(Generate patch)

Comparing deliantra/server/random_maps/maze_gen.C (file contents):
Revision 1.4 by root, Thu Sep 14 22:34:02 2006 UTC vs.
Revision 1.5 by root, Sun Dec 31 19:02:24 2006 UTC

1
1/* peterm@langmuir.eecs.berkeley.edu: this function generates a random 2/* peterm@langmuir.eecs.berkeley.edu: this function generates a random
2blocked maze with the property that there is only one path from one spot 3blocked maze with the property that there is only one path from one spot
3to any other, and there is always a path from one spot to any other. 4to any other, and there is always a path from one spot to any other.
4 5
5input: xsize, ysize; 6input: xsize, ysize;
228 count = RANDOM () % count; 229 count = RANDOM () % count;
229 else 230 else
230 count = 0; 231 count = 0;
231 switch (dirlist[count]) 232 switch (dirlist[count])
232 { 233 {
233 case 1: /* up */ 234 case 1: /* up */
234 { 235 {
235 *y = yc + 1; 236 *y = yc + 1;
236 *x = xc; 237 *x = xc;
237 break; 238 break;
238 }; 239 };
239 case 2: /* down */ 240 case 2: /* down */
240 { 241 {
241 *y = yc - 1; 242 *y = yc - 1;
242 *x = xc; 243 *x = xc;
243 break; 244 break;
244 }; 245 };
245 case 3: /* right */ 246 case 3: /* right */
246 { 247 {
247 *y = yc; 248 *y = yc;
248 *x = xc + 1; 249 *x = xc + 1;
249 break; 250 break;
250 } 251 }
251 case 4: /* left */ 252 case 4: /* left */
252 { 253 {
253 *x = xc - 1; 254 *x = xc - 1;
254 *y = yc; 255 *y = yc;
255 break; 256 break;
256 } 257 }
257 default: /* ??? */ 258 default: /* ??? */
258 { 259 {
259 return -1; 260 return -1;
260 } 261 }
261 } 262 }
262 return 1; 263 return 1;
263} 264}
264 265
265/* recursive routine which will fill every available space in the maze 266/* recursive routine which will fill every available space in the maze

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines