--- deliantra/server/random_maps/maze_gen.C 2008/04/11 21:09:53 1.8 +++ deliantra/server/random_maps/maze_gen.C 2008/05/04 14:12:37 1.11 @@ -34,45 +34,39 @@ /* the outsize interface routine: accepts sizes, returns a char ** maze. option is a flag for either a sparse or a full maze. Sparse mazes have sizable rooms. option = 1, full, 0, sparse.*/ - -Maze -maze_gen (int xsize, int ysize, int option) +void +maze_gen (Layout maze, int option) { - int i, j; - - Maze maze (xsize, ysize); - - /* write the outer walls */ - for (i = 0; i < xsize; i++) maze[i][0] = maze[i][ysize - 1] = '#'; - for (j = 0; j < ysize; j++) maze[0][j] = maze[xsize - 1][j] = '#'; + maze->clear (); + maze->border (); /* find how many free wall spots there are */ - wall_free_size = 2 * (xsize - 4) + 2 * (ysize - 4); + wall_free_size = 2 * (maze->w - 4) + 2 * (maze->h - 4); - make_wall_free_list (xsize, ysize); + make_wall_free_list (maze->w, maze->h); /* return the empty maze */ if (wall_free_size <= 0) - return maze; + return; /* recursively generate the walls of the maze */ /* first pop a random starting point */ while (wall_free_size > 0) { + int i, j; + pop_wall_point (&i, &j); if (option) - fill_maze_full (maze, i, j, xsize, ysize); + fill_maze_full (maze, i, j, maze->w, maze->h); else - fill_maze_sparse (maze, i, j, xsize, ysize); + fill_maze_sparse (maze, i, j, maze->w, maze->h); } /* clean up our intermediate data structures. */ free (wall_x_list); free (wall_y_list); - - return maze; } /* the free wall points are those outer points which aren't corners or @@ -117,7 +111,7 @@ void pop_wall_point (int *x, int *y) { - int index = rndm (wall_free_size); + int index = rmg_rndm (wall_free_size); *x = wall_x_list[index]; *y = wall_y_list[index]; @@ -152,7 +146,6 @@ } } - /* look down */ if (yc > 2 && xc > 2 && xc < xsize - 2) /* it is valid to look down */ { @@ -167,7 +160,6 @@ } } - /* look right */ if (xc < xsize - 2 && yc > 2 && yc < ysize - 2) /* it is valid to look left */ { @@ -182,7 +174,6 @@ } } - /* look left */ if (xc > 2 && yc > 2 && yc < ysize - 2) /* it is valid to look down */ { @@ -202,7 +193,7 @@ /* choose a random direction */ if (count > 1) - count = rndm (count); + count = rmg_rndm (count); else count = 0; @@ -241,7 +232,6 @@ /* recursive routine which will fill every available space in the maze with walls*/ - void fill_maze_full (char **maze, int x, int y, int xsize, int ysize) { @@ -251,7 +241,7 @@ maze[x][y] = '#'; /* decide if we're going to pick from the wall_free_list */ - if (rndm (4) && wall_free_size > 0) + if (rmg_rndm (4) && wall_free_size > 0) { pop_wall_point (&xc, &yc); fill_maze_full (maze, xc, yc, xsize, ysize); @@ -275,7 +265,7 @@ maze[x][y] = '#'; /* decide if we're going to pick from the wall_free_list */ - if (rndm (4) && wall_free_size > 0) + if (rmg_rndm (4) && wall_free_size > 0) { pop_wall_point (&xc, &yc); fill_maze_sparse (maze, xc, yc, xsize, ysize);