1 | /* |
1 | /* |
2 | * static char *rcsid_anim_c = |
2 | * static char *rcsid_anim_c = |
3 | * "$Id: anim.C,v 1.5 2006/09/03 07:57:54 root Exp $"; |
3 | * "$Id: anim.C,v 1.6 2006/09/03 08:05:39 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 | |
… | |
… | |
58 | */ |
58 | */ |
59 | /* set the name so we don't try to dereferance null. |
59 | /* set the name so we don't try to dereferance null. |
60 | * Put # at start so it will be first in alphabetical |
60 | * Put # at start so it will be first in alphabetical |
61 | * order. |
61 | * order. |
62 | */ |
62 | */ |
|
|
63 | { |
|
|
64 | Animations anim0; |
|
|
65 | |
63 | animations[0].name = "###none"; |
66 | anim0.name = "###none"; |
64 | animations[0].num_animations=1; |
67 | anim0.num_animations=1; |
65 | animations[0].faces = (Fontindex *) malloc(sizeof(Fontindex)); |
68 | anim0.faces = (Fontindex *) malloc(sizeof(Fontindex)); |
66 | animations[0].faces[0]=0; |
69 | anim0.faces[0]=0; |
67 | animations[0].facings=0; |
70 | anim0.facings=0; |
|
|
71 | |
|
|
72 | animations.push_back (anim0); |
|
|
73 | } |
68 | |
74 | |
69 | sprintf(buf,"%s/animations", settings.datadir); |
75 | sprintf(buf,"%s/animations", settings.datadir); |
70 | LOG(llevDebug,"Reading animations from %s...", buf); |
76 | LOG(llevDebug,"Reading animations from %s...", buf); |
71 | if ((fp=fopen(buf,"r")) ==NULL) { |
77 | if ((fp=fopen(buf,"r")) ==NULL) { |
72 | LOG(llevError, "Cannot open animations file %s: %s\n", buf, strerror(errno)); |
78 | LOG(llevError, "Cannot open animations file %s: %s\n", buf, strerror(errno)); |
… | |
… | |
81 | LOG(llevError,"Didn't get a mina before %s\n", buf); |
87 | LOG(llevError,"Didn't get a mina before %s\n", buf); |
82 | num_frames=0; |
88 | num_frames=0; |
83 | } |
89 | } |
84 | num_animations++; |
90 | num_animations++; |
85 | |
91 | |
86 | Animations &anim = animations.at (num_animations); |
92 | Animations anim; |
87 | anim.name = buf + 5; |
93 | anim.name = buf + 5; |
88 | anim.num = num_animations; /* for bsearch */ |
94 | anim.num = num_animations; /* for bsearch */ |
89 | anim.facings = 1; |
95 | anim.facings = 1; |
|
|
96 | animations.push_back (anim); |
90 | } |
97 | } |
91 | else if (!strncmp(buf,"mina",4)) { |
98 | else if (!strncmp(buf,"mina",4)) { |
92 | animations[num_animations].faces = (Fontindex *) malloc(sizeof(Fontindex)*num_frames); |
99 | animations[num_animations].faces = (Fontindex *) malloc(sizeof(Fontindex)*num_frames); |
93 | for (i=0; i<num_frames; i++) |
100 | for (i=0; i<num_frames; i++) |
94 | animations[num_animations].faces[i]=faces[i]; |
101 | animations[num_animations].faces[i]=faces[i]; |