diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 0363971ff..020bb3ce8 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -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; } diff --git a/source/duke3d/src/anim.h b/source/duke3d/src/anim.h index 4ee395df2..ba85d8f05 100644 --- a/source/duke3d/src/anim.h +++ b/source/duke3d/src/anim.h @@ -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); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index b71eca4ba..224d9d058 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -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: