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.27 by root, Sat Dec 9 14:01:12 2006 UTC vs.
Revision 1.33 by root, Sun Dec 31 17:17:22 2006 UTC

387 LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f); 387 LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f);
388} 388}
389 389
390archetype::archetype () 390archetype::archetype ()
391{ 391{
392 clear_object (&clone); /* to initial state other also */
393 CLEAR_FLAG (&clone, FLAG_FREED); /* This shouldn't matter, since copy_object() */ 392 CLEAR_FLAG (&clone, FLAG_FREED); /* This shouldn't matter, since copy_to */
394 SET_FLAG (&clone, FLAG_REMOVED); /* doesn't copy these flags... */ 393 SET_FLAG (&clone, FLAG_REMOVED); /* doesn't copy these flags... */
395} 394}
396 395
397archetype::~archetype () 396archetype::~archetype ()
398{ 397{
590 589
591/* 590/*
592 * Creates and returns a new object which is a copy of the given archetype. 591 * Creates and returns a new object which is a copy of the given archetype.
593 * This function returns NULL on failure. 592 * This function returns NULL on failure.
594 */ 593 */
595
596object * 594object *
597arch_to_object (archetype *at) 595arch_to_object (archetype *at)
598{ 596{
599 object *op; 597 object *op;
600 598
604 LOG (llevError, "Couldn't find archetype.\n"); 602 LOG (llevError, "Couldn't find archetype.\n");
605 603
606 return NULL; 604 return NULL;
607 } 605 }
608 606
609 op = get_object (); 607 op = at->clone.clone ();
610 copy_object (&at->clone, op);
611 op->arch = at; 608 op->arch = at;
612 op->instantiate (); 609 op->instantiate ();
613 return op; 610 return op;
614} 611}
615 612
617 * Creates an object. This function is called by get_archetype() 614 * Creates an object. This function is called by get_archetype()
618 * if it fails to find the appropriate archetype. 615 * if it fails to find the appropriate archetype.
619 * Thus get_archetype() will be guaranteed to always return 616 * Thus get_archetype() will be guaranteed to always return
620 * an object, and never NULL. 617 * an object, and never NULL.
621 */ 618 */
622
623object * 619object *
624create_singularity (const char *name) 620create_singularity (const char *name)
625{ 621{
626 object *op; 622 object *op;
627 char buf[MAX_BUF]; 623 char buf[MAX_BUF];
628 624
629 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 625 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name);
630 op = get_object (); 626 op = object::create ();
631 op->name = op->name_pl = buf; 627 op->name = op->name_pl = buf;
632 SET_FLAG (op, FLAG_NO_PICK); 628 SET_FLAG (op, FLAG_NO_PICK);
633 return op; 629 return op;
634} 630}
635 631
636/* 632/*
637 * Finds which archetype matches the given name, and returns a new 633 * Finds which archetype matches the given name, and returns a new
638 * object containing a copy of the archetype. 634 * object containing a copy of the archetype.
639 */ 635 */
640
641object * 636object *
642get_archetype (const char *name) 637get_archetype (const char *name)
643{ 638{
644 archetype *at = archetype::find (name); 639 archetype *at = archetype::find (name);
645 640
806 801
807object * 802object *
808clone_arch (int type) 803clone_arch (int type)
809{ 804{
810 archetype *at; 805 archetype *at;
811 object *op = get_object ();
812 806
813 if ((at = type_to_archetype (type)) == NULL) 807 if ((at = type_to_archetype (type)) == NULL)
814 { 808 {
815 LOG (llevError, "Can't clone archetype %d\n", type); 809 LOG (llevError, "Can't clone archetype %d\n", type);
816 free_object (op);
817 return NULL; 810 return 0;
818 } 811 }
819 812
820 copy_object (&at->clone, op); 813 object *op = at->clone.clone ();
821 op->instantiate (); 814 op->instantiate ();
822 return op; 815 return op;
823} 816}
824 817
825/* 818/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines