If an ANM is upgraded to an IVF, use the sounds defined for the .ivf if any have been.

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

View file

@ -234,23 +234,40 @@ int32_t Anim_Play(const char *fn)
#ifdef USE_LIBVPX
uint16_t framenum = 0;
while (getrendermode() >= REND_POLYMOST) // if, really
{
char *dot = Bstrrchr(fn, '.');
if (!dot)
break;
int32_t handle = -1;
if (!Bstrcmp(dot, ".ivf"))
{
handle = kopen4loadfrommod(fn, 0);
if (handle == -1)
break;
}
else
{
char vpxfn[BMAX_PATH];
Bstrncpyz(vpxfn, fn, BMAX_PATH);
char *dot = Bstrrchr(vpxfn, '.');
if (!dot || (dot - vpxfn) + 4 >= BMAX_PATH)
ptrdiff_t dotpos = dot - fn;
if (dotpos + 4 >= BMAX_PATH)
break;
dot[1] = 'i';
dot[2] = 'v';
dot[3] = 'f';
dot[4] = 0;
char *vpxfndot = vpxfn + dotpos;
vpxfndot[1] = 'i';
vpxfndot[2] = 'v';
vpxfndot[3] = 'f';
vpxfndot[4] = '\0';
int32_t handle = kopen4loadfrommod(vpxfn, 0);
handle = kopen4loadfrommod(vpxfn, 0);
if (handle == -1)
break;
anim = Anim_Find(vpxfn);
}
animvpx_ivf_header_t info;
i = animvpx_read_ivf_header(handle, &info);
@ -302,6 +319,8 @@ int32_t Anim_Play(const char *fn)
// after rendering the frame but before displaying: maybe play sound...
framenum++;
if (anim)
{
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == framenum)
{
int16_t sound = anim->sounds[soundidx].sound;
@ -312,6 +331,7 @@ int32_t Anim_Play(const char *fn)
soundidx++;
}
}
// this and showframe() instead of nextpage() are so that
// nobody tramples on our carefully set up GL state!