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.28 by root, Tue Dec 12 20:53:02 2006 UTC vs.
Revision 1.35 by root, Wed Jan 3 20:32:13 2007 UTC

118 * If type is -1, ew don't match on type. 118 * If type is -1, ew don't match on type.
119 */ 119 */
120object * 120object *
121get_archetype_by_skill_name (const char *skill, int type) 121get_archetype_by_skill_name (const char *skill, int type)
122{ 122{
123 archetype * 123 archetype *at;
124 at;
125 124
126 if (skill == NULL) 125 if (skill)
127 return NULL;
128
129 for (at = first_archetype; at != NULL; at = at->next) 126 for (at = first_archetype; at; at = at->next)
130 {
131 if (((type == -1) || (type == at->clone.type)) && (!strcmp (at->clone.skill, skill))) 127 if (((type == -1) || (type == at->clone.type)) && (!strcmp (at->clone.skill, skill)))
132 return arch_to_object (at); 128 return arch_to_object (at);
133 } 129
134 return NULL; 130 return 0;
135} 131}
136 132
137/* similiar to above - this returns the first archetype 133/* similiar to above - this returns the first archetype
138 * that matches both the type and subtype. type and subtype 134 * that matches both the type and subtype. type and subtype
139 * can be -1 to say ignore, but in this case, the match it does 135 * can be -1 to say ignore, but in this case, the match it does
179 for (i = strlen (tmpname); i > 0; i--) 175 for (i = strlen (tmpname); i > 0; i--)
180 { 176 {
181 tmpname[i] = 0; 177 tmpname[i] = 0;
182 at = find_archetype_by_object_name (tmpname); 178 at = find_archetype_by_object_name (tmpname);
183 179
184 if (at != NULL) 180 if (at)
185 return arch_to_object (at); 181 return arch_to_object (at);
186 } 182 }
187 183
188 return create_singularity (name); 184 return create_singularity (name);
189} 185}
387 LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f); 383 LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f);
388} 384}
389 385
390archetype::archetype () 386archetype::archetype ()
391{ 387{
392 clear_object (&clone); /* to initial state other also */
393 CLEAR_FLAG (&clone, FLAG_FREED); /* This shouldn't matter, since copy_object() */ 388 CLEAR_FLAG (&clone, FLAG_FREED); /* This shouldn't matter, since copy_to */
394 SET_FLAG (&clone, FLAG_REMOVED); /* doesn't copy these flags... */ 389 SET_FLAG (&clone, FLAG_REMOVED); /* doesn't copy these flags... */
395} 390}
396 391
397archetype::~archetype () 392archetype::~archetype ()
398{ 393{
576 object_thawer 571 object_thawer
577 thawer (filename); 572 thawer (filename);
578 573
579 LOG (llevDebug, " loading treasure...\n"); 574 LOG (llevDebug, " loading treasure...\n");
580 load_treasures (); 575 load_treasures ();
576 LOG (llevDebug, " done\n");
581 LOG (llevDebug, " done\n arch-pass 2...\n"); 577 LOG (llevDebug, " arch-pass 2...\n");
582 second_arch_pass (thawer); 578 second_arch_pass (thawer);
583 LOG (llevDebug, " done\n"); 579 LOG (llevDebug, " done\n");
584#ifdef DEBUG 580#ifdef DEBUG
585 check_generators (); 581 check_generators ();
586#endif 582#endif
590 586
591/* 587/*
592 * Creates and returns a new object which is a copy of the given archetype. 588 * Creates and returns a new object which is a copy of the given archetype.
593 * This function returns NULL on failure. 589 * This function returns NULL on failure.
594 */ 590 */
595
596object * 591object *
597arch_to_object (archetype *at) 592arch_to_object (archetype *at)
598{ 593{
599 object *op; 594 object *op;
600 595
604 LOG (llevError, "Couldn't find archetype.\n"); 599 LOG (llevError, "Couldn't find archetype.\n");
605 600
606 return NULL; 601 return NULL;
607 } 602 }
608 603
609 op = get_object (); 604 op = at->clone.clone ();
610 copy_object (&at->clone, op);
611 op->arch = at; 605 op->arch = at;
612 op->instantiate (); 606 op->instantiate ();
613 return op; 607 return op;
614} 608}
615 609
617 * Creates an object. This function is called by get_archetype() 611 * Creates an object. This function is called by get_archetype()
618 * if it fails to find the appropriate archetype. 612 * if it fails to find the appropriate archetype.
619 * Thus get_archetype() will be guaranteed to always return 613 * Thus get_archetype() will be guaranteed to always return
620 * an object, and never NULL. 614 * an object, and never NULL.
621 */ 615 */
622
623object * 616object *
624create_singularity (const char *name) 617create_singularity (const char *name)
625{ 618{
626 object *op; 619 object *op;
627 char buf[MAX_BUF]; 620 char buf[MAX_BUF];
628 621
629 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 622 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name);
630 op = get_object (); 623 op = object::create ();
631 op->name = op->name_pl = buf; 624 op->name = op->name_pl = buf;
632 SET_FLAG (op, FLAG_NO_PICK); 625 SET_FLAG (op, FLAG_NO_PICK);
633 return op; 626 return op;
634} 627}
635 628
636/* 629/*
637 * Finds which archetype matches the given name, and returns a new 630 * Finds which archetype matches the given name, and returns a new
638 * object containing a copy of the archetype. 631 * object containing a copy of the archetype.
639 */ 632 */
640
641object * 633object *
642get_archetype (const char *name) 634get_archetype (const char *name)
643{ 635{
644 archetype *at = archetype::find (name); 636 archetype *at = archetype::find (name);
645 637
806 798
807object * 799object *
808clone_arch (int type) 800clone_arch (int type)
809{ 801{
810 archetype *at; 802 archetype *at;
811 object *op = get_object ();
812 803
813 if ((at = type_to_archetype (type)) == NULL) 804 if ((at = type_to_archetype (type)) == NULL)
814 { 805 {
815 LOG (llevError, "Can't clone archetype %d\n", type); 806 LOG (llevError, "Can't clone archetype %d\n", type);
816 op->destroy (0);
817 return NULL; 807 return 0;
818 } 808 }
819 809
820 copy_object (&at->clone, op); 810 object *op = at->clone.clone ();
821 op->instantiate (); 811 op->instantiate ();
822 return op; 812 return op;
823} 813}
824 814
825/* 815/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines