--- deliantra/server/common/arch.C 2006/09/10 13:20:12 1.15 +++ 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.15 2006/09/10 13:20:12 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -56,13 +50,17 @@ #if USE_UNORDERED_MAP // the hashtable -typedef - std::tr1::unordered_map < -size_t, archetype *> - HT; +typedef std::tr1::unordered_map + < + std::size_t, + archetype *, + std::hash, + std::equal_to, + slice_allocator< std::pair > + true, + > HT; -static HT - ht; +static HT ht; #endif /** @@ -174,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); } @@ -425,7 +422,9 @@ else next = at->next; - delete at; + delete + at; + i++; } LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f); @@ -519,8 +518,7 @@ at->clone.arch = at; } - delete - at; + delete at; } /* @@ -618,7 +616,8 @@ LOG (llevDebug, "Reading archetypes from %s:\n", filename); { - object_thawer thawer (filename); + object_thawer + thawer (filename); clear_archetable (); LOG (llevDebug, " arch-pass 1...\n"); @@ -630,7 +629,8 @@ warn_archetypes = 1; { - object_thawer thawer (filename); + object_thawer + thawer (filename); LOG (llevDebug, " loading treasure...\n"); load_treasures (); @@ -757,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;