--- deliantra/server/common/button.C 2006/12/19 13:41:45 1.15 +++ deliantra/server/common/button.C 2006/12/19 15:30:01 1.16 @@ -828,7 +828,8 @@ /* First check the object itself. */ if ((trig->stats.hp && (op->type == trig->stats.hp)) - || (trig->slaying && (op->slaying == trig->slaying)) || (trig->race && (op->arch->name == trig->race))) + || (trig->slaying && (op->slaying == trig->slaying)) + || (trig->race && (op->arch->name == trig->race))) return op; for (tmp = op->inv; tmp; tmp = tmp->below) @@ -840,7 +841,8 @@ return ret; } else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) - || (trig->slaying && (tmp->slaying == trig->slaying)) || (trig->race && (tmp->arch->name == trig->race))) + || (trig->slaying && (tmp->slaying == trig->slaying)) + || (trig->race && (tmp->arch->name == trig->race))) return tmp; } return NULL; @@ -853,29 +855,43 @@ * Values are: last_sp = 1/0 obj/no obj triggers * last_heal = 1/0 remove/dont remove obj if triggered * -b.t. (thomas@nomad.astro.psu.edu + * + * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op + * because the check-inventory semantic essentially only applies when + * something is above the inventory checker. + * The semantic prior this change was: trigger if something has moved on or off + * and has a matching item. Imagine what happens if someone steps on the inventory + * checker with a matching item, has it, activates the connection, throws the item + * away, and then leaves the inventory checker. That would've caused an always-enabled + * state in the inventory checker. This won't happen anymore now. + * */ void -check_inv (object *op, object *trig, bool move_on) +check_inv (object *op, object *trig) { - object *match; + object *match = 0; - if (op->type != PLAYER) - return; - match = check_inv_recursive (op, trig); - if (match && trig->last_sp) - { - if (trig->last_heal) - decrease_ob (match); + trig->value = 0; // deactivate if none of the following conditions apply - trig->value = move_on ? 1 : 0; + for (object *tmp = trig->above; tmp; tmp = tmp->above) + if (tmp->type == PLAYER) + { + object *match = check_inv_recursive (tmp, trig); - push_button (trig); - } - else if (!match && !trig->last_sp) - { - trig->value = move_on ? 1 : 0; - push_button (trig); - } + if (match && trig->last_sp) // match == having + { + if (trig->last_heal) + decrease_ob (match); + + trig->value = 1; + } + else if (!match && !trig->last_sp) // match == not having + trig->value = 1; + + break; + } + + push_button (trig); }