--- deliantra/server/common/arch.C 2006/09/10 16:00:23 1.16 +++ deliantra/server/common/arch.C 2006/09/14 18:13:01 1.19 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_arch_c = - * "$Id: arch.C,v 1.16 2006/09/10 16:00:23 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -56,14 +50,17 @@ #if USE_UNORDERED_MAP // the hashtable -typedef - std::tr1::unordered_map < -size_t, archetype *> - HT; - -static - HT - ht; +typedef std::tr1::unordered_map + < + std::size_t, + archetype *, + std::hash, + std::equal_to, + slice_allocator< std::pair > + true, + > HT; + +static HT ht; #endif /** @@ -175,24 +172,23 @@ object * get_archetype_by_object_name (const char *name) { - archetype * - at; - char - tmpname[MAX_BUF]; - int - i; + archetype *at; + char tmpname[MAX_BUF]; + int i; + + assign (tmpname, name); - strncpy (tmpname, name, MAX_BUF - 1); - tmpname[MAX_BUF - 1] = 0; for (i = strlen (tmpname); i > 0; i--) { tmpname[i] = 0; at = find_archetype_by_object_name (tmpname); + if (at != NULL) { return arch_to_object (at); } } + return create_singularity (name); } @@ -761,7 +757,7 @@ if (!name) return 0; - HT::const_iterator i = ht.find ((size_t) name); + AUTODECL (i, ht.find ((size_t) name)); if (i == ht.end ()) return 0;