… | |
… | |
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 | |
390 | archetype::archetype () |
390 | archetype::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 | |
397 | archetype::~archetype () |
396 | archetype::~archetype () |
398 | { |
397 | { |
… | |
… | |
576 | object_thawer |
575 | object_thawer |
577 | thawer (filename); |
576 | thawer (filename); |
578 | |
577 | |
579 | LOG (llevDebug, " loading treasure...\n"); |
578 | LOG (llevDebug, " loading treasure...\n"); |
580 | load_treasures (); |
579 | load_treasures (); |
|
|
580 | LOG (llevDebug, " done\n"); |
581 | LOG (llevDebug, " done\n arch-pass 2...\n"); |
581 | LOG (llevDebug, " arch-pass 2...\n"); |
582 | second_arch_pass (thawer); |
582 | second_arch_pass (thawer); |
583 | LOG (llevDebug, " done\n"); |
583 | LOG (llevDebug, " done\n"); |
584 | #ifdef DEBUG |
584 | #ifdef DEBUG |
585 | check_generators (); |
585 | check_generators (); |
586 | #endif |
586 | #endif |
… | |
… | |
590 | |
590 | |
591 | /* |
591 | /* |
592 | * Creates and returns a new object which is a copy of the given archetype. |
592 | * Creates and returns a new object which is a copy of the given archetype. |
593 | * This function returns NULL on failure. |
593 | * This function returns NULL on failure. |
594 | */ |
594 | */ |
595 | |
|
|
596 | object * |
595 | object * |
597 | arch_to_object (archetype *at) |
596 | arch_to_object (archetype *at) |
598 | { |
597 | { |
599 | object *op; |
598 | object *op; |
600 | |
599 | |
… | |
… | |
604 | LOG (llevError, "Couldn't find archetype.\n"); |
603 | LOG (llevError, "Couldn't find archetype.\n"); |
605 | |
604 | |
606 | return NULL; |
605 | return NULL; |
607 | } |
606 | } |
608 | |
607 | |
609 | op = get_object (); |
608 | op = at->clone.clone (); |
610 | copy_object (&at->clone, op); |
|
|
611 | op->arch = at; |
609 | op->arch = at; |
612 | op->instantiate (); |
610 | op->instantiate (); |
613 | return op; |
611 | return op; |
614 | } |
612 | } |
615 | |
613 | |
… | |
… | |
617 | * Creates an object. This function is called by get_archetype() |
615 | * Creates an object. This function is called by get_archetype() |
618 | * if it fails to find the appropriate archetype. |
616 | * if it fails to find the appropriate archetype. |
619 | * Thus get_archetype() will be guaranteed to always return |
617 | * Thus get_archetype() will be guaranteed to always return |
620 | * an object, and never NULL. |
618 | * an object, and never NULL. |
621 | */ |
619 | */ |
622 | |
|
|
623 | object * |
620 | object * |
624 | create_singularity (const char *name) |
621 | create_singularity (const char *name) |
625 | { |
622 | { |
626 | object *op; |
623 | object *op; |
627 | char buf[MAX_BUF]; |
624 | char buf[MAX_BUF]; |
628 | |
625 | |
629 | sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); |
626 | sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); |
630 | op = get_object (); |
627 | op = object::create (); |
631 | op->name = op->name_pl = buf; |
628 | op->name = op->name_pl = buf; |
632 | SET_FLAG (op, FLAG_NO_PICK); |
629 | SET_FLAG (op, FLAG_NO_PICK); |
633 | return op; |
630 | return op; |
634 | } |
631 | } |
635 | |
632 | |
636 | /* |
633 | /* |
637 | * Finds which archetype matches the given name, and returns a new |
634 | * Finds which archetype matches the given name, and returns a new |
638 | * object containing a copy of the archetype. |
635 | * object containing a copy of the archetype. |
639 | */ |
636 | */ |
640 | |
|
|
641 | object * |
637 | object * |
642 | get_archetype (const char *name) |
638 | get_archetype (const char *name) |
643 | { |
639 | { |
644 | archetype *at = archetype::find (name); |
640 | archetype *at = archetype::find (name); |
645 | |
641 | |
… | |
… | |
806 | |
802 | |
807 | object * |
803 | object * |
808 | clone_arch (int type) |
804 | clone_arch (int type) |
809 | { |
805 | { |
810 | archetype *at; |
806 | archetype *at; |
811 | object *op = get_object (); |
|
|
812 | |
807 | |
813 | if ((at = type_to_archetype (type)) == NULL) |
808 | if ((at = type_to_archetype (type)) == NULL) |
814 | { |
809 | { |
815 | LOG (llevError, "Can't clone archetype %d\n", type); |
810 | LOG (llevError, "Can't clone archetype %d\n", type); |
816 | op->destroy (0); |
|
|
817 | return NULL; |
811 | return 0; |
818 | } |
812 | } |
819 | |
813 | |
820 | copy_object (&at->clone, op); |
814 | object *op = at->clone.clone (); |
821 | op->instantiate (); |
815 | op->instantiate (); |
822 | return op; |
816 | return op; |
823 | } |
817 | } |
824 | |
818 | |
825 | /* |
819 | /* |