--- deliantra/server/common/button.C 2007/01/09 22:14:29 1.25 +++ deliantra/server/common/button.C 2007/01/10 10:36:47 1.26 @@ -830,27 +830,40 @@ * 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. * + * Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check + * whether op is on this mapspace or not, because the value (1|0) depends + * on this information. also make sure to only push_button if op has + * a matching item (because when we do a push_button with value=0 timed gates + * will still open)! (i hope i got the semantics right this time) + * */ void check_inv (object *op, object *trig) { trig->value = 0; // deactivate if none of the following conditions apply - if (object *pl = trig->ms ().player ()) - { - object *match = check_inv_recursive (pl, trig); + object *pl = trig->ms ().player (); + object *match = check_inv_recursive (op, trig); - if (match && trig->last_sp) // match == having - { - if (trig->last_heal) - decrease_ob (match); + // elmex: a note about (pl == op): + // if pl == 0 then the player has left this space + // if pl != 0 then a player is on this mapspace, but then + // we still have to check whether it's the player that triggered + // this inv-checker, because if not, then the op left this inv-checker + // and we have to set the value to 0 - trig->value = 1; - } - else if (!match && !trig->last_sp) // match == not having - trig->value = 1; - } + if (match && trig->last_sp) // match == having + { + if (trig->last_heal) + decrease_ob (match); - push_button (trig); + trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left + push_button (trig); + } + else if (!match && !trig->last_sp) // match == not having + { + trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left + push_button (trig); + } }