When playing an IVF upgraded from an ANM and no sound list has been defined for the IVF, use the ANM's sound list by converting framerates.

git-svn-id: https://svn.eduke32.com/eduke32@6287 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-25 11:24:43 +00:00
parent 35b3cea5a6
commit 10d478eba8

View file

@ -239,6 +239,7 @@ int32_t Anim_Play(const char *fn)
if (!dot) if (!dot)
break; break;
dukeanim_t const * origanim = anim;
int32_t handle = -1; int32_t handle = -1;
if (!Bstrcmp(dot, ".ivf")) if (!Bstrcmp(dot, ".ivf"))
{ {
@ -289,7 +290,11 @@ int32_t Anim_Play(const char *fn)
return 0; return 0;
} }
uint32_t msecsperframe = ((uint64_t)info.fpsdenom * 1000) / info.fpsnumer;
uint32_t const convnumer = 120 * info.fpsdenom;
uint32_t const convdenom = info.fpsnumer * origanim->framedelay;
uint32_t const msecsperframe = scale(info.fpsdenom, 1000, info.fpsnumer);
uint32_t nextframetime = getticks(); uint32_t nextframetime = getticks();
uint8_t *pic; uint8_t *pic;
@ -321,7 +326,7 @@ int32_t Anim_Play(const char *fn)
framenum++; framenum++;
if (anim) if (anim)
{ {
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == framenum) while (soundidx < anim->numsounds && anim->sounds[soundidx].frame <= framenum)
{ {
int16_t sound = anim->sounds[soundidx].sound; int16_t sound = anim->sounds[soundidx].sound;
if (sound == -1) if (sound == -1)
@ -332,6 +337,20 @@ int32_t Anim_Play(const char *fn)
soundidx++; soundidx++;
} }
} }
else
{
uint16_t convframenum = scale(framenum, convnumer, convdenom);
while (soundidx < origanim->numsounds && origanim->sounds[soundidx].frame <= convframenum)
{
int16_t sound = origanim->sounds[soundidx].sound;
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
soundidx++;
}
}
// this and showframe() instead of nextpage() are so that // this and showframe() instead of nextpage() are so that
// nobody tramples on our carefully set up GL state! // nobody tramples on our carefully set up GL state!
@ -463,7 +482,7 @@ int32_t Anim_Play(const char *fn)
ototalclock += anim->framedelay; ototalclock += anim->framedelay;
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == (uint16_t)i) while (soundidx < anim->numsounds && anim->sounds[soundidx].frame <= (uint16_t)i)
{ {
int16_t sound = anim->sounds[soundidx].sound; int16_t sound = anim->sounds[soundidx].sound;
if (sound == -1) if (sound == -1)