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)) |
… | |
… | |
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 | |
673 | void |
677 | void |
674 | remove_monsters (int x, int y, maptile *map) |
678 | remove_monsters (int x, int y, maptile *map) |