- reinstated setuptile.

Apparently this is needed by some hires packs to fudge the sprite offsets.
Fortunately, setting sprite offsets is the only thing this was ever used for so it's relatively uninvasive.
This commit is contained in:
Christoph Oelckers 2020-09-23 16:54:52 +02:00
parent 8690c633d8
commit 5a76dce5f8
4 changed files with 59 additions and 4 deletions

View file

@ -605,6 +605,50 @@ static int32_t defsparser(scriptfile *script)
TileFiles.LoadArtFile(fn, nullptr, tile); TileFiles.LoadArtFile(fn, nullptr, tile);
} }
break; break;
case T_SETUPTILE:
{
int tile, tmp;
if (scriptfile_getsymbol(script,&tile)) break;
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;
break;
}
case T_SETUPTILERANGE:
{
int tile1,tile2,xsiz,ysiz,xoffs,yoffs,i;
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 (check_tile_range("setuptilerange", &tile1, &tile2, script, pos))
break;
for (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;
}
break;
}
case T_ANIMTILERANGE: case T_ANIMTILERANGE:
{ {
SetAnim set; SetAnim set;

View file

@ -3053,8 +3053,9 @@ void polymost_drawsprite(int32_t snum)
if ((globalorientation & 48) != 48) // only non-voxel sprites should do this if ((globalorientation & 48) != 48) // only non-voxel sprites should do this
{ {
off = { (int32_t)tspr->xoffset + (tileLeftOffset(globalpicnum)), int const flag = hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize;
(int32_t)tspr->yoffset + (tileTopOffset(globalpicnum)) }; 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)) };
} }
int32_t method = DAMETH_MASK | DAMETH_CLAMPED; int32_t method = DAMETH_MASK | DAMETH_CLAMPED;
@ -3110,8 +3111,12 @@ void polymost_drawsprite(int32_t snum)
pos.y -= (sintable[(tspr->ang) & 2047] >> 13); pos.y -= (sintable[(tspr->ang) & 2047] >> 13);
} }
vec2_16_t const oldsiz = tilesiz[globalpicnum]; vec2_t tsiz;
vec2_t tsiz = { oldsiz.x, oldsiz.y };
if (hw_hightile && TileFiles.tiledata[globalpicnum].h_xsize)
tsiz = { TileFiles.tiledata[globalpicnum].h_xsize, TileFiles.tiledata[globalpicnum].h_ysize };
else
tsiz = { tileWidth(globalpicnum), tileHeight(globalpicnum) };
if (tsiz.x <= 0 || tsiz.y <= 0) if (tsiz.x <= 0 || tsiz.y <= 0)
return; return;

View file

@ -140,6 +140,7 @@ void BuildTiles::Init()
tile.RotTile = { -1,-1 }; tile.RotTile = { -1,-1 };
tile.replacement = ReplacementType::Art; tile.replacement = ReplacementType::Art;
tile.alphaThreshold = 0.5; tile.alphaThreshold = 0.5;
tile.h_xsize = 0;
} }
} }

View file

@ -274,6 +274,11 @@ struct TileDesc
TArray<HightileReplacement> Hightiles; TArray<HightileReplacement> Hightiles;
ReplacementType replacement; ReplacementType replacement;
float alphaThreshold; 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;
}; };
struct TexturePick struct TexturePick