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.12 by root, Sun Oct 15 02:16:34 2006 UTC vs.
Revision 1.16 by elmex, Tue Dec 19 15:30:01 2006 UTC

771 tmp->attack_movement = 0; 771 tmp->attack_movement = 0;
772 /* lots of checks here, but want to make sure we don't 772 /* lots of checks here, but want to make sure we don't
773 * dereference a null value 773 * dereference a null value
774 */ 774 */
775 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) 775 if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp)
776 {
777 tmp->owner->contr->ranges[range_golem] = NULL; 776 tmp->owner->contr->ranges[range_golem] = 0;
778 tmp->owner->contr->golem_count = 0; 777
779 }
780 tmp->owner = 0; 778 tmp->owner = 0;
781 } 779 }
782 break; 780 break;
783 case 1: /* angry -- get neutral monsters mad */ 781 case 1: /* angry -- get neutral monsters mad */
784 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY)) 782 if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY))
801 if (tmp2->above == NULL) 799 if (tmp2->above == NULL)
802 break; 800 break;
803 801
804 if (tmp2->type != PLAYER) 802 if (tmp2->type != PLAYER)
805 break; 803 break;
806 set_owner (tmp, tmp2); 804 tmp->set_owner (tmp2);
807 SET_FLAG (tmp, FLAG_MONSTER); 805 SET_FLAG (tmp, FLAG_MONSTER);
808 tmp->stats.exp = 0; 806 tmp->stats.exp = 0;
809 SET_FLAG (tmp, FLAG_FRIENDLY); 807 SET_FLAG (tmp, FLAG_FRIENDLY);
810 add_friendly_object (tmp); 808 add_friendly_object (tmp);
811 tmp->attack_movement = PETMOVE; 809 tmp->attack_movement = PETMOVE;
828{ 826{
829 object *tmp, *ret = NULL; 827 object *tmp, *ret = NULL;
830 828
831 /* First check the object itself. */ 829 /* First check the object itself. */
832 if ((trig->stats.hp && (op->type == trig->stats.hp)) 830 if ((trig->stats.hp && (op->type == trig->stats.hp))
833 || (trig->slaying && (op->slaying == trig->slaying)) || (trig->race && (op->arch->name == trig->race))) 831 || (trig->slaying && (op->slaying == trig->slaying))
832 || (trig->race && (op->arch->name == trig->race)))
834 return op; 833 return op;
835 834
836 for (tmp = op->inv; tmp; tmp = tmp->below) 835 for (tmp = op->inv; tmp; tmp = tmp->below)
837 { 836 {
838 if (tmp->inv) 837 if (tmp->inv)
840 ret = check_inv_recursive (tmp, trig); 839 ret = check_inv_recursive (tmp, trig);
841 if (ret) 840 if (ret)
842 return ret; 841 return ret;
843 } 842 }
844 else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) 843 else if ((trig->stats.hp && (tmp->type == trig->stats.hp))
845 || (trig->slaying && (tmp->slaying == trig->slaying)) || (trig->race && (tmp->arch->name == trig->race))) 844 || (trig->slaying && (tmp->slaying == trig->slaying))
845 || (trig->race && (tmp->arch->name == trig->race)))
846 return tmp; 846 return tmp;
847 } 847 }
848 return NULL; 848 return NULL;
849} 849}
850 850
853 * the square will activate connected items. 853 * the square will activate connected items.
854 * Monsters can't trigger this square (for now) 854 * Monsters can't trigger this square (for now)
855 * Values are: last_sp = 1/0 obj/no obj triggers 855 * Values are: last_sp = 1/0 obj/no obj triggers
856 * last_heal = 1/0 remove/dont remove obj if triggered 856 * last_heal = 1/0 remove/dont remove obj if triggered
857 * -b.t. (thomas@nomad.astro.psu.edu 857 * -b.t. (thomas@nomad.astro.psu.edu
858 *
859 * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op
860 * because the check-inventory semantic essentially only applies when
861 * something is above the inventory checker.
862 * The semantic prior this change was: trigger if something has moved on or off
863 * and has a matching item. Imagine what happens if someone steps on the inventory
864 * checker with a matching item, has it, activates the connection, throws the item
865 * away, and then leaves the inventory checker. That would've caused an always-enabled
866 * state in the inventory checker. This won't happen anymore now.
867 *
858 */ 868 */
859 869
860void 870void
861check_inv (object *op, object *trig) 871check_inv (object *op, object *trig)
862{ 872{
863 object *match; 873 object *match = 0;
864 874
875 trig->value = 0; // deactivate if none of the following conditions apply
876
877 for (object *tmp = trig->above; tmp; tmp = tmp->above)
865 if (op->type != PLAYER) 878 if (tmp->type == PLAYER)
866 return;
867 match = check_inv_recursive (op, trig);
868 if (match && trig->last_sp)
869 { 879 {
880 object *match = check_inv_recursive (tmp, trig);
881
882 if (match && trig->last_sp) // match == having
883 {
870 if (trig->last_heal) 884 if (trig->last_heal)
871 decrease_ob (match); 885 decrease_ob (match);
872 use_trigger (trig); 886
887 trig->value = 1;
888 }
889 else if (!match && !trig->last_sp) // match == not having
890 trig->value = 1;
891
892 break;
873 } 893 }
874 else if (!match && !trig->last_sp)
875 use_trigger (trig);
876}
877 894
895 push_button (trig);
896}
897

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines