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.5 by root, Sun Dec 31 19:02:24 2006 UTC vs.
Revision 1.7 by root, Sat Jan 27 02:19:37 2007 UTC

19#include <global.h> 19#include <global.h>
20 20
21/*#include <random_map.h>*/ 21/*#include <random_map.h>*/
22#include <maze_gen.h> 22#include <maze_gen.h>
23#include <time.h> 23#include <time.h>
24
25
26/* this include solely, and only, is needed for the definition of RANDOM */
27
28
29 24
30/* global variables that everyone needs: don't want to pass them in 25/* global variables that everyone needs: don't want to pass them in
31 as parameters every time. */ 26 as parameters every time. */
32int *wall_x_list = 0; 27int *wall_x_list = 0;
33int *wall_y_list = 0; 28int *wall_y_list = 0;
136/* randomly returns one of the elements from the wall point list */ 131/* randomly returns one of the elements from the wall point list */
137 132
138void 133void
139pop_wall_point (int *x, int *y) 134pop_wall_point (int *x, int *y)
140{ 135{
141 int index = RANDOM () % wall_free_size; 136 int index = rndm (wall_free_size);
142 137
143 *x = wall_x_list[index]; 138 *x = wall_x_list[index];
144 *y = wall_y_list[index]; 139 *y = wall_y_list[index];
145 /* write the last array point here */ 140 /* write the last array point here */
146 wall_x_list[index] = wall_x_list[wall_free_size - 1]; 141 wall_x_list[index] = wall_x_list[wall_free_size - 1];
224 if (count == 0) 219 if (count == 0)
225 return -1; /* failed to find any clear points */ 220 return -1; /* failed to find any clear points */
226 221
227 /* choose a random direction */ 222 /* choose a random direction */
228 if (count > 1) 223 if (count > 1)
229 count = RANDOM () % count; 224 count = rndm (count);
230 else 225 else
231 count = 0; 226 count = 0;
227
232 switch (dirlist[count]) 228 switch (dirlist[count])
233 { 229 {
234 case 1: /* up */ 230 case 1: /* up */
235 { 231 {
236 *y = yc + 1; 232 *y = yc + 1;
273 269
274 /* write a wall here */ 270 /* write a wall here */
275 maze[x][y] = '#'; 271 maze[x][y] = '#';
276 272
277 /* decide if we're going to pick from the wall_free_list */ 273 /* decide if we're going to pick from the wall_free_list */
278 if (RANDOM () % 4 && wall_free_size > 0) 274 if (rndm (4) && wall_free_size > 0)
279 { 275 {
280 pop_wall_point (&xc, &yc); 276 pop_wall_point (&xc, &yc);
281 fill_maze_full (maze, xc, yc, xsize, ysize); 277 fill_maze_full (maze, xc, yc, xsize, ysize);
282 } 278 }
283 279
299 295
300 /* write a wall here */ 296 /* write a wall here */
301 maze[x][y] = '#'; 297 maze[x][y] = '#';
302 298
303 /* decide if we're going to pick from the wall_free_list */ 299 /* decide if we're going to pick from the wall_free_list */
304 if (RANDOM () % 4 && wall_free_size > 0) 300 if (rndm (4) && wall_free_size > 0)
305 { 301 {
306 pop_wall_point (&xc, &yc); 302 pop_wall_point (&xc, &yc);
307 fill_maze_sparse (maze, xc, yc, xsize, ysize); 303 fill_maze_sparse (maze, xc, yc, xsize, ysize);
308 } 304 }
309 305

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines