1 | /* |
1 | /* |
2 | * static char *rcsid_arch_c = |
2 | * static char *rcsid_arch_c = |
3 | * "$Id: arch.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; |
3 | * "$Id: arch.C,v 1.5 2006/08/28 14:05:23 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
28 | |
28 | |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <arch.h> |
30 | #include <arch.h> |
31 | #include <funcpoint.h> |
31 | #include <funcpoint.h> |
32 | #include <loader.h> |
32 | #include <loader.h> |
|
|
33 | |
|
|
34 | #include <cassert> |
33 | |
35 | |
34 | /* IF set, does a little timing on the archetype load. */ |
36 | /* IF set, does a little timing on the archetype load. */ |
35 | #define TIME_ARCH_LOAD 0 |
37 | #define TIME_ARCH_LOAD 0 |
36 | |
38 | |
37 | static void add_arch(archetype *at); |
39 | static void add_arch(archetype *at); |
… | |
… | |
397 | |
399 | |
398 | /* |
400 | /* |
399 | * Reads/parses the archetype-file, and copies into a linked list |
401 | * Reads/parses the archetype-file, and copies into a linked list |
400 | * of archetype-structures. |
402 | * of archetype-structures. |
401 | */ |
403 | */ |
402 | void first_arch_pass(FILE *fp) { |
404 | void first_arch_pass(object_thawer &fp) { |
403 | object *op; |
405 | object *op; |
404 | archetype *at,*head=NULL,*last_more=NULL; |
406 | archetype *at,*head=NULL,*last_more=NULL; |
405 | int i,first=2; |
407 | int i,first=2; |
406 | |
408 | |
407 | op=get_object(); |
409 | op=get_object(); |
… | |
… | |
544 | clear_archetable(); |
546 | clear_archetable(); |
545 | LOG(llevDebug," arch-pass 1...\n"); |
547 | LOG(llevDebug," arch-pass 1...\n"); |
546 | #if TIME_ARCH_LOAD |
548 | #if TIME_ARCH_LOAD |
547 | GETTIMEOFDAY(&tv1); |
549 | GETTIMEOFDAY(&tv1); |
548 | #endif |
550 | #endif |
|
|
551 | { |
|
|
552 | object_thawer thawer (fp); |
549 | first_arch_pass(fp); |
553 | first_arch_pass (thawer); |
|
|
554 | } |
550 | #if TIME_ARCH_LOAD |
555 | #if TIME_ARCH_LOAD |
551 | { int sec, usec; |
556 | { int sec, usec; |
552 | GETTIMEOFDAY(&tv2); |
557 | GETTIMEOFDAY(&tv2); |
553 | sec = tv2.tv_sec - tv1.tv_sec; |
558 | sec = tv2.tv_sec - tv1.tv_sec; |
554 | usec = tv2.tv_usec - tv1.tv_usec; |
559 | usec = tv2.tv_usec - tv1.tv_usec; |
… | |
… | |
591 | LOG(llevError,"Couldn't find archetype.\n"); |
596 | LOG(llevError,"Couldn't find archetype.\n"); |
592 | return NULL; |
597 | return NULL; |
593 | } |
598 | } |
594 | op=get_object(); |
599 | op=get_object(); |
595 | copy_object(&at->clone,op); |
600 | copy_object(&at->clone,op); |
|
|
601 | op->instantiate (); |
596 | op->arch=at; |
602 | op->arch=at; |
597 | return op; |
603 | return op; |
598 | } |
604 | } |
599 | |
605 | |
600 | /* |
606 | /* |
… | |
… | |
729 | LOG(llevError,"Can't clone archetype %d\n",type); |
735 | LOG(llevError,"Can't clone archetype %d\n",type); |
730 | free_object(op); |
736 | free_object(op); |
731 | return NULL; |
737 | return NULL; |
732 | } |
738 | } |
733 | copy_object(&at->clone,op); |
739 | copy_object(&at->clone,op); |
|
|
740 | op->instantiate (); |
734 | return op; |
741 | return op; |
735 | } |
742 | } |
736 | |
743 | |
737 | /* |
744 | /* |
738 | * member: make instance from class |
745 | * member: make instance from class |