--- deliantra/server/common/arch.C 2007/04/16 12:37:08 1.49 +++ deliantra/server/common/arch.C 2007/04/17 10:06:32 1.52 @@ -326,6 +326,8 @@ typedef std::pair part; std::vector parts; + coroapi::cede_to_tick_every (100); + for (;;) { archetype *at = get (f.get_str ()); @@ -347,7 +349,7 @@ archetype *head = parts.front ().first; // check that all archetypes belong to the same object or are heads - for (AUTODECL (p, parts.begin ()); p != parts.end (); ++p) + for (auto (p, parts.begin ()); p != parts.end (); ++p) { archetype *at = p->first; @@ -379,15 +381,16 @@ head->tail_y = 0; // link into list of heads, if not already there - if (!head->next) + if (!head->linked) { + head->linked = true; head->next = first_archetype; first_archetype = head; } // reassemble new chain archetype *prev = head; - for (AUTODECL (p, parts.begin () + 1); p != parts.end (); ++p) + for (auto (p, parts.begin () + 1); p != parts.end (); ++p) { archetype *at = p->first; overwrite (at, p->second); @@ -407,7 +410,7 @@ return true; fail: - for (AUTODECL (p, parts.begin ()); p != parts.end (); ++p) + for (auto (p, parts.begin ()); p != parts.end (); ++p) p->second->destroy (true); return false; @@ -459,9 +462,6 @@ f.next (); - // make sure the next - long - step is only done after a tick - coroapi::wait_for_tick_begin (); - if (!load_archetypes (f)) return false; @@ -471,8 +471,6 @@ if (!empty_archetype) return false; - coroapi::cede (); - return true; } @@ -532,36 +530,6 @@ } /* - * Hash-function used by the arch-hashtable. - */ - -unsigned long -hasharch (const char *str, int tablesize) -{ - unsigned long hash = 0; - unsigned int i = 0; - const char *p; - - /* use the one-at-a-time hash function, which supposedly is - * better than the djb2-like one used by perl5.005, but - * certainly is better then the bug used here before. - * see http://burtleburtle.net/bob/hash/doobs.html - */ - for (p = str; i < MAXSTRING && *p; p++, i++) - { - hash += *p; - hash += hash << 10; - hash ^= hash >> 6; - } - - hash += hash << 3; - hash ^= hash >> 11; - hash += hash << 15; - - return hash % tablesize; -} - -/* * Finds, using the hashtable, which archetype matches the given name. * returns a pointer to the found archetype, otherwise NULL. */ @@ -571,7 +539,7 @@ if (!name) return 0; - AUTODECL (i, ht.find (name)); + auto (i, ht.find (name)); if (i == ht.end ()) return 0;