--- deliantra/server/common/object.C 2006/09/12 01:09:53 1.34 +++ deliantra/server/common/object.C 2006/09/12 19:20:06 1.36 @@ -418,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; @@ -852,7 +852,7 @@ mortals.erase (i); } - if (mortals.size())//D + if (mortals.size() && 0)//D LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D } @@ -2722,34 +2722,27 @@ const char * get_ob_key_value (const object *op, const char *const key) { - key_value * - link; - const char * - canonical_key; - - canonical_key = shstr::find (key); + key_value *link; + shstr_cmp canonical_key (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; } @@ -2866,3 +2859,32 @@ 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); +} +