--- deliantra/server/common/object.C 2006/09/11 23:33:27 1.31 +++ deliantra/server/common/object.C 2006/09/12 18:15:34 1.35 @@ -31,7 +31,6 @@ #include #include #include -#include #include int nrofallocobjects = 0; @@ -419,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; @@ -853,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 } @@ -907,8 +906,7 @@ object *object::create () { - object * - op; + object *op; if (freed.empty ()) op = new object; @@ -940,12 +938,12 @@ if (QUERY_FLAG (this, FLAG_FREED)) return; - if (!QUERY_FLAG (this, FLAG_REMOVED)) - remove_ob (this); - if (QUERY_FLAG (this, FLAG_FRIENDLY)) remove_friendly_object (this); + if (!QUERY_FLAG (this, FLAG_REMOVED)) + remove_ob (this); + SET_FLAG (this, FLAG_FREED); if (more) @@ -960,7 +958,7 @@ * 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; @@ -2724,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; } @@ -2847,13 +2838,24 @@ return set_ob_key_value_s (op, key_, value, add_key); } -void -object::deep_iterator::next () +object::depth_iterator::depth_iterator (object *container) +: iterator_base (container) { - if (item->inv) + while (item->inv) item = item->inv; - else if (item->below) - item = item->below; +} + +void +object::depth_iterator::next () +{ + if (item->below) + { + item = item->below; + + while (item->inv) + item = item->inv; + } else - item = item->env->below; + item = item->env; } +