--- deliantra/server/common/arch.C 2007/06/04 13:04:00 1.63 +++ deliantra/server/common/arch.C 2007/06/05 13:05:02 1.64 @@ -302,7 +302,7 @@ archetype::unlink () { ht.erase (archname); - + if (!strcmp (&archname, "Gaea")) fprintf (stderr, "oI\n");//D if (archetypes.contains (this)) archetypes.erase (this); } @@ -336,13 +336,7 @@ archetype *at = find (name); - if (loading_arch && at && !at->stub) - { - at->unlink (); - at = 0; - } - - if (!at || (!at->stub && loading_arch)) + if (!at) { at = new archetype (name); at->link (); @@ -417,8 +411,12 @@ archetype *new_head = parts.front (); archetype *old_head = find (new_head->archname); - for (auto (at, parts.begin ()); at != parts.end (); ++at) - fprintf (stderr, "%d: %s\n", at - parts.begin(), &(*at)->archname);//D + if (old_head && !old_head->is_head ()) + { + LOG (llevError, "%s: unable to overwrite non-head archetype '%s' with head archetype, skipping.\n", + &new_head->archname, &old_head->archname); + goto fail; + } // check that all archetypes belong to the same old object or are new for (auto (at, parts.begin ()); at != parts.end (); ++at) @@ -428,26 +426,21 @@ if (old_part && old_part->head_ () != old_head) { - fprintf (stderr, "nhn %s\n", &new_head->archname);//D - fprintf (stderr, "old_head %p,%p new_head %p,%p ph %p\n", old_head, old_part, new_head, new_part, old_part->head_()); LOG (llevError, "%s: unable to overwrite archetype '%s' with archetype of different object, skipping.\n", &new_part->archname, &((archetype *)old_part->head_ ())->archname); goto fail; } } - fprintf (stderr, "oh %p %s\n", old_head, &new_head->archname);//D - // deactivate existing archetype for (archetype *at = old_head; at; at = (archetype *)at->more) at->unlink (); - // reassemble new chain + // assemble new chain new_head->min_x = new_head->max_x = new_head->x; new_head->min_y = new_head->max_y = new_head->y; archetype *less = new_head; - archetype *head = 0; for (auto (p, parts.begin () + 1); p != parts.end (); ++p) { archetype *at = *p; @@ -457,8 +450,9 @@ if (at->x > new_head->max_x) new_head->max_x = at->x; if (at->y > new_head->max_y) new_head->max_y = at->y; - at->head = head; head = new_head; - less->more = at; less = at; + at->head = new_head; + less->more = at; + less = at; } // now activate it