--- deliantra/server/common/button.C 2008/04/09 14:36:47 1.41 +++ deliantra/server/common/button.C 2008/04/20 22:03:21 1.42 @@ -237,33 +237,30 @@ tmp = ol->ob; if (tmp->type == BUTTON) { - for (ab = tmp->above, tot = 0; ab != NULL; ab = ab->above) - /* Bug? The pedestal code below looks for the head of - * the object, this bit doesn't. I'd think we should check - * for head here also. Maybe it also makese sense to - * make the for ab=tmp->above loop common, and alter - * behaviour based on object within that loop? - */ - - /* Basically, if the move_type matches that on what the - * button wants, we count it. The second check is so that - * objects don't move (swords, etc) will count. Note that - * this means that more work is needed to make buttons - * that are only triggered by flying objects. - */ - if ((ab->move_type & tmp->move_on) || ab->move_type == 0) - tot += ab->weight * (ab->nrof ? ab->nrof : 1) + ab->carrying; - - tmp->value = (tot >= tmp->weight) ? 1 : 0; - if (tmp->value) - any_down = 1; + for (ab = tmp->above, tot = 0; ab; ab = ab->above) + { + head = ab->head_ (); + + /* Basically, if the move_type matches that on what the + * button wants, we count it. The second check is so that + * objects who don't move (swords, etc) will count. Note that + * this means that more work is needed to make buttons + * that are only triggered by flying objects. + */ + if ((head->move_type & tmp->move_on) || head->move_type == 0) + tot += head->total_weight (); + } + + tmp->value = tot >= tmp->weight ? 1 : 0; } else if (tmp->type == PEDESTAL) { tmp->value = 0; - for (ab = tmp->above; ab != NULL; ab = ab->above) + + for (ab = tmp->above; ab; ab = ab->above) { head = ab->head_ (); + /* Same note regarding move_type for buttons above apply here. */ if (((head->move_type & tmp->move_on) || ab->move_type == 0) && (head->race == tmp->slaying || @@ -271,11 +268,11 @@ (!strcmp (tmp->slaying, "player") && head->type == PLAYER))) tmp->value = 1; } - - if (tmp->value) - any_down = 1; } + + any_down = any_down || tmp->value; } + if (any_down) /* If any other buttons were down, force this to remain down */ op->value = 1; @@ -339,7 +336,7 @@ || ARCH_SACRIFICE (altar) == sacrifice->name || ARCH_SACRIFICE (altar) == sacrifice->slaying || strstr (query_base_name (sacrifice, 0), ARCH_SACRIFICE (altar))) - && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) + && NROF_SACRIFICE (altar) <= sacrifice->number_of ()) return 1; } @@ -444,26 +441,28 @@ * this means that more work is needed to make buttons * that are only triggered by flying objects. */ - if ((tmp->move_type & op->move_on) || tmp->move_type == 0) - { - tot += tmp->weight * (tmp->nrof ? tmp->nrof : 1) + tmp->carrying; - } + tot += tmp->head_ ()->total_weight (); + if (tot >= op->weight) push = 1; + if (op->stats.ac == push) return 0; + op->stats.ac = push; if (NUM_ANIMATIONS (op) > 1) { SET_ANIMATION (op, push); update_object (op, UP_OBJ_FACE); } + if (in_movement || !push) return 0; } trigger_move (op, push); } + return 0; case TRIGGER_PEDESTAL: