--- deliantra/server/random_maps/treasure.C 2010/07/02 03:40:14 1.56 +++ deliantra/server/random_maps/treasure.C 2010/07/02 15:03:57 1.57 @@ -45,13 +45,13 @@ static object *find_closest_monster (maptile *map, int x, int y, random_map_params *RP); static object *find_monster_in_room (maptile *map, int x, int y, random_map_params *RP); -static void find_spot_in_room_recursive (char **layout, int x, int y, random_map_params *RP); +static void find_spot_in_room_recursive (char **maze, int x, int y, random_map_params *RP); static void find_spot_in_room (maptile *map, int x, int y, int *kx, int *ky, random_map_params *RP); static object *place_chest (int treasureoptions, int x, int y, maptile *map, maptile *style_map, int n_treasures, random_map_params *RP); static object **find_doors_in_room (maptile *map, int x, int y, random_map_params *RP); static void lock_and_hide_doors (object **doorlist, maptile *map, int opts, random_map_params *RP); static void find_enclosed_spot (maptile *map, int *cx, int *cy, random_map_params *RP); -static object **surround_by_doors (maptile *map, char **layout, int x, int y, int opts); +static object **surround_by_doors (maptile *map, char **maze, int x, int y, int opts); /* a macro to get a strongly centered random distribution, from 0 to x, centered at x/2 */ @@ -189,12 +189,12 @@ /* place treasures in the map, given the map, (required) -layout, (required) +maze, (required) treasure style (may be empty or NULL, or "none" to cause no treasure.) treasureoptions (may be 0 for random choices or positive) */ void -place_treasure (maptile *map, char **layout, const char *treasure_style, int treasureoptions, random_map_params *RP) +place_treasure (maptile *map, char **maze, const char *treasure_style, int treasureoptions, random_map_params *RP) { int num_treasures; @@ -252,7 +252,7 @@ { for (j = 0; j < RP->Ysize; j++) { - if (layout[i][j] == 'C' || layout[i][j] == '>') + if (maze[i][j] == 'C' || maze[i][j] == '>') { int tdiv = RP->symmetry_used; object *chest; @@ -307,7 +307,7 @@ j = chest->y; if (treasureoptions & (DOORED | HIDDEN)) { - doorlist = surround_by_doors (map, layout, i, j, treasureoptions); + doorlist = surround_by_doors (map, maze, i, j, treasureoptions); lock_and_hide_doors (doorlist, map, treasureoptions, RP); free (doorlist); } @@ -315,7 +315,7 @@ } } else - { /* DIFFUSE treasure layout */ + { /* DIFFUSE treasure maze */ int ti, i, j; for (ti = 0; ti < num_treasures; ti++) @@ -449,9 +449,9 @@ static object *theMonsterToFind; /* a recursive routine which will return a monster, eventually,if there is one. - it does a check-off on the layout, converting 0's to 1's */ + it does a check-off on the maze, converting 0's to 1's */ static object * -find_monster_in_room_recursive (char **layout, maptile *map, int x, int y, random_map_params *RP) +find_monster_in_room_recursive (char **maze, maptile *map, int x, int y, random_map_params *RP) { int i, j; @@ -464,12 +464,12 @@ return theMonsterToFind; /* if the square is blocked or searched already, leave */ - if (layout[x][y] != 0) + if (maze[x][y] != 0) return theMonsterToFind; /* might be NULL, that's fine. */ /* check the current square for a monster. If there is one, set theMonsterToFind and return it. */ - layout[x][y] = 1; + maze[x][y] = 1; if (GET_MAP_FLAGS (map, x, y) & P_IS_ALIVE) { object *the_monster = GET_MAP_OB (map, x, y); @@ -486,7 +486,7 @@ /* now search all the 8 squares around recursively for a monster,in random order */ for (i = rmg_rndm (8), j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) { - theMonsterToFind = find_monster_in_room_recursive (layout, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); + theMonsterToFind = find_monster_in_room_recursive (maze, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); if (theMonsterToFind != NULL) return theMonsterToFind; } @@ -499,7 +499,7 @@ static object * find_monster_in_room (maptile *map, int x, int y, random_map_params *RP) { - Layout layout2 (map->width, map->height); + layout layout2 (map->width, map->height); // find walls for (int i = 0; i < layout2.w; i++) @@ -521,7 +521,7 @@ a datastructure of free points is set up, and a position chosen from that datastructure. */ static void -find_spot_in_room_recursive (char **layout, int x, int y, random_map_params *RP) +find_spot_in_room_recursive (char **maze, int x, int y, random_map_params *RP) { int i, j; @@ -530,20 +530,20 @@ return; /* if the square is blocked or searched already, leave */ - if (layout[x][y] != 0) + if (maze[x][y] != 0) return; /* set the current square as checked, and add it to the list. set theMonsterToFind and return it. */ /* check off this point */ - layout[x][y] = 1; + maze[x][y] = 1; room_free_spots_x[number_of_free_spots_in_room] = x; room_free_spots_y[number_of_free_spots_in_room] = y; number_of_free_spots_in_room++; /* now search all the 8 squares around recursively for free spots,in random order */ for (i = rmg_rndm (8), j = 0; j < 8 && theMonsterToFind == NULL; i++, j++) - find_spot_in_room_recursive (layout, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); + find_spot_in_room_recursive (maze, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], RP); } @@ -559,7 +559,7 @@ room_free_spots_y = (int *) calloc (sizeof (int), RP->Xsize * RP->Ysize); layout2 = (char **) calloc (sizeof (char *), RP->Xsize); - /* allocate and copy the layout, converting C to 0. */ + /* allocate and copy the maze, converting C to 0. */ for (i = 0; i < RP->Xsize; i++) { layout2[i] = (char *) calloc (sizeof (char), RP->Ysize); @@ -578,7 +578,7 @@ *ky = room_free_spots_y[i]; } - /* deallocate the temp. layout */ + /* deallocate the temp. maze */ for (i = 0; i < RP->Xsize; i++) free (layout2[i]); @@ -684,7 +684,7 @@ a chest. It only goes as far as the 8 squares surrounding, and it'll remove any monsters it finds.*/ static object ** -surround_by_doors (maptile *map, char **layout, int x, int y, int opts) +surround_by_doors (maptile *map, char **maze, int x, int y, int opts) { int i; const char *doors[2]; @@ -709,7 +709,7 @@ { int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; - if (!wall_blocked (map, x1, y1) && layout[x1][y1] == '>') + if (!wall_blocked (map, x1, y1) && maze[x1][y1] == '>') { /* place a door */ remove_monsters (x1, y1, map); @@ -736,7 +736,7 @@ /* the workhorse routine, which finds the doors in a room */ static void -find_doors_in_room_recursive (char **layout, maptile *map, int x, int y, object **doorlist, int *ndoors, random_map_params *RP) +find_doors_in_room_recursive (char **maze, maptile *map, int x, int y, object **doorlist, int *ndoors, random_map_params *RP) { int i, j; object *door; @@ -746,13 +746,13 @@ return; /* if the square is blocked or searched already, leave */ - if (layout[x][y] == 1) + if (maze[x][y] == 1) return; /* check off this point */ - if (layout[x][y] == '#') + if (maze[x][y] == '#') { /* there could be a door here */ - layout[x][y] = 1; + maze[x][y] = 1; door = door_in_square (map, x, y); if (door) { @@ -769,11 +769,11 @@ } else { - layout[x][y] = 1; + maze[x][y] = 1; /* now search all the 8 squares around recursively for free spots,in random order */ for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) - find_doors_in_room_recursive (layout, map, + find_doors_in_room_recursive (maze, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], doorlist, ndoors, RP); } @@ -788,10 +788,10 @@ object **doorlist = (object **)calloc (sizeof (int), 1024); - Layout layout2 (RP->Xsize, RP->Ysize); + layout layout2 (RP->Xsize, RP->Ysize); layout2.clear (); - /* allocate and copy the layout, converting C to 0. */ + /* allocate and copy the maze, converting C to 0. */ for (i = 0; i < RP->Xsize; i++) for (j = 0; j < RP->Ysize; j++) layout2[i][j] = wall_blocked (map, i, j) ? '#' : 0;