1 | /* |
1 | /* |
2 | * static char *rcsid_anim_c = |
2 | * static char *rcsid_anim_c = |
3 | * "$Id: anim.C,v 1.4 2006/09/03 00:18:39 root Exp $"; |
3 | * "$Id: anim.C,v 1.5 2006/09/03 07:57:54 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 | |
… | |
… | |
81 | LOG(llevError,"Didn't get a mina before %s\n", buf); |
81 | LOG(llevError,"Didn't get a mina before %s\n", buf); |
82 | num_frames=0; |
82 | num_frames=0; |
83 | } |
83 | } |
84 | num_animations++; |
84 | num_animations++; |
85 | |
85 | |
86 | animations.resize (num_animations + 1); |
86 | Animations &anim = animations.at (num_animations); |
87 | animations[num_animations].name = buf + 5; |
87 | anim.name = buf + 5; |
88 | animations[num_animations].num = num_animations; /* for bsearch */ |
88 | anim.num = num_animations; /* for bsearch */ |
89 | animations[num_animations].facings = 1; |
89 | anim.facings = 1; |
90 | } |
90 | } |
91 | else if (!strncmp(buf,"mina",4)) { |
91 | else if (!strncmp(buf,"mina",4)) { |
92 | animations[num_animations].faces = (Fontindex *) malloc(sizeof(Fontindex)*num_frames); |
92 | animations[num_animations].faces = (Fontindex *) malloc(sizeof(Fontindex)*num_frames); |
93 | for (i=0; i<num_frames; i++) |
93 | for (i=0; i<num_frames; i++) |
94 | animations[num_animations].faces[i]=faces[i]; |
94 | animations[num_animations].faces[i]=faces[i]; |
… | |
… | |
127 | { |
127 | { |
128 | Animations search, *match; |
128 | Animations search, *match; |
129 | |
129 | |
130 | search.name = name; |
130 | search.name = name; |
131 | |
131 | |
132 | match = (Animations*)bsearch(&search, animations, (num_animations+1), |
132 | match = (Animations*)bsearch(&search, &animations [0], (num_animations+1), |
133 | sizeof(Animations), (int (*)(const void*, const void*))anim_compare); |
133 | sizeof(Animations), (int (*)(const void*, const void*))anim_compare); |
134 | |
134 | |
135 | |
135 | |
136 | if (match) return match->num; |
136 | if (match) return match->num; |
137 | LOG(llevError,"Unable to find animation %s\n", name); |
137 | LOG(llevError,"Unable to find animation %s\n", name); |