--- deliantra/server/random_maps/maze_gen.C 2006/09/14 22:34:02 1.4 +++ deliantra/server/random_maps/maze_gen.C 2007/01/27 02:19:37 1.7 @@ -1,3 +1,4 @@ + /* peterm@langmuir.eecs.berkeley.edu: this function generates a random blocked maze with the property that there is only one path from one spot to any other, and there is always a path from one spot to any other. @@ -21,11 +22,6 @@ #include #include - -/* this include solely, and only, is needed for the definition of RANDOM */ - - - /* global variables that everyone needs: don't want to pass them in as parameters every time. */ int *wall_x_list = 0; @@ -137,7 +133,7 @@ void pop_wall_point (int *x, int *y) { - int index = RANDOM () % wall_free_size; + int index = rndm (wall_free_size); *x = wall_x_list[index]; *y = wall_y_list[index]; @@ -225,39 +221,40 @@ /* choose a random direction */ if (count > 1) - count = RANDOM () % count; + count = rndm (count); else count = 0; + switch (dirlist[count]) { - case 1: /* up */ - { - *y = yc + 1; - *x = xc; - break; - }; - case 2: /* down */ - { - *y = yc - 1; - *x = xc; - break; - }; - case 3: /* right */ - { - *y = yc; - *x = xc + 1; - break; - } - case 4: /* left */ - { - *x = xc - 1; - *y = yc; - break; - } - default: /* ??? */ - { - return -1; - } + case 1: /* up */ + { + *y = yc + 1; + *x = xc; + break; + }; + case 2: /* down */ + { + *y = yc - 1; + *x = xc; + break; + }; + case 3: /* right */ + { + *y = yc; + *x = xc + 1; + break; + } + case 4: /* left */ + { + *x = xc - 1; + *y = yc; + break; + } + default: /* ??? */ + { + return -1; + } } return 1; } @@ -274,7 +271,7 @@ maze[x][y] = '#'; /* decide if we're going to pick from the wall_free_list */ - if (RANDOM () % 4 && wall_free_size > 0) + if (rndm (4) && wall_free_size > 0) { pop_wall_point (&xc, &yc); fill_maze_full (maze, xc, yc, xsize, ysize); @@ -300,7 +297,7 @@ maze[x][y] = '#'; /* decide if we're going to pick from the wall_free_list */ - if (RANDOM () % 4 && wall_free_size > 0) + if (rndm (4) && wall_free_size > 0) { pop_wall_point (&xc, &yc); fill_maze_sparse (maze, xc, yc, xsize, ysize);