--- deliantra/server/common/object.C 2008/07/14 23:47:06 1.248 +++ deliantra/server/common/object.C 2008/09/29 09:04:50 1.258 @@ -188,12 +188,9 @@ || ob1->name != ob2->name) return 0; - /* Do not merge objects if nrof would overflow. First part checks - * for unsigned overflow (2c), second part checks whether the result - * would fit into a 32 bit signed int, which is often used to hold - * nrof values. - */ - if (~ob1->nrof < ob2->nrof || ob1->nrof + ob2->nrof > (1UL << 31)) + /* Do not merge objects if nrof would overflow, assume nrof + * is always 0 .. 2**31-1 */ + if (ob1->nrof > 0x7fffffff - ob2->nrof) return 0; /* If the objects have been identified, set the BEEN_APPLIED flag. @@ -237,7 +234,6 @@ if ((ob1->flag ^ ob2->flag) .reset (FLAG_INV_LOCKED) - .reset (FLAG_CLIENT_SENT) .reset (FLAG_REMOVED) .any ()) return 0; @@ -642,7 +638,7 @@ if (speed < 0) dst->speed_left -= rndm (); - dst->set_speed (dst->speed); + dst->activate (); } void @@ -772,7 +768,7 @@ || (m.move_off | op->move_off ) != m.move_off || (m.move_slow | op->move_slow) != m.move_slow /* This isn't perfect, but I don't expect a lot of objects to - * to have move_allow right now. + * have move_allow right now. */ || ((m.move_block | op->move_block) & ~op->move_allow) != m.move_block || 1) // the above is not strong enough a test to skip updating. los maybe? TODO (Schmorp) @@ -836,6 +832,9 @@ if (active) return; + if (has_active_speed () && flag [FLAG_FREED]) LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D + if (has_active_speed () && flag [FLAG_DEBUG]) LOG (llevError | logBacktrace, "BUG: tried to activate DEBUG object %s\n", debug_desc ());//D temp + if (has_active_speed ()) actives.insert (this); } @@ -912,10 +911,7 @@ || ms ().move_block == MOVE_ALL) { while (inv) - { - inv->destroy_inv (false); - inv->destroy (); - } + inv->destroy (true); } else { /* Put objects in inventory onto this space */ @@ -989,7 +985,7 @@ if (more) { - more->destroy (); + more->destroy (true); more = 0; } @@ -1120,6 +1116,8 @@ above = 0; below = 0; + ms.flags_ = 0; + if (map->in_memory == MAP_SAVING) return; @@ -1161,13 +1159,6 @@ last = tmp; } - /* last == NULL if there are no objects on this space */ - //TODO: this makes little sense, why only update the topmost object? - if (!last) - map->at (x, y).flags_ = 0; - else - update_object (last, UP_OBJ_REMOVE); - if (flag [FLAG_BLOCKSVIEW] || glow_radius) update_all_los (map, x, y); } @@ -1202,7 +1193,7 @@ op->weight = 0; // cancel the addition above op->carrying = 0; // must be 0 already - op->destroy (1); + op->destroy (true); return top; } @@ -1286,10 +1277,9 @@ op->remove (); } - if (op->face && !face_info (op->face))//D TODO: remove soon + if (m == &freed_map)//D TODO: remove soon {//D - LOG (llevError | logBacktrace, "op->face out of bounds: %s", op->debug_desc ());//D - op->face = 1;//D + LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D }//D /* Ideally, the caller figures this out. However, it complicates a lot @@ -1298,7 +1288,7 @@ */ if (!xy_normalise (m, op->x, op->y)) { - op->head_ ()->destroy (1);// remove head_ once all tail object destroyers found + op->head_ ()->destroy (true);// remove head_ once all tail object destroyers found return 0; } @@ -1321,7 +1311,7 @@ // but some caller surely breaks when we return tmp // from here :/ op->nrof += tmp->nrof; - tmp->destroy (1); + tmp->destroy (true); } CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ @@ -1506,7 +1496,7 @@ for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above) if (!strcmp (tmp->arch->archname, arch_string)) /* same archetype */ - tmp->destroy (1); + tmp->destroy (true); object *tmp = arch_to_object (archetype::find (arch_string)); @@ -1540,10 +1530,9 @@ nr = min (nr, nrof); - nrof -= nr; - - if (nrof) + if (nrof > nr) { + nrof -= nr; adjust_weight (env, -weight * max (1, nr)); // carrying == 0 if (object *pl = visible_to ()) @@ -1553,7 +1542,7 @@ } else { - destroy (1); + destroy (); return false; } } @@ -1640,7 +1629,7 @@ adjust_weight (this, op->total_weight ()); - op->destroy (1); + op->destroy (true); op = tmp; goto inserted; } @@ -2499,7 +2488,7 @@ // remove the "Close old_container" object. if (object *closer = old_container->inv) if (closer->type == CLOSE_CON) - closer->destroy (); + closer->destroy (true); #endif // make sure the container is available @@ -2565,7 +2554,7 @@ object::force_add (const shstr name, int duration) { if (object *force = force_find (name)) - force->destroy (); + force->destroy (true); object *force = get_archetype (FORCE_NAME);