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.15 by elmex, Tue Dec 19 13:41:45 2006 UTC vs.
Revision 1.16 by elmex, Tue Dec 19 15:30:01 2006 UTC

826{ 826{
827 object *tmp, *ret = NULL; 827 object *tmp, *ret = NULL;
828 828
829 /* First check the object itself. */ 829 /* First check the object itself. */
830 if ((trig->stats.hp && (op->type == trig->stats.hp)) 830 if ((trig->stats.hp && (op->type == trig->stats.hp))
831 || (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)))
832 return op; 833 return op;
833 834
834 for (tmp = op->inv; tmp; tmp = tmp->below) 835 for (tmp = op->inv; tmp; tmp = tmp->below)
835 { 836 {
836 if (tmp->inv) 837 if (tmp->inv)
838 ret = check_inv_recursive (tmp, trig); 839 ret = check_inv_recursive (tmp, trig);
839 if (ret) 840 if (ret)
840 return ret; 841 return ret;
841 } 842 }
842 else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) 843 else if ((trig->stats.hp && (tmp->type == trig->stats.hp))
843 || (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)))
844 return tmp; 846 return tmp;
845 } 847 }
846 return NULL; 848 return NULL;
847} 849}
848 850
851 * the square will activate connected items. 853 * the square will activate connected items.
852 * Monsters can't trigger this square (for now) 854 * Monsters can't trigger this square (for now)
853 * Values are: last_sp = 1/0 obj/no obj triggers 855 * Values are: last_sp = 1/0 obj/no obj triggers
854 * last_heal = 1/0 remove/dont remove obj if triggered 856 * last_heal = 1/0 remove/dont remove obj if triggered
855 * -b.t. (thomas@nomad.astro.psu.edu 857 * -b.t. (thomas@nomad.astro.psu.edu
856 */ 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 *
868 */
857 869
858void 870void
859check_inv (object *op, object *trig, bool move_on) 871check_inv (object *op, object *trig)
860{ 872{
861 object *match; 873 object *match = 0;
862 874
875 trig->value = 0; // deactivate if none of the following conditions apply
876
877 for (object *tmp = trig->above; tmp; tmp = tmp->above)
863 if (op->type != PLAYER) 878 if (tmp->type == PLAYER)
864 return;
865 match = check_inv_recursive (op, trig);
866 if (match && trig->last_sp)
867 { 879 {
880 object *match = check_inv_recursive (tmp, trig);
881
882 if (match && trig->last_sp) // match == having
883 {
868 if (trig->last_heal) 884 if (trig->last_heal)
869 decrease_ob (match); 885 decrease_ob (match);
870 886
871 trig->value = move_on ? 1 : 0; 887 trig->value = 1;
888 }
889 else if (!match && !trig->last_sp) // match == not having
890 trig->value = 1;
872 891
892 break;
893 }
894
873 push_button (trig); 895 push_button (trig);
874 }
875 else if (!match && !trig->last_sp)
876 {
877 trig->value = move_on ? 1 : 0;
878 push_button (trig);
879 }
880} 896}
881 897

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines