--- deliantra/server/common/arch.C 2007/06/04 13:04:00 1.63 +++ deliantra/server/common/arch.C 2007/06/07 18:55:24 1.65 @@ -159,23 +159,23 @@ return create_singularity (name); } - /* This is a subset of the parse_id command. Basically, name can be - * a string seperated lists of things to match, with certain keywords. - * pl is the player (only needed to set count properly) - * op is the item we are trying to match. Calling function takes care - * of what action might need to be done and if it is valid - * (pickup, drop, etc.) Return NONZERO if we have a match. A higher - * value means a better match. 0 means no match. - * - * Brief outline of the procedure: - * We take apart the name variable into the individual components. - * cases for 'all' and unpaid are pretty obvious. - * Next, we check for a count (either specified in name, or in the - * player object.) - * If count is 1, make a quick check on the name. - * IF count is >1, we need to make plural name. Return if match. - * Last, make a check on the full name. - */ +/* This is a subset of the parse_id command. Basically, name can be + * a string seperated lists of things to match, with certain keywords. + * pl is the player (only needed to set count properly) + * op is the item we are trying to match. Calling function takes care + * of what action might need to be done and if it is valid + * (pickup, drop, etc.) Return NONZERO if we have a match. A higher + * value means a better match. 0 means no match. + * + * Brief outline of the procedure: + * We take apart the name variable into the individual components. + * cases for 'all' and unpaid are pretty obvious. + * Next, we check for a count (either specified in name, or in the + * player object.) + * If count is 1, make a quick check on the name. + * IF count is >1, we need to make plural name. Return if match. + * Last, make a check on the full name. + */ int item_matched_string (object *pl, object *op, const char *name) { @@ -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 @@ -522,13 +516,17 @@ object * create_singularity (const char *name) { - object *op; + LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name); + + if (!strcmp (name, "bug")) + abort (); + char buf[MAX_BUF]; + sprintf (buf, "bug, please report (%s)", ARCH_SINGULARITY, name); - sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); - op = object::create (); + object *op = get_archetype ("bug"); op->name = op->name_pl = buf; - SET_FLAG (op, FLAG_NO_PICK); + return op; }