--- deliantra/server/common/object.C 2007/04/16 06:23:40 1.137 +++ deliantra/server/common/object.C 2007/04/21 16:56:29 1.138 @@ -1114,6 +1114,29 @@ return 0; } +void +object::expand_tail () +{ + if (more) + return; + + object *prev = this; + + for (archetype *at = arch->more; at; at = at->more) + { + object *op = arch_to_object (at); + + op->name = name; + op->name_pl = name_pl; + op->title = title; + + op->head = this; + prev->more = op; + + prev = op; + } +} + /* * same as insert_ob_in_map except it handles separate coordinates and does a clean * job preparing multi-part monsters. @@ -1153,31 +1176,21 @@ object * insert_ob_in_map (object *op, maptile *m, object *originator, int flag) { - object *tmp, *top, *floor = NULL; + assert (!op->flag [FLAG_FREED]); - if (QUERY_FLAG (op, FLAG_FREED)) - { - LOG (llevError, "Trying to insert freed object!\n"); - return NULL; - } - - if (!QUERY_FLAG (op, FLAG_REMOVED)) - LOG (llevError, "Trying to insert already inserted object %s\n", op->debug_desc ()); + object *tmp, *top, *floor = NULL; op->remove (); - if (!m) - { - char *dump = dump_object (op); - LOG (llevError, "Trying to insert in null-map!\n%s\n", dump); - free (dump); - return op; - } + if (!m->active != !op->active) + if (m->active) + op->activate_recursive (); + else + op->deactivate_recursive (); if (out_of_map (m, op->x, op->y)) { - char *dump = dump_object (op); - LOG (llevError, "Trying to insert object outside the map.\n%s\n", dump); + LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ()); #ifdef MANY_CORES /* Better to catch this here, as otherwise the next use of this object * is likely to cause a crash. Better to find out where it is getting @@ -1185,7 +1198,6 @@ */ abort (); #endif - free (dump); return op; } @@ -1432,11 +1444,10 @@ insert_ob_in_map (tmp1, op->map, op, 0); } -// XXX: function not returning object* object * object::insert_at (object *where, object *originator, int flags) { - where->map->insert (this, where->x, where->y, originator, flags); + return where->map->insert (this, where->x, where->y, originator, flags); } /* @@ -1486,7 +1497,6 @@ * * Return value: 'op' if something is left, NULL if the amount reached 0 */ - object * decrease_ob_nr (object *op, uint32 i) { @@ -1571,7 +1581,6 @@ * add_weight(object, weight) adds the specified weight to an object, * and also updates how much the environment(s) is/are carrying. */ - void add_weight (object *op, signed long weight) { @@ -1613,7 +1622,6 @@ * The function returns now pointer to inserted item, and return value can * be != op, if items are merged. -Tero */ - object * object::insert (object *op) {