1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * 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 |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * 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 |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | /* Specials in this file: |
24 | /* Specials in this file: |
26 | included maps */ |
25 | included maps */ |
27 | |
26 | |
… | |
… | |
168 | } |
167 | } |
169 | |
168 | |
170 | object *fountain = get_archetype ("fountain"); |
169 | object *fountain = get_archetype ("fountain"); |
171 | object *potion = object::create (); |
170 | object *potion = object::create (); |
172 | |
171 | |
173 | pick_random_object (fountain_style)->copy_to (potion); |
172 | fountain_style->pick_random_object ()->copy_to (potion); |
174 | |
173 | |
175 | while (i < 0 && tries < 10) |
174 | while (i < 0 && tries < 10) |
176 | { |
175 | { |
177 | ix = rndm (map->width - 2) + 1; |
176 | ix = rndm (map->width - 2) + 1; |
178 | iy = rndm (map->height - 2) + 1; |
177 | iy = rndm (map->height - 2) + 1; |
… | |
… | |
204 | |
203 | |
205 | void |
204 | void |
206 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
205 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
207 | { |
206 | { |
208 | int ix, iy, i = -1; |
207 | int ix, iy, i = -1; |
|
|
208 | char buf[16384]; |
209 | char buf[16384], *style, *decor, *mon; |
209 | const char *style, *decor, *mon; |
210 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
210 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
211 | int g_xsize, g_ysize; |
211 | int g_xsize, g_ysize; |
212 | |
212 | |
213 | if (!exit_style) |
213 | if (!exit_style) |
214 | { |
214 | { |
… | |
… | |
219 | object *the_exit = object::create (); |
219 | object *the_exit = object::create (); |
220 | |
220 | |
221 | if (!exit_style) |
221 | if (!exit_style) |
222 | return; |
222 | return; |
223 | |
223 | |
224 | pick_random_object (exit_style)->copy_to (the_exit); |
224 | exit_style->pick_random_object ()->copy_to (the_exit); |
225 | |
225 | |
226 | while (i < 0) |
226 | // put an upper bound here, just in case |
|
|
227 | for (int repeat = 8192; --repeat; ) |
227 | { |
228 | { |
228 | ix = rndm (map->width - 2) + 1; |
229 | ix = rndm (map->width - 2) + 1; |
229 | iy = rndm (map->height - 2) + 1; |
230 | iy = rndm (map->height - 2) + 1; |
|
|
231 | |
230 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
232 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
231 | } |
233 | if (i >= 0) |
232 | |
234 | { |
233 | ix += freearr_x[i]; |
235 | ix += freearr_x[i]; |
234 | iy += freearr_y[i]; |
236 | iy += freearr_y[i]; |
|
|
237 | break; |
|
|
238 | } |
|
|
239 | } |
|
|
240 | |
235 | the_exit->x = ix; |
241 | the_exit->x = ix; |
236 | the_exit->y = iy; |
242 | the_exit->y = iy; |
237 | |
243 | |
238 | if (!hole_type) |
244 | if (!hole_type) |
239 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |
245 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |