ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/button.c
(Generate patch)

Comparing deliantra/server/common/button.c (file contents):
Revision 1.1 by root, Fri Feb 3 07:11:30 2006 UTC vs.
Revision 1.2 by elmex, Sun Jul 9 11:11:13 2006 UTC

1/* 1/*
2 * static char *rcsid_button_c = 2 * static char *rcsid_button_c =
3 * "$Id: button.c,v 1.1 2006/02/03 07:11:30 root Exp $"; 3 * "$Id: button.c,v 1.2 2006/07/09 11:11:13 elmex Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
277 * 0.93.4: Linked objects (ie, objects that are connected) can not be 277 * 0.93.4: Linked objects (ie, objects that are connected) can not be
278 * sacrificed. This fixes a bug of trying to put multiple altars/related 278 * sacrificed. This fixes a bug of trying to put multiple altars/related
279 * objects on the same space that take the same sacrifice. 279 * objects on the same space that take the same sacrifice.
280 */ 280 */
281 281
282int check_altar_sacrifice (object *altar, object *sacrifice) 282int check_altar_sacrifice (const object *altar, const object *sacrifice)
283{ 283{
284 if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE) 284 if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE)
285 && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED) 285 && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED)
286 && sacrifice->type != PLAYER) 286 && sacrifice->type != PLAYER)
287 { 287 {
399 if (tot >= op->weight) 399 if (tot >= op->weight)
400 push = 1; 400 push = 1;
401 if (op->stats.ac == push) 401 if (op->stats.ac == push)
402 return 0; 402 return 0;
403 op->stats.ac = push; 403 op->stats.ac = push;
404 SET_ANIMATION (op, push); 404 if (NUM_ANIMATIONS(op) > 1) {
405 SET_ANIMATION (op, push);
405 update_object (op, UP_OBJ_FACE); 406 update_object (op, UP_OBJ_FACE);
407 }
406 if (in_movement || ! push) 408 if (in_movement || ! push)
407 return 0; 409 return 0;
408 } 410 }
409 trigger_move (op, push); 411 trigger_move (op, push);
410 } 412 }
424 } 426 }
425 } 427 }
426 if (op->stats.ac == push) 428 if (op->stats.ac == push)
427 return 0; 429 return 0;
428 op->stats.ac = push; 430 op->stats.ac = push;
429 SET_ANIMATION (op, push); 431 if (NUM_ANIMATIONS(op) > 1) {
432 SET_ANIMATION (op, push);
433 update_object (op, UP_OBJ_FACE);
434 }
430 update_object(op,UP_OBJ_FACE); 435 update_object(op,UP_OBJ_FACE);
431 if (in_movement || ! push) 436 if (in_movement || ! push)
432 return 0; 437 return 0;
433 } 438 }
434 trigger_move (op, push); 439 trigger_move (op, push);
437 case TRIGGER_ALTAR: 442 case TRIGGER_ALTAR:
438 if (cause) { 443 if (cause) {
439 if (in_movement) 444 if (in_movement)
440 return 0; 445 return 0;
441 if (operate_altar (op, &cause)) { 446 if (operate_altar (op, &cause)) {
442 SET_ANIMATION (op, 1); 447 if (NUM_ANIMATIONS(op) > 1) {
443 update_object(op,UP_OBJ_FACE); 448 SET_ANIMATION (op, 1);
444 449 update_object(op, UP_OBJ_FACE);
450 }
445 if (op->last_sp >= 0) { 451 if (op->last_sp >= 0) {
446 trigger_move (op, 1); 452 trigger_move (op, 1);
447 if (op->last_sp > 0) 453 if (op->last_sp > 0)
448 op->last_sp = -op->last_sp; 454 op->last_sp = -op->last_sp;
449 } 455 }
459 return cause == NULL; 465 return cause == NULL;
460 } else { 466 } else {
461 return 0; 467 return 0;
462 } 468 }
463 } else { 469 } else {
464 SET_ANIMATION (op, 0); 470 if (NUM_ANIMATIONS(op) > 1) {
465 update_object(op,UP_OBJ_FACE); 471 SET_ANIMATION (op, 0);
472 update_object(op, UP_OBJ_FACE);
473 }
466 474
467 /* If trigger_altar has "last_sp > 0" set on the map, 475 /* If trigger_altar has "last_sp > 0" set on the map,
468 * it will push the connected value only once per sacrifice. 476 * it will push the connected value only once per sacrifice.
469 * Otherwise (default), the connected value will be 477 * Otherwise (default), the connected value will be
470 * pushed twice: First by sacrifice, second by reset! -AV 478 * pushed twice: First by sacrifice, second by reset! -AV
484 if (cause) { 492 if (cause) {
485 if (in_movement) 493 if (in_movement)
486 return 0; 494 return 0;
487 push = 1; 495 push = 1;
488 } 496 }
497 if (NUM_ANIMATIONS(op) > 1) {
489 SET_ANIMATION (op, push); 498 SET_ANIMATION (op, push);
490 update_object(op,UP_OBJ_FACE); 499 update_object(op, UP_OBJ_FACE);
500 }
491 trigger_move (op, push); 501 trigger_move (op, push);
492 return 1; 502 return 1;
493 503
494 default: 504 default:
495 LOG(llevDebug, "Unknown trigger type: %s (%d)\n", op->name, op->type); 505 LOG(llevDebug, "Unknown trigger type: %s (%d)\n", op->name, op->type);
562 572
563/* 573/*
564 * Return the first objectlink in the objects linked to this one 574 * Return the first objectlink in the objects linked to this one
565 */ 575 */
566 576
567objectlink *get_button_links(object *button) { 577objectlink *get_button_links(const object *button) {
568 oblinkpt *obp; 578 oblinkpt *obp;
569 objectlink *ol; 579 objectlink *ol;
570 580
571 if (!button->map) 581 if (!button->map)
572 return NULL; 582 return NULL;
579 589
580/* 590/*
581 * Made as a separate function to increase efficiency 591 * Made as a separate function to increase efficiency
582 */ 592 */
583 593
584int get_button_value(object *button) { 594int get_button_value(const object *button) {
585 oblinkpt *obp; 595 oblinkpt *obp;
586 objectlink *ol; 596 objectlink *ol;
587 597
588 if (!button->map) 598 if (!button->map)
589 return 0; 599 return 0;
676 * slaying = match object slaying flag 686 * slaying = match object slaying flag
677 * race = match object archetype name flag 687 * race = match object archetype name flag
678 * hp = match object type (excpt type '0'== PLAYER) 688 * hp = match object type (excpt type '0'== PLAYER)
679 */ 689 */
680 690
681object * check_inv_recursive(object *op, object *trig) 691object * check_inv_recursive(object *op, const object *trig)
682{ 692{
683 object *tmp,*ret=NULL; 693 object *tmp,*ret=NULL;
684 694
685 /* First check the object itself. */ 695 /* First check the object itself. */
686 if((trig->stats.hp && (op->type == trig->stats.hp)) 696 if((trig->stats.hp && (op->type == trig->stats.hp))
727 737
728/* This does a minimal check of the button link consistency for object 738/* This does a minimal check of the button link consistency for object
729 * map. All it really does it much sure the object id link that is set 739 * map. All it really does it much sure the object id link that is set
730 * matches what the object has. 740 * matches what the object has.
731 */ 741 */
732void verify_button_links(mapstruct *map) { 742void verify_button_links(const mapstruct *map) {
733 oblinkpt *obp; 743 oblinkpt *obp;
734 objectlink *ol; 744 objectlink *ol;
735 745
736 if (!map) return; 746 if (!map) return;
737 747

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines