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