ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/arch.C
(Generate patch)

Comparing deliantra/server/common/arch.C (file contents):
Revision 1.63 by root, Mon Jun 4 13:04:00 2007 UTC vs.
Revision 1.65 by root, Thu Jun 7 18:55:24 2007 UTC

157 } 157 }
158 158
159 return create_singularity (name); 159 return create_singularity (name);
160} 160}
161 161
162 /* This is a subset of the parse_id command. Basically, name can be 162/* This is a subset of the parse_id command. Basically, name can be
163 * a string seperated lists of things to match, with certain keywords. 163 * a string seperated lists of things to match, with certain keywords.
164 * pl is the player (only needed to set count properly) 164 * pl is the player (only needed to set count properly)
165 * op is the item we are trying to match. Calling function takes care 165 * op is the item we are trying to match. Calling function takes care
166 * of what action might need to be done and if it is valid 166 * of what action might need to be done and if it is valid
167 * (pickup, drop, etc.) Return NONZERO if we have a match. A higher 167 * (pickup, drop, etc.) Return NONZERO if we have a match. A higher
168 * value means a better match. 0 means no match. 168 * value means a better match. 0 means no match.
169 * 169 *
170 * Brief outline of the procedure: 170 * Brief outline of the procedure:
171 * We take apart the name variable into the individual components. 171 * We take apart the name variable into the individual components.
172 * cases for 'all' and unpaid are pretty obvious. 172 * cases for 'all' and unpaid are pretty obvious.
173 * Next, we check for a count (either specified in name, or in the 173 * Next, we check for a count (either specified in name, or in the
174 * player object.) 174 * player object.)
175 * If count is 1, make a quick check on the name. 175 * If count is 1, make a quick check on the name.
176 * IF count is >1, we need to make plural name. Return if match. 176 * IF count is >1, we need to make plural name. Return if match.
177 * Last, make a check on the full name. 177 * Last, make a check on the full name.
178 */ 178 */
179int 179int
180item_matched_string (object *pl, object *op, const char *name) 180item_matched_string (object *pl, object *op, const char *name)
181{ 181{
182 char *cp, local_name[MAX_BUF]; 182 char *cp, local_name[MAX_BUF];
183 int count, retval = 0; 183 int count, retval = 0;
300 300
301void 301void
302archetype::unlink () 302archetype::unlink ()
303{ 303{
304 ht.erase (archname); 304 ht.erase (archname);
305 305 if (!strcmp (&archname, "Gaea")) fprintf (stderr, "oI\n");//D
306 if (archetypes.contains (this)) 306 if (archetypes.contains (this))
307 archetypes.erase (this); 307 archetypes.erase (this);
308} 308}
309 309
310/* 310/*
334 name = "(null)"; 334 name = "(null)";
335 } 335 }
336 336
337 archetype *at = find (name); 337 archetype *at = find (name);
338 338
339 if (loading_arch && at && !at->stub) 339 if (!at)
340 {
341 at->unlink ();
342 at = 0;
343 }
344
345 if (!at || (!at->stub && loading_arch))
346 { 340 {
347 at = new archetype (name); 341 at = new archetype (name);
348 at->link (); 342 at->link ();
349 } 343 }
350 344
415 auto (at, parts.begin ()); 409 auto (at, parts.begin ());
416 410
417 archetype *new_head = parts.front (); 411 archetype *new_head = parts.front ();
418 archetype *old_head = find (new_head->archname); 412 archetype *old_head = find (new_head->archname);
419 413
420 for (auto (at, parts.begin ()); at != parts.end (); ++at) 414 if (old_head && !old_head->is_head ())
421 fprintf (stderr, "%d: %s\n", at - parts.begin(), &(*at)->archname);//D 415 {
416 LOG (llevError, "%s: unable to overwrite non-head archetype '%s' with head archetype, skipping.\n",
417 &new_head->archname, &old_head->archname);
418 goto fail;
419 }
422 420
423 // check that all archetypes belong to the same old object or are new 421 // check that all archetypes belong to the same old object or are new
424 for (auto (at, parts.begin ()); at != parts.end (); ++at) 422 for (auto (at, parts.begin ()); at != parts.end (); ++at)
425 { 423 {
426 archetype *new_part = *at; 424 archetype *new_part = *at;
427 archetype *old_part = find (new_part->archname); 425 archetype *old_part = find (new_part->archname);
428 426
429 if (old_part && old_part->head_ () != old_head) 427 if (old_part && old_part->head_ () != old_head)
430 { 428 {
431 fprintf (stderr, "nhn %s\n", &new_head->archname);//D
432 fprintf (stderr, "old_head %p,%p new_head %p,%p ph %p\n", old_head, old_part, new_head, new_part, old_part->head_());
433 LOG (llevError, "%s: unable to overwrite archetype '%s' with archetype of different object, skipping.\n", 429 LOG (llevError, "%s: unable to overwrite archetype '%s' with archetype of different object, skipping.\n",
434 &new_part->archname, &((archetype *)old_part->head_ ())->archname); 430 &new_part->archname, &((archetype *)old_part->head_ ())->archname);
435 goto fail; 431 goto fail;
436 } 432 }
437 } 433 }
438 434
439 fprintf (stderr, "oh %p %s\n", old_head, &new_head->archname);//D
440
441 // deactivate existing archetype 435 // deactivate existing archetype
442 for (archetype *at = old_head; at; at = (archetype *)at->more) 436 for (archetype *at = old_head; at; at = (archetype *)at->more)
443 at->unlink (); 437 at->unlink ();
444 438
445 // reassemble new chain 439 // assemble new chain
446 new_head->min_x = new_head->max_x = new_head->x; 440 new_head->min_x = new_head->max_x = new_head->x;
447 new_head->min_y = new_head->max_y = new_head->y; 441 new_head->min_y = new_head->max_y = new_head->y;
448 442
449 archetype *less = new_head; 443 archetype *less = new_head;
450 archetype *head = 0;
451 for (auto (p, parts.begin () + 1); p != parts.end (); ++p) 444 for (auto (p, parts.begin () + 1); p != parts.end (); ++p)
452 { 445 {
453 archetype *at = *p; 446 archetype *at = *p;
454 447
455 if (at->x < new_head->min_x) new_head->min_x = at->x; 448 if (at->x < new_head->min_x) new_head->min_x = at->x;
456 if (at->y < new_head->min_y) new_head->min_y = at->y; 449 if (at->y < new_head->min_y) new_head->min_y = at->y;
457 if (at->x > new_head->max_x) new_head->max_x = at->x; 450 if (at->x > new_head->max_x) new_head->max_x = at->x;
458 if (at->y > new_head->max_y) new_head->max_y = at->y; 451 if (at->y > new_head->max_y) new_head->max_y = at->y;
459 452
460 at->head = head; head = new_head; 453 at->head = new_head;
461 less->more = at; less = at; 454 less->more = at;
455 less = at;
462 } 456 }
463 457
464 // now activate it 458 // now activate it
465 for (auto (p, parts.begin ()); p != parts.end (); ++p) 459 for (auto (p, parts.begin ()); p != parts.end (); ++p)
466 { 460 {
520 * an object, and never NULL. 514 * an object, and never NULL.
521 */ 515 */
522object * 516object *
523create_singularity (const char *name) 517create_singularity (const char *name)
524{ 518{
525 object *op; 519 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name);
520
521 if (!strcmp (name, "bug"))
522 abort ();
523
526 char buf[MAX_BUF]; 524 char buf[MAX_BUF];
527
528 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 525 sprintf (buf, "bug, please report (%s)", ARCH_SINGULARITY, name);
529 op = object::create (); 526
527 object *op = get_archetype ("bug");
530 op->name = op->name_pl = buf; 528 op->name = op->name_pl = buf;
531 SET_FLAG (op, FLAG_NO_PICK); 529
532 return op; 530 return op;
533} 531}
534 532
535/* 533/*
536 * Finds which archetype matches the given name, and returns a new 534 * Finds which archetype matches the given name, and returns a new

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines