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.15 by root, Mon Jan 15 01:50:33 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
375 if (freeindex != -1) 375 if (freeindex != -1)
376 { 376 {
377 kx += freearr_x[freeindex]; 377 kx += freearr_x[freeindex];
656 *cy = ly; 656 *cy = ly;
657 return; 657 return;
658 } 658 }
659 } 659 }
660 /* give up and return the closest free spot. */ 660 /* give up and return the closest free spot. */
661 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);
662 if (i != -1 && i <= SIZEOFFREE1) 662
663 if (i != -1)
663 { 664 {
664 *cx = x + freearr_x[i]; 665 *cx = x + freearr_x[i];
665 *cy = y + freearr_y[i]; 666 *cy = y + freearr_y[i];
666 return; 667 }
668 else
667 } 669 {
668 /* indicate failure */ 670 /* indicate failure */
671 *cx = -1;
669 *cx = *cy = -1; 672 *cy = -1;
673 }
670} 674}
671 675
672 676
673void 677void
674remove_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