--- deliantra/server/random_maps/exit.C 2010/07/03 13:14:35 1.47 +++ deliantra/server/random_maps/exit.C 2010/07/04 22:12:26 1.48 @@ -30,13 +30,13 @@ /* find a character in the maze. fx and fy are pointers to where to find the char. fx,fy = -1 if not found. */ static void -find_in_layout (int mode, char target, int *fx, int *fy, char **maze, random_map_params *RP) +find_in_layout (int mode, char target, int &fx, int &fy, layout &maze) { int M; int i, j; - *fx = -1; - *fy = -1; + fx = -1; + fy = -1; /* if a starting point isn't given, pick one */ if (mode < 1 || mode > 4) @@ -51,13 +51,13 @@ { case 1: /* search from top left down/right */ - for (i = 1; i < RP->Xsize; i++) - for (j = 1; j < RP->Ysize; j++) + for (i = 1; i < maze.w; i++) + for (j = 1; j < maze.h; j++) { if (maze[i][j] == target) { - *fx = i; - *fy = j; + fx = i; + fy = j; return; } } @@ -65,13 +65,13 @@ case 2: /* Search from top right down/left */ - for (i = RP->Xsize - 2; i > 0; i--) - for (j = 1; j < RP->Ysize - 1; j++) + for (i = maze.w - 2; i > 0; i--) + for (j = 1; j < maze.h - 1; j++) { if (maze[i][j] == target) { - *fx = i; - *fy = j; + fx = i; + fy = j; return; } } @@ -79,13 +79,13 @@ case 3: /* search from bottom-left up-right */ - for (i = 1; i < RP->Xsize - 1; i++) - for (j = RP->Ysize - 2; j > 0; j--) + for (i = 1; i < maze.w - 1; i++) + for (j = maze.h - 2; j > 0; j--) { if (maze[i][j] == target) { - *fx = i; - *fy = j; + fx = i; + fy = j; return; } } @@ -93,18 +93,17 @@ case 4: /* search from bottom-right up-left */ - for (i = RP->Xsize - 2; i > 0; i--) - for (j = RP->Ysize - 2; j > 0; j--) + for (i = maze.w - 2; i > 0; i--) + for (j = maze.h - 2; j > 0; j--) { if (maze[i][j] == target) { - *fx = i; - *fy = j; + fx = i; + fy = j; return; } } break; - } } @@ -117,7 +116,7 @@ 6 means southward */ void -place_exits (maptile *map, char **maze, const char *exitstyle, int orientation, random_map_params *RP) +place_exits (maptile *map, layout &maze, const char *exitstyle, int orientation, random_map_params *RP) { maptile *style_map_down = 0; /* harder maze */ maptile *style_map_up = 0; /* easier maze */ @@ -182,10 +181,10 @@ /* begin a logical block */ { /* First, look for a '<' char */ - find_in_layout (0, '<', &upx, &upy, maze, RP); + find_in_layout (0, '<', upx, upy, maze); /* next, look for a C, the map center. */ - find_in_layout (0, 'C', &cx, &cy, maze, RP); + find_in_layout (0, 'C', cx, cy, maze); /* if we didn't find an up, find an empty place far from the center */ if (upx == -1 && cx != -1) @@ -202,18 +201,18 @@ /* find an empty place far from the center */ if (upx == 1 && upy == 1) - find_in_layout (1, 0, &upx, &upy, maze, RP); + find_in_layout (1, 0, upx, upy, maze); else if (upx == 1 && upy > 1) - find_in_layout (3, 0, &upx, &upy, maze, RP); + find_in_layout (3, 0, upx, upy, maze); else if (upx > 1 && upy == 1) - find_in_layout (2, 0, &upx, &upy, maze, RP); + find_in_layout (2, 0, upx, upy, maze); else if (upx > 1 && upy > 1) - find_in_layout (4, 0, &upx, &upy, maze, RP); + find_in_layout (4, 0, upx, upy, maze); } /* no indication of where to place the exit, so just place it. */ if (upx == -1) - find_in_layout (0, 0, &upx, &upy, maze, RP); + find_in_layout (0, 0, upx, upy, maze); the_exit_up->x = upx; the_exit_up->y = upy; @@ -238,7 +237,7 @@ map->enter_y = the_exit_up->y; /* first, look for a '>' character */ - find_in_layout (0, '>', &downx, &downy, maze, RP); + find_in_layout (0, '>', downx, downy, maze); /* if no > is found use C */ if (downx == -1) @@ -263,18 +262,18 @@ /* find an empty place far from the entrance */ if (downx == 1 && downy == 1) - find_in_layout (1, 0, &downx, &downy, maze, RP); + find_in_layout (1, 0, downx, downy, maze); else if (downx == 1 && downy > 1) - find_in_layout (3, 0, &downx, &downy, maze, RP); + find_in_layout (3, 0, downx, downy, maze); else if (downx > 1 && downy == 1) - find_in_layout (2, 0, &downx, &downy, maze, RP); + find_in_layout (2, 0, downx, downy, maze); else if (downx > 1 && downy > 1) - find_in_layout (4, 0, &downx, &downy, maze, RP); + find_in_layout (4, 0, downx, downy, maze); } /* no indication of where to place the down exit, so just place it */ if (downx == -1) - find_in_layout (0, 0, &downx, &downy, maze, RP); + find_in_layout (0, 0, downx, downy, maze); if (the_exit_down) { @@ -339,13 +338,13 @@ keep things from being dumped on them during the other phases of random map generation. */ void -unblock_exits (maptile *map, char **maze, random_map_params *RP) +unblock_exits (maptile *map, layout &maze) { int i = 0, j = 0; object *walk; - for (i = 0; i < RP->Xsize; i++) - for (j = 0; j < RP->Ysize; j++) + for (i = 0; i < maze.w; i++) + for (j = 0; j < maze.h; j++) if (maze[i][j] == '>' || maze[i][j] == '<') { for (walk = GET_MAP_OB (map, i, j); walk != NULL; walk = walk->above)