- use texture IDs in the sprite animator

This commit is contained in:
Christoph Oelckers 2023-04-23 10:36:27 +02:00
parent cc83438e31
commit bfc8862071

View file

@ -187,21 +187,27 @@ void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAn
} }
k += action->offset + l * h->curframe; k += action->offset + l * h->curframe;
t->picnum += k; int texid = t->spritetexture().GetIndex() + k; // we cannot work with texture IDs here because their arithmetics are limited.
if (isRRRA() && RRRAFullbrightHack(t, k)) t->shade = -127; if (isRRRA() && RRRAFullbrightHack(t, k)) t->shade = -127;
FGameTexture* tex = TexMan.GameByIndex(texid);
if (l > 0) if (l > 0)
{ {
while (t->picnum >= 0 && t->picnum < MAXTILES && !tileGetTexture(t->picnum)->isValid()) while(1)
t->picnum -= l; //back up one frame if this one is invald. {
if (!tex || tex->isValid()) break;
texid -= l; //back up one frame if this one is invald.
tex = TexMan.GameByIndex(texid);
}
} }
if (t->picnum < 0 || t->picnum >= MAXTILES) if (!tex)
{ {
t->picnum = 0; t->setspritetexture(FNullTextureID());
t->scale = DVector2(0, 0); t->scale = DVector2(0, 0);
} }
else t->setspritetexture(tex->GetID());
if (h->dispictex.isValid()) if (h->dispictex.isValid())
h->dispictex = t->spritetexture(); h->dispictex = t->spritetexture();