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.26 by root, Fri Nov 17 19:40:53 2006 UTC vs.
Revision 1.32 by root, Mon Dec 25 11:25:49 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{
403 * of archetype-structures. 402 * of archetype-structures.
404 */ 403 */
405void 404void
406first_arch_pass (object_thawer & fp) 405first_arch_pass (object_thawer & fp)
407{ 406{
408 archetype *at, *head = NULL, *last_more = NULL; 407 archetype *head = 0, *last_more = 0;
409 408
409 archetype *at = new archetype;
410 at->clone.arch = first_archetype = at = new archetype; 410 at->clone.arch = first_archetype = at;
411 411
412 while (int i = load_object (fp, &at->clone, 0)) 412 while (int i = load_object (fp, &at->clone, 0))
413 { 413 {
414 at->clone.speed_left = (float) (-0.1); 414 at->clone.speed_left = (float) (-0.1);
415 /* copy the body_info to the body_used - this is only really 415 /* copy the body_info to the body_used - this is only really
589 589
590/* 590/*
591 * 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.
592 * This function returns NULL on failure. 592 * This function returns NULL on failure.
593 */ 593 */
594
595object * 594object *
596arch_to_object (archetype *at) 595arch_to_object (archetype *at)
597{ 596{
598 object *op; 597 object *op;
599 598
603 LOG (llevError, "Couldn't find archetype.\n"); 602 LOG (llevError, "Couldn't find archetype.\n");
604 603
605 return NULL; 604 return NULL;
606 } 605 }
607 606
608 op = get_object (); 607 op = at->clone.clone ();
609 copy_object (&at->clone, op);
610 op->arch = at; 608 op->arch = at;
611 op->instantiate (); 609 op->instantiate ();
612 return op; 610 return op;
613} 611}
614 612
616 * Creates an object. This function is called by get_archetype() 614 * Creates an object. This function is called by get_archetype()
617 * if it fails to find the appropriate archetype. 615 * if it fails to find the appropriate archetype.
618 * Thus get_archetype() will be guaranteed to always return 616 * Thus get_archetype() will be guaranteed to always return
619 * an object, and never NULL. 617 * an object, and never NULL.
620 */ 618 */
621
622object * 619object *
623create_singularity (const char *name) 620create_singularity (const char *name)
624{ 621{
625 object *op; 622 object *op;
626 char buf[MAX_BUF]; 623 char buf[MAX_BUF];
627 624
628 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 625 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name);
629 op = get_object (); 626 op = object::create ();
630 op->name = op->name_pl = buf; 627 op->name = op->name_pl = buf;
631 SET_FLAG (op, FLAG_NO_PICK); 628 SET_FLAG (op, FLAG_NO_PICK);
632 return op; 629 return op;
633} 630}
634 631
805 802
806object * 803object *
807clone_arch (int type) 804clone_arch (int type)
808{ 805{
809 archetype *at; 806 archetype *at;
810 object *op = get_object ();
811 807
812 if ((at = type_to_archetype (type)) == NULL) 808 if ((at = type_to_archetype (type)) == NULL)
813 { 809 {
814 LOG (llevError, "Can't clone archetype %d\n", type); 810 LOG (llevError, "Can't clone archetype %d\n", type);
815 free_object (op);
816 return NULL; 811 return 0;
817 } 812 }
818 813
819 copy_object (&at->clone, op); 814 object *op = at->clone.clone ();
820 op->instantiate (); 815 op->instantiate ();
821 return op; 816 return op;
822} 817}
823 818
824/* 819/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines