From d193e199f1c678983f5b97e2a4936613128335bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Apr 2021 15:55:33 +0200 Subject: [PATCH] - reorganized hightile offset storage. --- source/build/src/defs.cpp | 32 ++++++++-------------- source/build/src/polymost.cpp | 10 +++---- source/core/gamefuncs.cpp | 16 +++++------ source/core/rendering/scene/hw_sprites.cpp | 10 +++---- source/core/rendering/scene/hw_walls.cpp | 6 ++-- source/core/textures/buildtiles.cpp | 2 +- source/core/textures/buildtiles.h | 8 ++++-- 7 files changed, 40 insertions(+), 44 deletions(-) diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index cf253152e..f11d366a3 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -617,38 +617,30 @@ static int32_t defsparser(scriptfile *script) if (check_tile("setuptile", tile, script, pos)) break; auto& tiled = TileFiles.tiledata[tile]; - if (scriptfile_getsymbol(script,&tmp)) break; // XXX - tiled.h_xsize = tmp; - if (scriptfile_getsymbol(script,&tmp)) break; - tiled.h_ysize = tmp; - if (scriptfile_getsymbol(script,&tmp)) break; - tiled.h_xoffs = tmp; - if (scriptfile_getsymbol(script,&tmp)) break; - tiled.h_yoffs = tmp; + if (scriptfile_getsymbol(script,&tiled.hiofs.xsize)) break; // XXX + if (scriptfile_getsymbol(script, &tiled.hiofs.ysize)) break; + if (scriptfile_getsymbol(script, &tiled.hiofs.xoffs)) break; + if (scriptfile_getsymbol(script, &tiled.hiofs.yoffs)) break; break; } case T_SETUPTILERANGE: { - int tile1,tile2,xsiz,ysiz,xoffs,yoffs,i; + int tile1,tile2; + TileOffs t; if (scriptfile_getsymbol(script,&tile1)) break; if (scriptfile_getsymbol(script,&tile2)) break; - if (scriptfile_getnumber(script,&xsiz)) break; - if (scriptfile_getnumber(script,&ysiz)) break; - if (scriptfile_getsymbol(script,&xoffs)) break; - if (scriptfile_getsymbol(script,&yoffs)) break; + if (scriptfile_getnumber(script,&t.xsize)) break; + if (scriptfile_getnumber(script,&t.ysize)) break; + if (scriptfile_getsymbol(script,&t.xoffs)) break; + if (scriptfile_getsymbol(script,&t.yoffs)) break; if (check_tile_range("setuptilerange", &tile1, &tile2, script, pos)) break; - for (i=tile1; i<=tile2; i++) + for (int i=tile1; i<=tile2; i++) { - auto& tiled = TileFiles.tiledata[i]; - - tiled.h_xsize = xsiz; - tiled.h_ysize = ysiz; - tiled.h_xoffs = xoffs; - tiled.h_yoffs = yoffs; + TileFiles.tiledata[i].hiofs = t; } break; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 31a4198e4..44423429a 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -2722,9 +2722,9 @@ void polymost_drawsprite(int32_t snum) if ((globalorientation & 48) != 48) // only non-voxel sprites should do this { - int const flag = hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize; - off = { (int32_t)tspr->xoffset + (flag ? TileFiles.tiledata[globalpicnum].h_xoffs : tileLeftOffset(globalpicnum)), - (int32_t)tspr->yoffset + (flag ? TileFiles.tiledata[globalpicnum].h_yoffs : tileTopOffset(globalpicnum)) }; + int const flag = hw_hightile && TileFiles.tiledata[globalpicnum].hiofs.xsize; + off = { (int32_t)tspr->xoffset + (flag ? TileFiles.tiledata[globalpicnum].hiofs.xoffs : tileLeftOffset(globalpicnum)), + (int32_t)tspr->yoffset + (flag ? TileFiles.tiledata[globalpicnum].hiofs.yoffs : tileTopOffset(globalpicnum)) }; } int32_t method = DAMETH_MASK | DAMETH_CLAMPED; @@ -2784,8 +2784,8 @@ void polymost_drawsprite(int32_t snum) vec2_t tsiz; - if (hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize) - tsiz = { TileFiles.tiledata[globalpicnum].h_xsize, TileFiles.tiledata[globalpicnum].h_ysize }; + if (hw_hightile && TileFiles.tiledata[globalpicnum].hiofs.xsize) + tsiz = { TileFiles.tiledata[globalpicnum].hiofs.xsize, TileFiles.tiledata[globalpicnum].hiofs.ysize }; else tsiz = { tileWidth(globalpicnum), tileHeight(globalpicnum) }; diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index c8bd0d41b..23191157e 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -191,10 +191,10 @@ void GetWallSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool auto tex = tileGetTexture(spr->picnum); int width, leftofs; - if (render && hw_hightile && TileFiles.tiledata[spr->picnum].h_xsize) + if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) { - width = TileFiles.tiledata[spr->picnum].h_xsize; - leftofs = (TileFiles.tiledata[spr->picnum].h_xoffs + spr->xoffset); + width = TileFiles.tiledata[spr->picnum].hiofs.xsize; + leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset); } else { @@ -227,12 +227,12 @@ void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool auto tex = tileGetTexture(spr->picnum); int width, height, leftofs, topofs; - if (render && hw_hightile && TileFiles.tiledata[spr->picnum].h_xsize) + if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) { - width = TileFiles.tiledata[spr->picnum].h_xsize * spr->xrepeat; - height = TileFiles.tiledata[spr->picnum].h_ysize * spr->yrepeat; - leftofs = (TileFiles.tiledata[spr->picnum].h_xoffs + spr->xoffset) * spr->xrepeat; - topofs = (TileFiles.tiledata[spr->picnum].h_yoffs + spr->yoffset) * spr->yrepeat; + width = TileFiles.tiledata[spr->picnum].hiofs.xsize * spr->xrepeat; + height = TileFiles.tiledata[spr->picnum].hiofs.ysize * spr->yrepeat; + leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset) * spr->xrepeat; + topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + spr->yoffset) * spr->yrepeat; } else { diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index b555fdd92..1637c1854 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -376,12 +376,12 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int int tilenum = spr->picnum; int xsize, ysize, tilexoff, tileyoff; - if (hw_hightile && TileFiles.tiledata[tilenum].h_xsize) + if (hw_hightile && TileFiles.tiledata[tilenum].hiofs.xsize) { - xsize = TileFiles.tiledata[tilenum].h_xsize; - ysize = TileFiles.tiledata[tilenum].h_ysize; - tilexoff = TileFiles.tiledata[tilenum].h_xoffs; - tileyoff = TileFiles.tiledata[tilenum].h_yoffs; + xsize = TileFiles.tiledata[tilenum].hiofs.xsize; + ysize = TileFiles.tiledata[tilenum].hiofs.ysize; + tilexoff = TileFiles.tiledata[tilenum].hiofs.xoffs; + tileyoff = TileFiles.tiledata[tilenum].hiofs.yoffs; } else { diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index d21e7d911..673c2c726 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -1104,10 +1104,10 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect int height, topofs; - if (hw_hightile && TileFiles.tiledata[spr->picnum].h_xsize) + if (hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) { - height = TileFiles.tiledata[spr->picnum].h_ysize; - topofs = (TileFiles.tiledata[spr->picnum].h_yoffs + spr->yoffset); + height = TileFiles.tiledata[spr->picnum].hiofs.ysize; + topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + spr->yoffset); } else { diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index cbddedbdb..2148b27a7 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -145,7 +145,7 @@ void BuildTiles::Init() tile.RotTile = { -1,-1 }; tile.replacement = ReplacementType::Art; tile.alphaThreshold = 0.5; - tile.h_xsize = 0; + tile.hiofs = {}; } } diff --git a/source/core/textures/buildtiles.h b/source/core/textures/buildtiles.h index c875f7084..d0d9d9cc8 100644 --- a/source/core/textures/buildtiles.h +++ b/source/core/textures/buildtiles.h @@ -256,6 +256,11 @@ struct RawCacheNode uint64_t lastUseTime; }; +struct TileOffs +{ + int xsize, ysize, xoffs, yoffs; +}; + struct TileDesc { FGameTexture* texture; // the currently active tile @@ -268,8 +273,7 @@ struct TileDesc float alphaThreshold; // Sprite offset hackery for hires replacements. This only gets used for sprites in the 3D view, nothing else. - uint16_t h_xsize, h_ysize; - int8_t h_xoffs, h_yoffs; + TileOffs hiofs; };