--- deliantra/server/common/button.C 2006/12/25 11:25:49 1.19 +++ deliantra/server/common/button.C 2007/01/09 16:38:23 1.24 @@ -1,6 +1,7 @@ /* CrossFire, A Multiplayer game for X-windows + Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team Copyright (C) 2002 Mark Wedel & Crossfire Development Team Copyright (C) 1992 Frank Tore Johansen @@ -69,8 +70,7 @@ case GATE: case HOLE: tmp->value = tmp->stats.maxsp ? !state : state; - tmp->speed = 0.5; - update_ob_speed (tmp); + tmp->set_speed (0.5); break; case CF_HANDLE: @@ -105,21 +105,19 @@ break; case TIMED_GATE: - tmp->speed = tmp->arch->clone.speed; - update_ob_speed (tmp); /* original values */ + tmp->set_speed (tmp->arch->clone.speed); tmp->value = tmp->arch->clone.value; tmp->stats.sp = 1; tmp->stats.hp = tmp->stats.maxhp; /* Handle multipart gates. We copy the value for the other parts * from the head - this ensures that the data will consistent */ - for (tmp = tmp->more; tmp != NULL; tmp = tmp->more) + for (tmp = tmp->more; tmp; tmp = tmp->more) { - tmp->speed = tmp->head->speed; tmp->value = tmp->head->value; tmp->stats.sp = tmp->head->stats.sp; tmp->stats.hp = tmp->head->stats.hp; - update_ob_speed (tmp); + tmp->set_speed (tmp->head->speed); } break; @@ -278,38 +276,9 @@ } } -/* - * Updates every button on the map (by calling update_button() for them). - */ - -void -update_buttons (maptile *m) -{ - objectlink *ol; - oblinkpt *obp; - - for (obp = m->buttons; obp; obp = obp->next) - for (ol = obp->link; ol; ol = ol->next) - { - if (!ol->ob) - { - LOG (llevError, "Internal error in update_button (%s (%dx%d), connected %ld).\n", - ol->ob ? (const char *) ol->ob->name : "null", ol->ob ? ol->ob->x : -1, ol->ob ? ol->ob->y : -1, obp->value); - continue; - } - - if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL) - { - update_button (ol->ob); - break; - } - } -} - void use_trigger (object *op) { - /* Toggle value */ op->value = !op->value; push_button (op); @@ -319,7 +288,6 @@ * Note: animate_object should be used instead of this, * but it can't handle animations in the 8 directions */ - void animate_turning (object *op) /* only one part objects */ { @@ -416,18 +384,13 @@ if (state) { use_trigger (op); - if (op->stats.exp > 0) /* check sanity */ - op->speed = 1.0 / op->stats.exp; - else - op->speed = 1.0; - update_ob_speed (op); + op->set_speed (op->stats.exp > 0 ? 1. / op->stats.exp : 1.); op->speed_left = -1; } else { use_trigger (op); - op->speed = 0; - update_ob_speed (op); + op->set_speed (0); } } @@ -572,8 +535,7 @@ { op->stats.wc = 0; op->value = !op->value; - op->speed = 0; - update_ob_speed (op); + op->set_speed (0); } } return 0; @@ -583,13 +545,16 @@ { if (in_movement) return 0; + push = 1; } + if (NUM_ANIMATIONS (op) > 1) { SET_ANIMATION (op, push); update_object (op, UP_OBJ_FACE); } + trigger_move (op, push); return 1; @@ -805,7 +770,6 @@ SET_FLAG (tmp, FLAG_MONSTER); tmp->stats.exp = 0; - SET_FLAG (tmp, FLAG_FRIENDLY); add_friendly_object (tmp); tmp->attack_movement = PETMOVE; @@ -870,6 +834,7 @@ void check_inv (object *op, object *trig) { + sint32 prev_state = trig->value; trig->value = 0; // deactivate if none of the following conditions apply if (object *pl = trig->ms ().player ()) @@ -887,6 +852,7 @@ trig->value = 1; } - push_button (trig); + if (prev_state != trig->value) + push_button (trig); }