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.80 by root, Sun May 4 18:46:01 2008 UTC vs.
Revision 1.88 by root, Thu Jan 1 19:44:22 2009 UTC

258 retval = 6; 258 retval = 6;
259 /* base name matched - not bad */ 259 /* base name matched - not bad */
260 else if (strcasecmp (cp, op->name) == 0 && !count) 260 else if (strcasecmp (cp, op->name) == 0 && !count)
261 retval = 4; 261 retval = 4;
262 /* Check for partial custom name, but give a real low priority */ 262 /* Check for partial custom name, but give a real low priority */
263 else if (op->custom_name && strstr (op->custom_name, cp)) 263 else if (op->custom_name.contains (cp))
264 retval = 3; 264 retval = 3;
265 265
266 if (retval) 266 if (retval)
267 { 267 {
268 if (pl->type == PLAYER) 268 if (pl->type == PLAYER)
440 return new_head; 440 return new_head;
441 } 441 }
442 442
443fail: 443fail:
444 for (auto (p, parts.begin ()); p != parts.end (); ++p) 444 for (auto (p, parts.begin ()); p != parts.end (); ++p)
445 (*p)->destroy (true); 445 (*p)->destroy ();
446 446
447 return 0; 447 return 0;
448} 448}
449 449
450void 450void
510 510
511 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object 511 if (at->refcnt_cnt () > 1) // all arches have ONE refcount from their object
512 ++idx; 512 ++idx;
513 else 513 else
514 { 514 {
515 LOG (llevDebug, "garbage collect arch %s", at->debug_desc ()); 515 LOG (llevDebug, "garbage collect arch %s", &at->archname);
516 assert (at->arch == at); // verify that refcnt == 1 is truly valid 516 assert (at->arch == at); // verify that refcnt == 1 is truly valid
517 allarch.erase (idx); 517 allarch.erase (idx);
518 518
519 // break chain 519 // break chain
520 for (object *op = at->head_ (); op; ) 520 for (object *op = at->head_ (); op; )
530 } 530 }
531 } 531 }
532 while (--cnt); 532 while (--cnt);
533} 533}
534 534
535/*
536 * Creates and returns a new object which is a copy of the given archetype.
537 * This function returns NULL on failure.
538 */
539object *
540arch_to_object (archetype *at)
541{
542 if (!at)
543 {
544 LOG (llevError, "Couldn't find archetype.\n");
545 return 0;
546 }
547
548 return at->instance ();
549}
550
551object * 535object *
552archetype::instance () 536archetype::instance ()
553{ 537{
554 object *op = clone (); 538 object *op = clone ();
555 op->instantiate (); 539 op->instantiate ();
568 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name); 552 LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name);
569 553
570 if (!strcmp (name, "bug")) 554 if (!strcmp (name, "bug"))
571 abort (); 555 abort ();
572 556
573 object *op = archetype::get ("bug"); 557 object *op = archetype::get (shstr_bug);
574 op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name); 558 op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name);
575 559
576 return op; 560 return op;
577} 561}
578 562

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines