--- deliantra/server/common/object.C 2006/12/26 08:17:58 1.86 +++ deliantra/server/common/object.C 2006/12/26 08:54:59 1.87 @@ -524,7 +524,7 @@ } } - update_ob_speed (dst); + dst->set_speed (dst->speed); } object * @@ -556,60 +556,62 @@ * This function needs to be called whenever the speed of an object changes. */ void -update_ob_speed (object *op) +object::set_speed (float speed) { extern int arch_init; /* No reason putting the archetypes objects on the speed list, * since they never really need to be updated. */ - if (QUERY_FLAG (op, FLAG_FREED) && op->speed) + if (flag [FLAG_FREED] && speed) { - LOG (llevError, "Object %s is freed but has speed.\n", &op->name); - op->speed = 0; + LOG (llevError, "Object %s is freed but has speed.\n", &name); + speed = 0; } + this->speed = speed; + if (arch_init) return; - if (FABS (op->speed) > MIN_ACTIVE_SPEED) + if (FABS (speed) > MIN_ACTIVE_SPEED) { /* If already on active list, don't do anything */ - if (op->active_next || op->active_prev || op == active_objects) + if (active_next || active_prev || this == active_objects) return; /* process_events() expects us to insert the object at the beginning * of the list. */ - op->active_next = active_objects; + active_next = active_objects; - if (op->active_next != NULL) - op->active_next->active_prev = op; + if (active_next) + active_next->active_prev = this; - active_objects = op; + active_objects = this; } else { /* If not on the active list, nothing needs to be done */ - if (!op->active_next && !op->active_prev && op != active_objects) + if (!active_next && !active_prev && this != active_objects) return; - if (op->active_prev == NULL) + if (!active_prev) { - active_objects = op->active_next; + active_objects = active_next; - if (op->active_next != NULL) - op->active_next->active_prev = NULL; + if (active_next) + active_next->active_prev = 0; } else { - op->active_prev->active_next = op->active_next; + active_prev->active_next = active_next; - if (op->active_next) - op->active_next->active_prev = op->active_prev; + if (active_next) + active_next->active_prev = active_prev; } - op->active_next = NULL; - op->active_prev = NULL; + active_next = 0; + active_prev = 0; } } @@ -785,16 +787,6 @@ return op; } -/* - * free_object() frees everything allocated by an object, removes - * it from the list of used objects, and puts it on the list of - * free objects. The IS_FREED() flag is set in the object. - * The object must have been removed by remove_ob() first for - * this function to succeed. - * - * If destroy_inventory is set, free inventory as well. Else drop items in - * inventory to the ground. - */ void object::do_destroy () { @@ -847,8 +839,7 @@ contr = 0; /* Remove object from the active list */ - speed = 0; - update_ob_speed (this); + set_speed (0); unlink (); }