--- deliantra/server/random_maps/treasure.C 2007/01/15 01:50:33 1.15 +++ deliantra/server/random_maps/treasure.C 2007/01/15 15:54:19 1.17 @@ -214,6 +214,7 @@ the_chest->destroy (); return NULL; } + xl = x + freearr_x[i]; yl = y + freearr_y[i]; @@ -369,7 +370,7 @@ { 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) @@ -658,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; + } }