1 | |
1 | |
2 | /* |
2 | /* |
3 | CrossFire, A Multiplayer game for X-windows |
3 | CrossFire, A Multiplayer game for X-windows |
4 | |
4 | |
|
|
5 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
7 | Copyright (C) 1992 Frank Tore Johansen |
7 | |
8 | |
8 | This program is free software; you can redistribute it and/or modify |
9 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | it under the terms of the GNU General Public License as published by |
… | |
… | |
366 | freeindex = -1; |
367 | freeindex = -1; |
367 | for (tries = 0; tries < 15 && freeindex == -1; tries++) |
368 | for (tries = 0; tries < 15 && freeindex == -1; tries++) |
368 | { |
369 | { |
369 | kx = (RANDOM () % (RP->Xsize - 2)) + 1; |
370 | kx = (RANDOM () % (RP->Xsize - 2)) + 1; |
370 | ky = (RANDOM () % (RP->Ysize - 2)) + 1; |
371 | ky = (RANDOM () % (RP->Ysize - 2)) + 1; |
371 | freeindex = find_first_free_spot (the_key, map, kx, ky); |
372 | freeindex = find_free_spot (the_key, map, kx, ky, 1, SIZEOFFREE1 + 1); |
372 | } |
373 | } |
|
|
374 | |
373 | if (freeindex != -1) |
375 | if (freeindex != -1) |
374 | { |
376 | { |
375 | kx += freearr_x[freeindex]; |
377 | kx += freearr_x[freeindex]; |
376 | ky += freearr_y[freeindex]; |
378 | ky += freearr_y[freeindex]; |
377 | } |
379 | } |
… | |
… | |
383 | NO_PASS_DOORS is set. */ |
385 | NO_PASS_DOORS is set. */ |
384 | if (n_keys == 1) |
386 | if (n_keys == 1) |
385 | { |
387 | { |
386 | if (wall_blocked (map, x, y)) |
388 | if (wall_blocked (map, x, y)) |
387 | return 0; |
389 | return 0; |
|
|
390 | |
388 | the_keymaster = find_monster_in_room (map, x, y, RP); |
391 | the_keymaster = find_monster_in_room (map, x, y, RP); |
389 | 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. */ |
390 | find_spot_in_room (map, x, y, &kx, &ky, RP); |
393 | find_spot_in_room (map, x, y, &kx, &ky, RP); |
391 | } |
394 | } |
392 | else |
395 | else |