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.18 by pippijn, Mon Jan 15 21:06:19 2007 UTC

1
2/* 1/*
3 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
4 3 *
5 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
6 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
7 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
8 7 *
9 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 11 * (at your option) any later version.
13 12 *
14 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 16 * GNU General Public License for more details.
18 17 *
19 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 21 *
23 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
24*/ 23 */
25 24
26/* placing treasure in maps, where appropriate. */ 25/* placing treasure in maps, where appropriate. */
27 26
28 27
29 28
212 if (i == -1) 211 if (i == -1)
213 { 212 {
214 the_chest->destroy (); 213 the_chest->destroy ();
215 return NULL; 214 return NULL;
216 } 215 }
216
217 xl = x + freearr_x[i]; 217 xl = x + freearr_x[i];
218 yl = y + freearr_y[i]; 218 yl = y + freearr_y[i];
219 219
220 /* if the placement is blocked, return a fail. */ 220 /* if the placement is blocked, return a fail. */
221 if (wall_blocked (map, xl, yl)) 221 if (wall_blocked (map, xl, yl))
367 freeindex = -1; 367 freeindex = -1;
368 for (tries = 0; tries < 15 && freeindex == -1; tries++) 368 for (tries = 0; tries < 15 && freeindex == -1; tries++)
369 { 369 {
370 kx = (RANDOM () % (RP->Xsize - 2)) + 1; 370 kx = (RANDOM () % (RP->Xsize - 2)) + 1;
371 ky = (RANDOM () % (RP->Ysize - 2)) + 1; 371 ky = (RANDOM () % (RP->Ysize - 2)) + 1;
372 freeindex = find_first_free_spot (the_key, map, kx, ky); 372 freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1);
373 } 373 }
374
374 if (freeindex != -1) 375 if (freeindex != -1)
375 { 376 {
376 kx += freearr_x[freeindex]; 377 kx += freearr_x[freeindex];
377 ky += freearr_y[freeindex]; 378 ky += freearr_y[freeindex];
378 } 379 }
384 NO_PASS_DOORS is set. */ 385 NO_PASS_DOORS is set. */
385 if (n_keys == 1) 386 if (n_keys == 1)
386 { 387 {
387 if (wall_blocked (map, x, y)) 388 if (wall_blocked (map, x, y))
388 return 0; 389 return 0;
390
389 the_keymaster = find_monster_in_room (map, x, y, RP); 391 the_keymaster = find_monster_in_room (map, x, y, RP);
390 if (the_keymaster == NULL) /* if fail, find a spot to drop the key. */ 392 if (the_keymaster == NULL) /* if fail, find a spot to drop the key. */
391 find_spot_in_room (map, x, y, &kx, &ky, RP); 393 find_spot_in_room (map, x, y, &kx, &ky, RP);
392 } 394 }
393 else 395 else
654 *cy = ly; 656 *cy = ly;
655 return; 657 return;
656 } 658 }
657 } 659 }
658 /* give up and return the closest free spot. */ 660 /* give up and return the closest free spot. */
659 i = find_first_free_spot (&archetype::find ("chest")->clone, map, x, y); 661 i = find_free_spot (&archetype::find ("chest")->clone, map, x, y, 1, SIZEOFFREE1 + 1);
660 if (i != -1 && i <= SIZEOFFREE1) 662
663 if (i != -1)
661 { 664 {
662 *cx = x + freearr_x[i]; 665 *cx = x + freearr_x[i];
663 *cy = y + freearr_y[i]; 666 *cy = y + freearr_y[i];
664 return; 667 }
668 else
665 } 669 {
666 /* indicate failure */ 670 /* indicate failure */
671 *cx = -1;
667 *cx = *cy = -1; 672 *cy = -1;
673 }
668} 674}
669 675
670 676
671void 677void
672remove_monsters (int x, int y, maptile *map) 678remove_monsters (int x, int y, maptile *map)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines