--- deliantra/server/random_maps/treasure.C 2006/12/31 20:46:17 1.13 +++ deliantra/server/random_maps/treasure.C 2007/01/15 15:54:19 1.17 @@ -2,6 +2,7 @@ /* CrossFire, A Multiplayer game for X-windows + Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team Copyright (C) 2001 Mark Wedel & Crossfire Development Team Copyright (C) 1992 Frank Tore Johansen @@ -213,6 +214,7 @@ the_chest->destroy (); return NULL; } + xl = x + freearr_x[i]; yl = y + freearr_y[i]; @@ -368,8 +370,9 @@ { kx = (RANDOM () % (RP->Xsize - 2)) + 1; ky = (RANDOM () % (RP->Ysize - 2)) + 1; - freeindex = find_first_free_spot (the_key, map, kx, ky); + freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1); } + if (freeindex != -1) { kx += freearr_x[freeindex]; @@ -385,6 +388,7 @@ { if (wall_blocked (map, x, y)) return 0; + the_keymaster = find_monster_in_room (map, x, y, RP); if (the_keymaster == NULL) /* if fail, find a spot to drop the key. */ find_spot_in_room (map, x, y, &kx, &ky, RP); @@ -655,15 +659,19 @@ } } /* give up and return the closest free spot. */ - i = find_first_free_spot (&archetype::find ("chest")->clone, map, x, y); - if (i != -1 && i <= SIZEOFFREE1) + i = find_free_spot (&archetype::find ("chest")->clone, map, x, y, 1, SIZEOFFREE1 + 1); + + if (i != -1) { *cx = x + freearr_x[i]; *cy = y + freearr_y[i]; - return; } - /* indicate failure */ - *cx = *cy = -1; + else + { + /* indicate failure */ + *cx = -1; + *cy = -1; + } }