Fixed crash with the getchannellevel QC builtin

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5508 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Eukara 2019-08-11 05:34:37 +00:00
parent 93a9fe379a
commit e7726fe42f

View file

@ -3143,7 +3143,10 @@ float S_GetChannelLevel(int entnum, int entchannel)
if (sc->channel[i].entnum == entnum && sc->channel[i].entchannel == entchannel && sc->channel[i].sfx) if (sc->channel[i].entnum == entnum && sc->channel[i].entchannel == entchannel && sc->channel[i].sfx)
{ {
ssamplepos_t spos = sc->GetChannelPos?sc->GetChannelPos(sc, &sc->channel[i]):(sc->channel[i].pos>>PITCHSHIFT); ssamplepos_t spos = sc->GetChannelPos?sc->GetChannelPos(sc, &sc->channel[i]):(sc->channel[i].pos>>PITCHSHIFT);
scache = sc->channel[i].sfx->decoder.decodedata(sc->channel[i].sfx, &scachebuf, spos, 1); if (sc->channel[i].sfx->decoder.decodedata)scache = sc->channel[i].sfx->decoder.decodedata(sc->channel[i].sfx, &scachebuf, spos, 1);
else
scache = NULL;
if (!scache) if (!scache)
scache = sc->channel[i].sfx->decoder.buf; scache = sc->channel[i].sfx->decoder.buf;
if (scache && spos >= scache->soundoffset && spos < scache->soundoffset+scache->length) if (scache && spos >= scache->soundoffset && spos < scache->soundoffset+scache->length)