- wrapped hiofs in a getter function.

This makes it a lot easier later to refactor.
This commit is contained in:
Christoph Oelckers 2022-12-07 15:57:28 +01:00
parent aa58b152ab
commit 0bacb05c1b
5 changed files with 30 additions and 17 deletions

View file

@ -205,10 +205,11 @@ void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVect
auto tex = TexMan.GetGameTexture(spr->spritetexture()); auto tex = TexMan.GetGameTexture(spr->spritetexture());
double width, xoffset; double width, xoffset;
if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) TileOffs* tofs;
if (render && hw_hightile && (tofs = GetHiresOffset(spr->spritetexture())))
{ {
width = TileFiles.tiledata[spr->picnum].hiofs.xsize; width = tofs->xsize;
xoffset = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset); xoffset = (tofs->xoffs + spr->xoffset);
} }
else else
{ {
@ -244,12 +245,13 @@ void TGetFlatSpritePosition(const spritetypebase* spr, const DVector2& pos, DVec
int xo = heinum ? 0 : spr->xoffset; int xo = heinum ? 0 : spr->xoffset;
int yo = heinum ? 0 : spr->yoffset; int yo = heinum ? 0 : spr->yoffset;
if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) TileOffs* tofs;
if (render && hw_hightile && (tofs = GetHiresOffset(spr->spritetexture())))
{ {
width = TileFiles.tiledata[spr->picnum].hiofs.xsize * xrepeat; width = tofs->xsize * xrepeat;
height = TileFiles.tiledata[spr->picnum].hiofs.ysize * yrepeat; height = tofs->ysize * yrepeat;
leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + xo) * xrepeat; leftofs = (tofs->xoffs + xo) * xrepeat;
topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + yo) * yrepeat; topofs = (tofs->yoffs + yo) * yrepeat;
} }
else else
{ {

View file

@ -343,15 +343,16 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int
if (modelframe == 0) if (modelframe == 0)
{ {
int flags = spr->cstat; int flags = spr->cstat;
int tilenum = spr->picnum;
int xsize, ysize, tilexoff, tileyoff; int xsize, ysize, tilexoff, tileyoff;
if (hw_hightile && TileFiles.tiledata[tilenum].hiofs.xsize) TileOffs* tofs;
if (hw_hightile && (tofs = GetHiresOffset(spr->spritetexture())))
{ {
xsize = TileFiles.tiledata[tilenum].hiofs.xsize; xsize = tofs->xsize;
ysize = TileFiles.tiledata[tilenum].hiofs.ysize; ysize = tofs->ysize;
tilexoff = TileFiles.tiledata[tilenum].hiofs.xoffs; tilexoff = tofs->xoffs;
tileyoff = TileFiles.tiledata[tilenum].hiofs.yoffs; tileyoff = tofs->yoffs;
} }
else else
{ {

View file

@ -1163,11 +1163,12 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, tspritetype* spr, sectortype* sec
SetSpriteTranslucency(Sprite, alpha, RenderStyle); SetSpriteTranslucency(Sprite, alpha, RenderStyle);
TileOffs* tofs;
int height, topofs; int height, topofs;
if (hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) if (hw_hightile && (tofs = GetHiresOffset(spr->spritetexture())))
{ {
height = TileFiles.tiledata[spr->picnum].hiofs.ysize; height = tofs->ysize;
topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + spr->yoffset); topofs = tofs->yoffs + spr->yoffset;
} }
else else
{ {

View file

@ -810,3 +810,11 @@ void walltype::setovertexture(FTextureID tex)
if (p) overpicnum = *p; if (p) overpicnum = *p;
else overpicnum = -1; // unlike the others this one can be invalid. else overpicnum = -1; // unlike the others this one can be invalid.
} }
TileOffs* GetHiresOffset(FTextureID tex)
{
// fixme: This must return nullptr if the tile has no replacement.
auto p = TileFiles.textotile.CheckKey(tex.GetIndex());
if (p && TileFiles.tiledata[*p].hiofs.xsize != 0) return &TileFiles.tiledata[*p].hiofs;
else return nullptr;
}

View file

@ -430,6 +430,7 @@ void tileUpdateAnimations();
const uint8_t* GetRawPixels(FTextureID texid); const uint8_t* GetRawPixels(FTextureID texid);
uint8_t* GetWritablePixels(FTextureID texid); uint8_t* GetWritablePixels(FTextureID texid);
void InvalidateTexture(FTextureID num); void InvalidateTexture(FTextureID num);
TileOffs* GetHiresOffset(FTextureID num);
class FGameTexture; class FGameTexture;
bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wantindexed = false); bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wantindexed = false);