--- deliantra/server/random_maps/treasure.C 2006/12/30 18:45:28 1.11 +++ deliantra/server/random_maps/treasure.C 2006/12/31 19:02:24 1.12 @@ -1,3 +1,4 @@ + /* CrossFire, A Multiplayer game for X-windows @@ -69,7 +70,7 @@ */ void -place_treasure (maptile *map, char **layout, char *treasure_style, int treasureoptions, random_map_params * RP) +place_treasure (maptile *map, char **layout, char *treasure_style, int treasureoptions, random_map_params *RP) { char styledirname[256]; char stylefilepath[256]; @@ -115,69 +116,69 @@ /* map_layout_style global, and is previously set */ switch (RP->map_layout_style) { - case LAYOUT_ONION: - case LAYOUT_SPIRAL: - case LAYOUT_SQUARE_SPIRAL: - { - int i, j; - - /* search the onion for C's or '>', and put treasure there. */ - for (i = 0; i < RP->Xsize; i++) - { - for (j = 0; j < RP->Ysize; j++) - { - if (layout[i][j] == 'C' || layout[i][j] == '>') - { - int tdiv = RP->symmetry_used; - object **doorlist; - object *chest; - - if (tdiv == 3) - tdiv = 2; /* this symmetry uses a divisor of 2 */ - /* don't put a chest on an exit. */ - chest = place_chest (treasureoptions, i, j, map, style_map, num_treasures / tdiv, RP); - if (!chest) - continue; /* if no chest was placed NEXT */ - if (treasureoptions & (DOORED | HIDDEN)) - { - doorlist = find_doors_in_room (map, i, j, RP); - lock_and_hide_doors (doorlist, map, treasureoptions, RP); - free (doorlist); - } - } - } - } - break; - } - default: - { - int i, j, tries; - object *chest; - object **doorlist; - - i = j = -1; - tries = 0; - while (i == -1 && tries < 100) - { - i = RANDOM () % (RP->Xsize - 2) + 1; - j = RANDOM () % (RP->Ysize - 2) + 1; - find_enclosed_spot (map, &i, &j, RP); - if (wall_blocked (map, i, j)) - i = -1; - tries++; - } - chest = place_chest (treasureoptions, i, j, map, style_map, num_treasures, RP); - if (!chest) - return; - i = chest->x; - j = chest->y; - if (treasureoptions & (DOORED | HIDDEN)) - { - doorlist = surround_by_doors (map, layout, i, j, treasureoptions); - lock_and_hide_doors (doorlist, map, treasureoptions, RP); - free (doorlist); - } - } + case LAYOUT_ONION: + case LAYOUT_SPIRAL: + case LAYOUT_SQUARE_SPIRAL: + { + int i, j; + + /* search the onion for C's or '>', and put treasure there. */ + for (i = 0; i < RP->Xsize; i++) + { + for (j = 0; j < RP->Ysize; j++) + { + if (layout[i][j] == 'C' || layout[i][j] == '>') + { + int tdiv = RP->symmetry_used; + object **doorlist; + object *chest; + + if (tdiv == 3) + tdiv = 2; /* this symmetry uses a divisor of 2 */ + /* don't put a chest on an exit. */ + chest = place_chest (treasureoptions, i, j, map, style_map, num_treasures / tdiv, RP); + if (!chest) + continue; /* if no chest was placed NEXT */ + if (treasureoptions & (DOORED | HIDDEN)) + { + doorlist = find_doors_in_room (map, i, j, RP); + lock_and_hide_doors (doorlist, map, treasureoptions, RP); + free (doorlist); + } + } + } + } + break; + } + default: + { + int i, j, tries; + object *chest; + object **doorlist; + + i = j = -1; + tries = 0; + while (i == -1 && tries < 100) + { + i = RANDOM () % (RP->Xsize - 2) + 1; + j = RANDOM () % (RP->Ysize - 2) + 1; + find_enclosed_spot (map, &i, &j, RP); + if (wall_blocked (map, i, j)) + i = -1; + tries++; + } + chest = place_chest (treasureoptions, i, j, map, style_map, num_treasures, RP); + if (!chest) + return; + i = chest->x; + j = chest->y; + if (treasureoptions & (DOORED | HIDDEN)) + { + doorlist = surround_by_doors (map, layout, i, j, treasureoptions); + lock_and_hide_doors (doorlist, map, treasureoptions, RP); + free (doorlist); + } + } } } else @@ -193,14 +194,12 @@ } } - - /* put a chest into the map, near x and y, with the treasure style determined (may be null, or may be a treasure list from lib/treasures, if the global variable "treasurestyle" is set to that treasure list's name */ object * -place_chest (int treasureoptions, int x, int y, maptile *map, maptile *style_map, int n_treasures, random_map_params * RP) +place_chest (int treasureoptions, int x, int y, maptile *map, maptile *style_map, int n_treasures, random_map_params *RP) { object *the_chest; int i, xl, yl; @@ -221,7 +220,6 @@ if (wall_blocked (map, xl, yl)) return 0; - /* put the treasures in the chest. */ /* if(style_map) { */ #if 0 /* don't use treasure style maps for now! */ @@ -243,7 +241,6 @@ the_chest->stats.hp = n_treasures; } #endif - else { /* neither style_map no treasure list given */ treasurelist *tlist = find_treasurelist ("chest"); @@ -299,7 +296,7 @@ /* finds the closest monster and returns him, regardless of doors or walls */ object * -find_closest_monster (maptile *map, int x, int y, random_map_params * RP) +find_closest_monster (maptile *map, int x, int y, random_map_params *RP) { int i; @@ -338,7 +335,7 @@ */ int -keyplace (maptile *map, int x, int y, char *keycode, int door_flag, int n_keys, random_map_params * RP) +keyplace (maptile *map, int x, int y, char *keycode, int door_flag, int n_keys, random_map_params *RP) { int i, j; int kx, ky; @@ -434,7 +431,7 @@ it does a check-off on the layout, converting 0's to 1's */ object * -find_monster_in_room_recursive (char **layout, maptile *map, int x, int y, random_map_params * RP) +find_monster_in_room_recursive (char **layout, maptile *map, int x, int y, random_map_params *RP) { int i, j; @@ -481,7 +478,7 @@ real work. */ object * -find_monster_in_room (maptile *map, int x, int y, random_map_params * RP) +find_monster_in_room (maptile *map, int x, int y, random_map_params *RP) { char **layout2; int i, j; @@ -523,7 +520,7 @@ that datastructure. */ void -find_spot_in_room_recursive (char **layout, int x, int y, random_map_params * RP) +find_spot_in_room_recursive (char **layout, int x, int y, random_map_params *RP) { int i, j; @@ -552,7 +549,7 @@ /* find a random non-blocked spot in this room to drop a key. */ void -find_spot_in_room (maptile *map, int x, int y, int *kx, int *ky, random_map_params * RP) +find_spot_in_room (maptile *map, int x, int y, int *kx, int *ky, random_map_params *RP) { char **layout2; int i, j; @@ -599,7 +596,7 @@ it'll return 0 if no FREE spots are found.*/ void -find_enclosed_spot (maptile *map, int *cx, int *cy, random_map_params * RP) +find_enclosed_spot (maptile *map, int *cx, int *cy, random_map_params *RP) { int x, y; int i; @@ -750,7 +747,7 @@ /* the workhorse routine, which finds the doors in a room */ 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 **layout, maptile *map, int x, int y, object **doorlist, int *ndoors, random_map_params *RP) { int i, j; object *door; @@ -792,7 +789,7 @@ /* find a random non-blocked spot in this room to drop a key. */ object ** -find_doors_in_room (maptile *map, int x, int y, random_map_params * RP) +find_doors_in_room (maptile *map, int x, int y, random_map_params *RP) { char **layout2; object **doorlist; @@ -832,7 +829,7 @@ opts doesn't say to lock/hide doors. */ void -lock_and_hide_doors (object **doorlist, maptile *map, int opts, random_map_params * RP) +lock_and_hide_doors (object **doorlist, maptile *map, int opts, random_map_params *RP) { object *door; int i;