--- deliantra/server/random_maps/snake.C 2007/01/27 02:19:37 1.6 +++ deliantra/server/random_maps/snake.C 2008/04/15 03:00:24 1.9 @@ -10,36 +10,24 @@ */ - -#include #include -#include - - - +#include "random_map.h" +#include "rproto.h" -char ** -make_snake_layout (int xsize, int ysize, int options) +void +make_snake_layout (Layout maze, int options) { int i, j; - /* allocate that array, set it up */ - char **maze = (char **) calloc (sizeof (char *), xsize); + maze->clear (); + maze->border (); - for (i = 0; i < xsize; i++) - { - maze[i] = (char *) calloc (sizeof (char), 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] = '#'; + int xsize = maze->w; + int ysize = maze->h; /* Bail out if the size is too small to make a snake. */ if (xsize < 8 || ysize < 8) - return maze; + return; /* decide snake orientation--vertical or horizontal , and make the walls and place the doors. */ @@ -55,19 +43,18 @@ if (orientation) { for (j = 1; j < ysize - 2; j++) - { - maze[i][j] = '#'; - } + maze[i][j] = '#'; + maze[i][j] = 'D'; } else { for (j = 2; j < ysize; j++) - { - maze[i][j] = '#'; - } + maze[i][j] = '#'; + maze[i][1] = 'D'; } + orientation ^= 1; /* toggle the value of orientation */ } } @@ -82,19 +69,18 @@ if (orientation) { for (j = 1; j < xsize - 2; j++) - { - maze[j][i] = '#'; - } + maze[j][i] = '#'; + maze[j][i] = 'D'; } else { for (j = 2; j < xsize; j++) - { - maze[j][i] = '#'; - } + maze[j][i] = '#'; + maze[1][i] = 'D'; } + orientation ^= 1; /* toggle the value of orientation */ } } @@ -110,7 +96,5 @@ maze[1][1] = '>'; maze[xsize - 2][ysize - 2] = '<'; } - - - return maze; } +