--- deliantra/server/random_maps/expand2x.C 2006/08/29 08:01:36 1.2 +++ deliantra/server/random_maps/expand2x.C 2006/09/10 16:06:37 1.3 @@ -1,61 +1,67 @@ + /* * Expands a layout by 2x in each dimension. * H. S. Teoh * -------------------------------------------------------------------------- - * $Id: expand2x.C,v 1.2 2006/08/29 08:01:36 root Exp $ + * $Id: expand2x.C,v 1.3 2006/09/10 16:06:37 root Exp $ * * ALGORITHM * * ... (TBW) */ -#include /* just in case */ -#include /* use compiler to do sanity check */ +#include /* just in case */ +#include /* use compiler to do sanity check */ /* PROTOTYPES */ -static void expand_misc(char **newlayout, int i, int j, char **layout, - int xsize, int ysize); -static void expand_wall(char **newlayout, int i, int j, char **layout, - int xsize, int ysize); -static void expand_door(char **newlayout, int i, int j, char **layout, - int xsize, int ysize); +static void expand_misc (char **newlayout, int i, int j, char **layout, int xsize, int ysize); +static void expand_wall (char **newlayout, int i, int j, char **layout, int xsize, int ysize); +static void expand_door (char **newlayout, int i, int j, char **layout, int xsize, int ysize); /* FUNCTIONS */ -char **expand2x(char **layout, int xsize, int ysize) { - int i,j; - int nxsize = xsize*2 - 1; - int nysize = ysize*2 - 1; +char ** +expand2x (char **layout, int xsize, int ysize) +{ + int i, j; + int nxsize = xsize * 2 - 1; + int nysize = ysize * 2 - 1; /* Allocate new layout */ - char **newlayout = (char **)calloc(sizeof(char*), nxsize); - for (i=0; i X \0 * \0 \0 */ -static void expand_misc(char **newlayout, int i, int j, char **layout, - int xsize, int ysize) { - newlayout[i*2][j*2] = layout[i][j]; +static void +expand_misc (char **newlayout, int i, int j, char **layout, int xsize, int ysize) +{ + newlayout[i * 2][j * 2] = layout[i][j]; /* (Note: no need to reset rest of 2x2 area to \0 because calloc does that * for us.) */ } @@ -79,19 +86,21 @@ * 4 match on (i+1, j+1) * and the possible combinations thereof. */ -static int calc_pattern(char ch, char **layout, int i, int j, - int xsize, int ysize) { +static int +calc_pattern (char ch, char **layout, int i, int j, int xsize, int ysize) +{ int pattern = 0; - if (i+1