--- deliantra/server/common/object.C 2006/09/11 11:46:52 1.26 +++ deliantra/server/common/object.C 2006/09/12 19:20:06 1.36 @@ -1,10 +1,5 @@ /* - * static char *rcsid_object_c = - * "$Id: object.C,v 1.26 2006/09/11 11:46:52 root Exp $"; - */ - -/* CrossFire, A Multiplayer game for X-windows Copyright (C) 2001 Mark Wedel & Crossfire Development Team @@ -31,15 +26,13 @@ sub/add_weight will transcend the environment updating the carrying variable. */ #include -#ifndef WIN32 /* ---win32 exclude headers */ -# include -# include -# include -#endif /* win32 */ +#include +#include +#include #include #include -#include #include + int nrofallocobjects = 0; object *objects; /* Pointer to the list of used objects */ @@ -216,10 +209,10 @@ switch (ob1->type) { - case SCROLL: - if (ob1->level != ob2->level) - return 0; - break; + case SCROLL: + if (ob1->level != ob2->level) + return 0; + break; } if (ob1->key_values != NULL || ob2->key_values != NULL) @@ -251,10 +244,10 @@ * an object is carrying. It goes through in figures out how much * containers are carrying, and sums it up. */ -signed long +long sum_weight (object *op) { - signed long sum; + long sum; object *inv; for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) @@ -425,11 +418,11 @@ object * find_object_name (const char *str) { - const char *name = shstr::find (str); + shstr_cmp str_ (str); object *op; for (op = objects; op != NULL; op = op->next) - if (&op->name == name) + if (op->name == str_) break; return op; @@ -451,32 +444,15 @@ * anything, so check removed flag. I don't expect that this should break * anything - once an object is removed, it is basically dead anyways. */ - object * -get_owner (object *op) +object::get_owner () { - if (op->owner == NULL) - return NULL; - - if (!QUERY_FLAG (op->owner, FLAG_FREED) && !QUERY_FLAG (op->owner, FLAG_REMOVED) && op->owner->count == op->ownercount) - return op->owner; - - op->owner = NULL; - op->ownercount = 0; - return NULL; -} - -void -clear_owner (object *op) -{ - if (!op) - return; - - if (op->owner && op->ownercount == op->owner->count) - op->owner->refcount--; + if (!owner + || QUERY_FLAG (owner, FLAG_FREED) + || QUERY_FLAG (owner, FLAG_REMOVED)) + owner = 0; - op->owner = NULL; - op->ownercount = 0; + return owner; } /* @@ -484,9 +460,9 @@ * skill and experience objects. */ void -set_owner (object *op, object *owner) +object::set_owner (object *owner) { - if (owner == NULL || op == NULL) + if (!owner) return; /* next line added to allow objects which own objects */ @@ -496,48 +472,10 @@ * freed and then another object replacing it. Since the ownercounts * didn't match, this check is valid and I believe that cause is valid. */ - while (owner->owner && owner != owner->owner && owner->ownercount == owner->owner->count) + while (owner->owner) owner = owner->owner; - /* IF the owner still has an owner, we did not resolve to a final owner. - * so lets not add to that. - */ - if (owner->owner) - return; - - op->owner = owner; - - op->ownercount = owner->count; - owner->refcount++; -} - -/* Set the owner to clone's current owner and set the skill and experience - * objects to clone's objects (typically those objects that where the owner's - * current skill and experience objects at the time when clone's owner was - * set - not the owner's current skill and experience objects). - * - * Use this function if player created an object (e.g. fire bullet, swarm - * spell), and this object creates further objects whose kills should be - * accounted for the player's original skill, even if player has changed - * skills meanwhile. - */ -void -copy_owner (object *op, object *clone) -{ - object *owner = get_owner (clone); - - if (owner == NULL) - { - /* players don't have owners - they own themselves. Update - * as appropriate. - */ - if (clone->type == PLAYER) - owner = clone; - else - return; - } - - set_owner (op, owner); + this->owner = owner; } /* Zero the key_values on op, decrementing the shared-string @@ -563,8 +501,7 @@ free_key_values (this); - clear_owner (this); - + owner = 0; name = 0; name_pl = 0; title = 0; @@ -575,54 +512,42 @@ lore = 0; custom_name = 0; materialname = 0; + contr = 0; + below = 0; + above = 0; + inv = 0; + container = 0; + env = 0; + more = 0; + head = 0; + map = 0; + active_next = 0; + active_prev = 0; - memset (static_cast < object_pod * >(this), 0, sizeof (object_pod)); + memset (static_cast(this), 0, sizeof (object_pod)); SET_FLAG (this, FLAG_REMOVED); + + /* What is not cleared is next, prev, and count */ + + expmul = 1.0; + face = blank_face; + attacked_by_count = -1; + + if (settings.casting_time) + casting_time = -1; } void object::clone (object *destination) { - *(object_copy *) destination = *this; - *(object_pod *) destination = *this; + *(object_copy *)destination = *this; + *(object_pod *)destination = *this; if (self || cb) INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); } /* - * clear_object() frees everything allocated by an object, and also - * clears all variables and flags to default settings. - */ - -void -clear_object (object *op) -{ - op->clear (); - - op->contr = NULL; - op->below = NULL; - op->above = NULL; - op->inv = NULL; - op->container = NULL; - op->env = NULL; - op->more = NULL; - op->head = NULL; - op->map = NULL; - op->refcount = 0; - op->active_next = NULL; - op->active_prev = NULL; - /* What is not cleared is next, prev, and count */ - - op->expmul = 1.0; - op->face = blank_face; - op->attacked_by_count = -1; - - if (settings.casting_time) - op->casting_time = -1; -} - -/* * copy object first frees everything allocated by the second object, * and then copies the contends of the first object into the second * object, allocating what needs to be allocated. Basically, any @@ -630,7 +555,6 @@ * if the first object is freed, the pointers in the new object * will point at garbage. */ - void copy_object (object *op2, object *op) { @@ -700,7 +624,6 @@ * value, or vice versa, then add/remove the object from the active list. * This function needs to be called whenever the speed of an object changes. */ - void update_ob_speed (object *op) { @@ -719,10 +642,10 @@ op->speed = 0; #endif } + if (arch_init) - { - return; - } + return; + if (FABS (op->speed) > MIN_ACTIVE_SPEED) { /* If already on active list, don't do anything */ @@ -732,8 +655,10 @@ /* process_events() expects us to insert the object at the beginning * of the list. */ op->active_next = active_objects; + if (op->active_next != NULL) op->active_next->active_prev = op; + active_objects = op; } else @@ -745,15 +670,18 @@ if (op->active_prev == NULL) { active_objects = op->active_next; + if (op->active_next != NULL) op->active_next->active_prev = NULL; } else { op->active_prev->active_next = op->active_next; + if (op->active_next) op->active_next->active_prev = op->active_prev; } + op->active_next = NULL; op->active_prev = NULL; } @@ -893,17 +821,11 @@ * that is being removed. */ else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) - { - update_now = 1; - } + update_now = 1; else if (action == UP_OBJ_FACE) - { - /* Nothing to do for that case */ - } + /* Nothing to do for that case */ ; else - { - LOG (llevError, "update_object called with invalid action: %d\n", action); - } + LOG (llevError, "update_object called with invalid action: %d\n", action); if (update_now) { @@ -920,14 +842,18 @@ void object::free_mortals () { - for (unordered_vector::iterator i = mortals.begin (); i != mortals.end (); ) - if (!(*i)->refcount) + for (unordered_vector::iterator i = mortals.begin (); i != mortals.end ();) + if ((*i)->refcnt) + ++i; // further delay freeing + else { - freed.push_back (*i); + freed.push_back (*i);//D + //delete *i; mortals.erase (i); } - else - ++i; + + if (mortals.size() && 0)//D + LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D } object::object () @@ -987,9 +913,10 @@ else { // highly annoying, but the only way to get it stable right now - op = freed.back (); freed.pop_back (); + op = freed.back (); + freed.pop_back (); op->~object (); - new ((void *)op) object; + new ((void *) op) object; } op->link (); @@ -1008,27 +935,16 @@ */ void object::free (bool free_inventory) { - if (!QUERY_FLAG (this, FLAG_REMOVED)) - { - LOG (llevDebug, "Free object called with non removed object\n"); - dump_object (this); -#ifdef MANY_CORES - abort (); -#endif - } + if (QUERY_FLAG (this, FLAG_FREED)) + return; if (QUERY_FLAG (this, FLAG_FRIENDLY)) - { - LOG (llevMonster, "Warning: tried to free friendly object.\n"); - remove_friendly_object (this); - } + remove_friendly_object (this); - if (QUERY_FLAG (this, FLAG_FREED)) - { - dump_object (this); - LOG (llevError, "Trying to free freed object.\n%s\n", errmsg); - return; - } + if (!QUERY_FLAG (this, FLAG_REMOVED)) + remove_ob (this); + + SET_FLAG (this, FLAG_FREED); if (more) { @@ -1042,30 +958,24 @@ * if some form of movement is allowed, let objects * drop on that space. */ - if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || (GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)) + if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) { - object * - op = inv; + object *op = inv; while (op) { - object * - tmp = op->below; - - remove_ob (op); + object *tmp = op->below; op->free (free_inventory); op = tmp; } } else { /* Put objects in inventory onto this space */ - object * - op = inv; + object *op = inv; while (op) { - object * - tmp = op->below; + object *tmp = op->below; remove_ob (op); @@ -1084,7 +994,7 @@ } } - clear_owner (this); + owner = 0; /* Remove object from the active list */ speed = 0; @@ -1092,8 +1002,6 @@ unlink (); - SET_FLAG (this, FLAG_FREED); - mortals.push_back (this); } @@ -1128,38 +1036,31 @@ void remove_ob (object *op) { - object *tmp, *last = NULL; - object *otmp; + object * + tmp, * + last = NULL; + object * + otmp; - tag_t tag; - int check_walk_off; - mapstruct *m; + tag_t + tag; + int + check_walk_off; + mapstruct * + m; - sint16 x, y; + sint16 + x, + y; if (QUERY_FLAG (op, FLAG_REMOVED)) - { - dump_object (op); - LOG (llevError, "Trying to remove removed object.\n%s\n", errmsg); + return; - /* Changed it to always dump core in this case. As has been learned - * in the past, trying to recover from errors almost always - * make things worse, and this is a real error here - something - * that should not happen. - * Yes, if this was a mission critical app, trying to do something - * to recover may make sense, but that is because failure of the app - * may have other disastrous problems. Cf runs out of a script - * so is easily enough restarted without any real problems. - * MSW 2001-07-01 - */ - abort (); - } + SET_FLAG (op, FLAG_REMOVED); if (op->more != NULL) remove_ob (op->more); - SET_FLAG (op, FLAG_REMOVED); - /* * In this case, the object to be removed is in someones * inventory. @@ -1194,128 +1095,125 @@ op->map = op->env->map; op->above = NULL, op->below = NULL; op->env = NULL; - return; } + else if (op->map) + { + x = op->x; + y = op->y; + m = get_map_from_coord (op->map, &x, &y); + + if (!m) + { + LOG (llevError, "remove_ob called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n", + op->map->path, op->x, op->y); + /* in old days, we used to set x and y to 0 and continue. + * it seems if we get into this case, something is probablye + * screwed up and should be fixed. + */ + abort (); + } - /* If we get here, we are removing it from a map */ - if (op->map == NULL) - return; - - x = op->x; - y = op->y; - m = get_map_from_coord (op->map, &x, &y); + if (op->map != m) + LOG (llevDebug, "remove_ob: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n", + op->map->path, m->path, op->x, op->y, x, y); - if (!m) - { - LOG (llevError, "remove_ob called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n", - op->map->path, op->x, op->y); - /* in old days, we used to set x and y to 0 and continue. - * it seems if we get into this case, something is probablye - * screwed up and should be fixed. + /* Re did the following section of code - it looks like it had + * lots of logic for things we no longer care about */ - abort (); - } - if (op->map != m) - { - LOG (llevDebug, "remove_ob: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n", - op->map->path, m->path, op->x, op->y, x, y); - } - /* Re did the following section of code - it looks like it had - * lots of logic for things we no longer care about - */ - - /* link the object above us */ - if (op->above) - op->above->below = op->below; - else - SET_MAP_TOP (m, x, y, op->below); /* we were top, set new top */ + /* link the object above us */ + if (op->above) + op->above->below = op->below; + else + SET_MAP_TOP (m, x, y, op->below); /* we were top, set new top */ - /* Relink the object below us, if there is one */ - if (op->below) - op->below->above = op->above; - else - { - /* Nothing below, which means we need to relink map object for this space - * use translated coordinates in case some oddness with map tiling is - * evident - */ - if (GET_MAP_OB (m, x, y) != op) + /* Relink the object below us, if there is one */ + if (op->below) + op->below->above = op->above; + else { - dump_object (op); - LOG (llevError, "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", - errmsg); - dump_object (GET_MAP_OB (m, x, y)); - LOG (llevError, "%s\n", errmsg); - } - - SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ - } + /* Nothing below, which means we need to relink map object for this space + * use translated coordinates in case some oddness with map tiling is + * evident + */ + if (GET_MAP_OB (m, x, y) != op) + { + dump_object (op); + LOG (llevError, + "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", errmsg); + dump_object (GET_MAP_OB (m, x, y)); + LOG (llevError, "%s\n", errmsg); + } - op->above = NULL; - op->below = NULL; + SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ + } - if (op->map->in_memory == MAP_SAVING) - return; + op->above = 0; + op->below = 0; - tag = op->count; - check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY); + if (op->map->in_memory == MAP_SAVING) + return; - for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) - { - /* No point updating the players look faces if he is the object - * being removed. - */ + tag = op->count; + check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY); - if (tmp->type == PLAYER && tmp != op) + for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) { - /* If a container that the player is currently using somehow gets - * removed (most likely destroyed), update the player view - * appropriately. + /* No point updating the players look faces if he is the object + * being removed. */ - if (tmp->container == op) + + if (tmp->type == PLAYER && tmp != op) { - CLEAR_FLAG (op, FLAG_APPLIED); - tmp->container = NULL; - } + /* If a container that the player is currently using somehow gets + * removed (most likely destroyed), update the player view + * appropriately. + */ + if (tmp->container == op) + { + CLEAR_FLAG (op, FLAG_APPLIED); + tmp->container = NULL; + } - tmp->contr->socket.update_look = 1; - } - /* See if player moving off should effect something */ - if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) - { - move_apply (tmp, op, NULL); + tmp->contr->socket.update_look = 1; + } - if (was_destroyed (op, tag)) + /* See if player moving off should effect something */ + if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) { - LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); + move_apply (tmp, op, NULL); + + if (was_destroyed (op, tag)) + { + LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); + } } - } - /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ + /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ - if (tmp->above == tmp) - tmp->above = NULL; + if (tmp->above == tmp) + tmp->above = NULL; - last = tmp; - } + last = tmp; + } - /* last == NULL of there are no objects on this space */ - if (last == NULL) - { - /* set P_NEED_UPDATE, otherwise update_position will complain. In theory, - * we could preserve the flags (GET_MAP_FLAGS), but update_position figures - * those out anyways, and if there are any flags set right now, they won't - * be correct anyways. - */ - SET_MAP_FLAGS (op->map, op->x, op->y, P_NEED_UPDATE); - update_position (op->map, op->x, op->y); - } - else - update_object (last, UP_OBJ_REMOVE); + /* last == NULL of there are no objects on this space */ + if (last == NULL) + { + /* set P_NEED_UPDATE, otherwise update_position will complain. In theory, + * we could preserve the flags (GET_MAP_FLAGS), but update_position figures + * those out anyways, and if there are any flags set right now, they won't + * be correct anyways. + */ + SET_MAP_FLAGS (op->map, op->x, op->y, P_NEED_UPDATE); + update_position (op->map, op->x, op->y); + } + else + update_object (last, UP_OBJ_REMOVE); - if (QUERY_FLAG (op, FLAG_BLOCKSVIEW) || (op->glow_radius != 0)) - update_all_los (op->map, op->x, op->y); + if (QUERY_FLAG (op, FLAG_BLOCKSVIEW) || (op->glow_radius != 0)) + update_all_los (op->map, op->x, op->y); + } } /* @@ -1332,8 +1230,10 @@ { if (!op->nrof) return 0; + if (top == NULL) for (top = op; top != NULL && top->above != NULL; top = top->above); + for (; top != NULL; top = top->below) { if (top == op) @@ -1349,6 +1249,7 @@ return top; } } + return NULL; } @@ -1359,16 +1260,17 @@ object * insert_ob_in_map_at (object *op, mapstruct *m, object *originator, int flag, int x, int y) { - object * - tmp; + object *tmp; if (op->head) op = op->head; + for (tmp = op; tmp; tmp = tmp->more) { tmp->x = x + tmp->arch->clone.x; tmp->y = y + tmp->arch->clone.y; } + return insert_ob_in_map (op, m, originator, flag); } @@ -1669,8 +1571,10 @@ void replace_insert_ob_in_map (const char *arch_string, object *op) { - object *tmp; - object *tmp1; + object * + tmp; + object * + tmp1; /* first search for itself and remove any old instances */ @@ -1711,7 +1615,9 @@ sprintf (errmsg, "There are only %d %ss.", orig_ob->nrof ? orig_ob->nrof : 1, &orig_ob->name); return NULL; } + newob = object_create_clone (orig_ob); + if ((orig_ob->nrof -= nr) < 1) { if (!is_removed) @@ -1729,6 +1635,7 @@ return NULL; } } + newob->nrof = nr; return newob; @@ -1745,10 +1652,8 @@ object * decrease_ob_nr (object *op, uint32 i) { - object * - tmp; - player * - pl; + object *tmp; + player *pl; if (i == 0) /* objects with op->nrof require this check */ return op; @@ -1757,9 +1662,7 @@ i = op->nrof; if (QUERY_FLAG (op, FLAG_REMOVED)) - { - op->nrof -= i; - } + op->nrof -= i; else if (op->env != NULL) { /* is this object in the players inventory, or sub container @@ -1804,18 +1707,16 @@ } else { - object * - above = op->above; + object *above = op->above; if (i < op->nrof) - { - op->nrof -= i; - } + op->nrof -= i; else { remove_ob (op); op->nrof = 0; } + /* Since we just removed op, op->above is null */ for (tmp = above; tmp != NULL; tmp = tmp->above) if (tmp->type == PLAYER) @@ -1828,9 +1729,7 @@ } if (op->nrof) - { - return op; - } + return op; else { free_object (op); @@ -1849,9 +1748,8 @@ while (op != NULL) { if (op->type == CONTAINER) - { - weight = (signed long) (weight * (100 - op->stats.Str) / 100); - } + weight = (signed long) (weight * (100 - op->stats.Str) / 100); + op->carrying += weight; op = op->env; } @@ -1884,22 +1782,26 @@ LOG (llevError, "Trying to insert (ob) inserted object.\n%s\n", errmsg); return op; } + if (where == NULL) { dump_object (op); LOG (llevError, "Trying to put object in NULL.\n%s\n", errmsg); return op; } + if (where->head) { LOG (llevDebug, "Warning: Tried to insert object wrong part of multipart object.\n"); where = where->head; } + if (op->more) { LOG (llevError, "Tried to insert multipart object %s (%d)\n", &op->name, op->count); return op; } + CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); CLEAR_FLAG (op, FLAG_REMOVED); if (op->nrof) @@ -1994,12 +1896,19 @@ int check_move_on (object *op, object *originator) { - object *tmp; - tag_t tag; - mapstruct *m = op->map; - int x = op->x, y = op->y; + object * + tmp; + tag_t + tag; + mapstruct * + m = op->map; + int + x = op->x, y = op->y; - MoveType move_on, move_slow, move_block; + MoveType + move_on, + move_slow, + move_block; if (QUERY_FLAG (op, FLAG_NO_APPLY)) return 0; @@ -2057,7 +1966,8 @@ ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) { - float diff = tmp->move_slow_penalty * FABS (op->speed); + float + diff = tmp->move_slow_penalty * FABS (op->speed); if (op->type == PLAYER) if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || @@ -2386,16 +2296,14 @@ int i, max = SIZEOFFREE, mflags; - sint16 - nx, - ny; + + sint16 nx, ny; object * tmp; mapstruct * mp; - MoveType - blocked, - move_type; + + MoveType blocked, move_type; if (exclude && exclude->head) { @@ -2612,9 +2520,7 @@ int can_see_monsterP (mapstruct *m, int x, int y, int dir) { - sint16 - dx, - dy; + sint16 dx, dy; int mflags; @@ -2755,8 +2661,7 @@ op = get_object (); - object_thawer - thawer (filename); + object_thawer thawer (filename); if (thawer) load_object (thawer, op, 0); @@ -2817,34 +2722,27 @@ const char * get_ob_key_value (const object *op, const char *const key) { - key_value * - link; - const char * - canonical_key; + key_value *link; + shstr_cmp canonical_key (key); - canonical_key = shstr::find (key); - - if (canonical_key == NULL) + if (!canonical_key) { /* 1. There being a field named key on any object * implies there'd be a shared string to find. * 2. Since there isn't, no object has this field. * 3. Therefore, *this* object doesn't have this field. */ - return NULL; + return 0; } /* This is copied from get_ob_key_link() above - * only 4 lines, and saves the function call overhead. */ - for (link = op->key_values; link != NULL; link = link->next) - { - if (link->key == canonical_key) - { - return link->value; - } - } - return NULL; + for (link = op->key_values; link; link = link->next) + if (link->key == canonical_key) + return link->value; + + return 0; } @@ -2890,8 +2788,7 @@ else op->key_values = field->next; - delete - field; + delete field; } } return TRUE; @@ -2936,8 +2833,58 @@ int set_ob_key_value (object *op, const char *key, const char *value, int add_key) { - shstr - key_ (key); + shstr key_ (key); return set_ob_key_value_s (op, key_, value, add_key); } + +object::depth_iterator::depth_iterator (object *container) +: iterator_base (container) +{ + while (item->inv) + item = item->inv; +} + +void +object::depth_iterator::next () +{ + if (item->below) + { + item = item->below; + + while (item->inv) + item = item->inv; + } + else + item = item->env; +} + +// return a suitable string describing an objetc in enough detail to find it +const char * +object::debug_desc (char *info) const +{ + char info2[256 * 3]; + char *p = info; + + p += snprintf (p, 256, "%d=\"%s%s%s\"", + count, + &name, + title ? " " : "", + title ? (const char *)title : ""); + + if (env) + p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); + + if (map) + p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y); + + return info; +} + +const char * +object::debug_desc () const +{ + static char info[256 * 3]; + return debug_desc (info); +} +