--- deliantra/server/common/object.C 2007/10/15 17:50:27 1.193 +++ deliantra/server/common/object.C 2007/10/22 02:52:48 1.198 @@ -309,8 +309,8 @@ if (ob1->self || ob2->self) { - int k1 = ob1->self ? HvTOTALKEYS (SvRV (ob1->self)) : 0; - int k2 = ob2->self ? HvTOTALKEYS (SvRV (ob2->self)) : 0; + int k1 = ob1->self ? HvTOTALKEYS (ob1->self) : 0; + int k2 = ob2->self ? HvTOTALKEYS (ob2->self) : 0; if (k1 != k2) return 0; @@ -450,6 +450,12 @@ while (owner->owner) owner = owner->owner; + if (flag [FLAG_FREED]) + { + LOG (llevError | logBacktrace, "tried to set owner of %s to %s\n", debug_desc (), owner->debug_desc ()); + return; + } + this->owner = owner; } @@ -1152,7 +1158,7 @@ if (!op->nrof) return 0; - if (top) + if (!top) for (top = op; top && top->above; top = top->above) ; @@ -1954,12 +1960,11 @@ void flag_inv (object *op, int flag) { - if (op->inv) - for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) - { - SET_FLAG (tmp, flag); - flag_inv (tmp, flag); - } + for (object *tmp = op->inv; tmp; tmp = tmp->below) + { + SET_FLAG (tmp, flag); + flag_inv (tmp, flag); + } } /* @@ -1968,12 +1973,11 @@ void unflag_inv (object *op, int flag) { - if (op->inv) - for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) - { - CLEAR_FLAG (tmp, flag); - unflag_inv (tmp, flag); - } + for (object *tmp = op->inv; tmp; tmp = tmp->below) + { + CLEAR_FLAG (tmp, flag); + unflag_inv (tmp, flag); + } } /* @@ -1985,10 +1989,7 @@ * start and stop are where to start relative to the free_arr array (1,9 * does all 4 immediate directions). This returns the index into the * array of the free spot, -1 if no spot available (dir 0 = x,y) - * Note - this only checks to see if there is space for the head of the - * object - if it is a multispace object, this should be called for all - * pieces. - * Note2: This function does correctly handle tiled maps, but does not + * Note: This function does correctly handle tiled maps, but does not * inform the caller. However, insert_ob_in_map will update as * necessary, so the caller shouldn't need to do any special work. * Note - updated to take an object instead of archetype - this is necessary @@ -2045,6 +2046,9 @@ if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) continue; + if (ob->blocked (m, pos.x, pos.y)) + continue; + altern [index++] = i; }