Game defs: Split Anim_Create out of Anim_Setup and use it for the cutscene token.

git-svn-id: https://svn.eduke32.com/eduke32@6280 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-25 11:24:10 +00:00
parent 7226eb346d
commit aebd4c53c4
3 changed files with 28 additions and 22 deletions

View file

@ -63,20 +63,20 @@ dukeanim_t *Anim_Find(const char *s)
return (dukeanim_t *)(ptr == -1 ? NULL : (dukeanim_t *)ptr);
}
dukeanim_t * Anim_Setup(const char *fn, uint8_t fdelay, void (*sound_func)(int32_t))
dukeanim_t * Anim_Create(char const * fn)
{
dukeanim_t * anim = Anim_Find(fn);
if (!anim)
anim = (dukeanim_t *)Xcalloc(1, sizeof(dukeanim_t));
dukeanim_t * anim = (dukeanim_t *)Xcalloc(1, sizeof(dukeanim_t));
hash_add(&h_dukeanim, fn, (intptr_t)anim, 0);
if (sound_func)
anim->sound_func = sound_func;
return anim;
}
static dukeanim_t * Anim_Setup(const char *fn, uint8_t fdelay, void (*sound_func)(int32_t))
{
dukeanim_t * anim = Anim_Create(fn);
anim->framedelay = fdelay;
anim->sound_func = sound_func;
return anim;
}

View file

@ -38,7 +38,7 @@ typedef struct
extern dukeanim_t * g_animPtr;
extern hashtable_t h_dukeanim;
extern dukeanim_t * Anim_Find(const char *s);
extern dukeanim_t * Anim_Setup(const char *fn, uint8_t framerate, void (*sound_func)(int32_t));
extern dukeanim_t * Anim_Create(const char *fn);
int32_t Anim_Play(const char *fn);
void Anim_Init(void);

View file

@ -5206,25 +5206,31 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
if (scriptfile_getbraces(pScript, &animEnd))
break;
int32_t frameDelay = 10;
while (pScript->textptr < animEnd)
{
switch (getatoken(pScript, animTokens, ARRAY_SIZE(animTokens)))
{
case T_DELAY: scriptfile_getnumber(pScript, &frameDelay); break;
}
}
if (!firstPass)
{
dukeanim_t *animPtr = Anim_Find(fileName);
if (!animPtr)
animPtr = Anim_Setup(fileName, frameDelay, NULL);
else
animPtr->framedelay = frameDelay;
{
animPtr = Anim_Create(fileName);
animPtr->framedelay = 10;
}
int32_t temp;
while (pScript->textptr < animEnd)
{
switch (getatoken(pScript, animTokens, ARRAY_SIZE(animTokens)))
{
case T_DELAY:
scriptfile_getnumber(pScript, &temp);
animPtr->framedelay = temp;
break;
}
}
}
else
pScript->textptr = animEnd;
}
break;
case T_ANIMSOUNDS: