ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/treasure.C
(Generate patch)

Comparing deliantra/server/random_maps/treasure.C (file contents):
Revision 1.14 by pippijn, Sat Jan 6 14:42:30 2007 UTC vs.
Revision 1.17 by root, Mon Jan 15 15:54:19 2007 UTC

212 if (i == -1) 212 if (i == -1)
213 { 213 {
214 the_chest->destroy (); 214 the_chest->destroy ();
215 return NULL; 215 return NULL;
216 } 216 }
217
217 xl = x + freearr_x[i]; 218 xl = x + freearr_x[i];
218 yl = y + freearr_y[i]; 219 yl = y + freearr_y[i];
219 220
220 /* if the placement is blocked, return a fail. */ 221 /* if the placement is blocked, return a fail. */
221 if (wall_blocked (map, xl, yl)) 222 if (wall_blocked (map, xl, yl))
367 freeindex = -1; 368 freeindex = -1;
368 for (tries = 0; tries < 15 && freeindex == -1; tries++) 369 for (tries = 0; tries < 15 && freeindex == -1; tries++)
369 { 370 {
370 kx = (RANDOM () % (RP->Xsize - 2)) + 1; 371 kx = (RANDOM () % (RP->Xsize - 2)) + 1;
371 ky = (RANDOM () % (RP->Ysize - 2)) + 1; 372 ky = (RANDOM () % (RP->Ysize - 2)) + 1;
372 freeindex = find_first_free_spot (the_key, map, kx, ky); 373 freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1);
373 } 374 }
375
374 if (freeindex != -1) 376 if (freeindex != -1)
375 { 377 {
376 kx += freearr_x[freeindex]; 378 kx += freearr_x[freeindex];
377 ky += freearr_y[freeindex]; 379 ky += freearr_y[freeindex];
378 } 380 }
384 NO_PASS_DOORS is set. */ 386 NO_PASS_DOORS is set. */
385 if (n_keys == 1) 387 if (n_keys == 1)
386 { 388 {
387 if (wall_blocked (map, x, y)) 389 if (wall_blocked (map, x, y))
388 return 0; 390 return 0;
391
389 the_keymaster = find_monster_in_room (map, x, y, RP); 392 the_keymaster = find_monster_in_room (map, x, y, RP);
390 if (the_keymaster == NULL) /* if fail, find a spot to drop the key. */ 393 if (the_keymaster == NULL) /* if fail, find a spot to drop the key. */
391 find_spot_in_room (map, x, y, &kx, &ky, RP); 394 find_spot_in_room (map, x, y, &kx, &ky, RP);
392 } 395 }
393 else 396 else
654 *cy = ly; 657 *cy = ly;
655 return; 658 return;
656 } 659 }
657 } 660 }
658 /* give up and return the closest free spot. */ 661 /* give up and return the closest free spot. */
659 i = find_first_free_spot (&archetype::find ("chest")->clone, map, x, y); 662 i = find_free_spot (&archetype::find ("chest")->clone, map, x, y, 1, SIZEOFFREE1 + 1);
660 if (i != -1 && i <= SIZEOFFREE1) 663
664 if (i != -1)
661 { 665 {
662 *cx = x + freearr_x[i]; 666 *cx = x + freearr_x[i];
663 *cy = y + freearr_y[i]; 667 *cy = y + freearr_y[i];
664 return; 668 }
669 else
665 } 670 {
666 /* indicate failure */ 671 /* indicate failure */
672 *cx = -1;
667 *cx = *cy = -1; 673 *cy = -1;
674 }
668} 675}
669 676
670 677
671void 678void
672remove_monsters (int x, int y, maptile *map) 679remove_monsters (int x, int y, maptile *map)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines