--- deliantra/server/common/object.C 2007/04/16 06:23:40 1.137 +++ deliantra/server/common/object.C 2007/05/01 05:48:20 1.143 @@ -1,5 +1,5 @@ /* - * CrossFire, A Multiplayer game for X-windows + * CrossFire, A Multiplayer game * * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team * Copyright (C) 2001 Mark Wedel & Crossfire Development Team @@ -326,10 +326,11 @@ long sum; object *inv; - for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) + for (sum = 0, inv = op->inv; inv; inv = inv->below) { if (inv->inv) sum_weight (inv); + sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); } @@ -837,15 +838,7 @@ remove_button_link (this); if (flag [FLAG_FRIENDLY]) - { - remove_friendly_object (this); - - if (type == GOLEM - && owner - && owner->type == PLAYER - && owner->contr->ranges[range_golem] == this) - owner->contr->ranges[range_golem] = 0; - } + remove_friendly_object (this); if (!flag [FLAG_REMOVED]) remove (); @@ -1114,6 +1107,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 +1169,23 @@ object * insert_ob_in_map (object *op, maptile *m, object *originator, int flag) { - object *tmp, *top, *floor = NULL; - - if (QUERY_FLAG (op, FLAG_FREED)) - { - LOG (llevError, "Trying to insert freed object!\n"); - return NULL; - } + assert (!op->flag [FLAG_FREED]); - 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 0 + if (!m->active != !op->active) + if (m->active) + op->activate_recursive (); + else + op->deactivate_recursive (); +#endif 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 +1193,6 @@ */ abort (); #endif - free (dump); return op; } @@ -1432,11 +1439,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 +1492,6 @@ * * Return value: 'op' if something is left, NULL if the amount reached 0 */ - object * decrease_ob_nr (object *op, uint32 i) { @@ -1571,7 +1576,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 +1617,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) { @@ -2583,15 +2586,10 @@ const char * object::debug_desc () const { - static char info[256 * 4]; - return debug_desc (info); -} + static char info[3][256 * 4]; + static int info_idx; -const char * -object::debug_desc2 () const -{ - static char info[256 * 4]; - return debug_desc (info); + return debug_desc (info [++info_idx % 3]); } struct region *