1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_button_c = |
|
|
4 | * "$Id: button.C,v 1.8 2006/09/11 20:28:37 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #include <funcpoint.h> |
25 | #include <funcpoint.h> |
32 | |
26 | |
… | |
… | |
364 | return 1; |
358 | return 1; |
365 | } |
359 | } |
366 | return 0; |
360 | return 0; |
367 | } |
361 | } |
368 | |
362 | |
369 | |
|
|
370 | /* |
363 | /* |
371 | * operate_altar checks if sacrifice was accepted and removes sacrificed |
364 | * operate_altar checks if sacrifice was accepted and removes sacrificed |
372 | * objects. If sacrifice was succeed return 1 else 0. Might be better to |
365 | * objects. If sacrifice was succeed return 1 else 0. Might be better to |
373 | * call check_altar_sacrifice (above) than depend on the return value, |
366 | * call check_altar_sacrifice (above) than depend on the return value, |
374 | * since operate_altar will remove the sacrifice also. |
367 | * since operate_altar will remove the sacrifice also. |
375 | * |
368 | * |
376 | * If this function returns 1, '*sacrifice' is modified to point to the |
369 | * If this function returns 1, '*sacrifice' is modified to point to the |
377 | * remaining sacrifice, or is set to NULL if the sacrifice was used up. |
370 | * remaining sacrifice, or is set to NULL if the sacrifice was used up. |
378 | */ |
371 | */ |
379 | |
|
|
380 | int |
372 | int |
381 | operate_altar (object *altar, object **sacrifice) |
373 | operate_altar (object *altar, object **sacrifice) |
382 | { |
374 | { |
383 | |
|
|
384 | if (!altar->map) |
375 | if (!altar->map) |
385 | { |
376 | { |
386 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
377 | LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
387 | return 0; |
378 | return 0; |
388 | } |
379 | } |
… | |
… | |
401 | int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; |
392 | int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; |
402 | |
393 | |
403 | /* Round up any sacrifices. Altars don't make change either */ |
394 | /* Round up any sacrifices. Altars don't make change either */ |
404 | if (NROF_SACRIFICE (altar) % (*sacrifice)->value) |
395 | if (NROF_SACRIFICE (altar) % (*sacrifice)->value) |
405 | number++; |
396 | number++; |
|
|
397 | |
406 | *sacrifice = decrease_ob_nr (*sacrifice, number); |
398 | *sacrifice = decrease_ob_nr (*sacrifice, number); |
407 | } |
399 | } |
408 | else |
400 | else |
409 | *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar)); |
401 | *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar)); |
410 | |
402 | |
411 | if (altar->msg) |
403 | if (altar->msg) |
412 | new_info_map (NDI_BLACK, altar->map, altar->msg); |
404 | new_info_map (NDI_BLACK, altar->map, altar->msg); |
|
|
405 | |
413 | return 1; |
406 | return 1; |
414 | } |
407 | } |
415 | |
408 | |
416 | void |
409 | void |
417 | trigger_move (object *op, int state) /* 1 down and 0 up */ |
410 | trigger_move (object *op, int state) /* 1 down and 0 up */ |