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 #ifdef USE_LIBVPX
uint16_t framenum = 0; uint16_t framenum = 0;
while (getrendermode() >= REND_POLYMOST) // if, really 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]; char vpxfn[BMAX_PATH];
Bstrncpyz(vpxfn, fn, BMAX_PATH); Bstrncpyz(vpxfn, fn, BMAX_PATH);
char *dot = Bstrrchr(vpxfn, '.'); ptrdiff_t dotpos = dot - fn;
if (!dot || (dot - vpxfn) + 4 >= BMAX_PATH) if (dotpos + 4 >= BMAX_PATH)
break; break;
dot[1] = 'i'; char *vpxfndot = vpxfn + dotpos;
dot[2] = 'v'; vpxfndot[1] = 'i';
dot[3] = 'f'; vpxfndot[2] = 'v';
dot[4] = 0; vpxfndot[3] = 'f';
vpxfndot[4] = '\0';
int32_t handle = kopen4loadfrommod(vpxfn, 0); handle = kopen4loadfrommod(vpxfn, 0);
if (handle == -1) if (handle == -1)
break; break;
anim = Anim_Find(vpxfn);
}
animvpx_ivf_header_t info; animvpx_ivf_header_t info;
i = animvpx_read_ivf_header(handle, &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... // after rendering the frame but before displaying: maybe play sound...
framenum++; framenum++;
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;
@ -312,6 +331,7 @@ int32_t Anim_Play(const char *fn)
soundidx++; 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!