Updates to the processing of the tilefromtexture def command:

- Allow xoffset and yoffset to modified independently of a tile definition, much like texhitscan and nofullbright.
(Both still default to zero when a tile is specified, to keep current behavior, and because it makes sense.)
- Add actual detection of the "nofullbright" keyword, which appears to have been overlooked in r3230.
- Internal: Eliminate the need for one int32_t by condensing two variables into "flags".

git-svn-id: https://svn.eduke32.com/eduke32@3973 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2013-07-20 03:37:10 +00:00
parent 62cdb8a9e6
commit af9a451f02

View file

@ -541,9 +541,9 @@ static int32_t defsparser(scriptfile *script)
case T_TILEFROMTEXTURE: case T_TILEFROMTEXTURE:
{ {
char *texturetokptr = script->ltextptr, *textureend, *fn = NULL; char *texturetokptr = script->ltextptr, *textureend, *fn = NULL;
int32_t tile=-1; int32_t tile = -1;
int32_t alphacut = 255, texhitscan=0, nofullbright=0; int32_t alphacut = 255, flags = 0;
int32_t xoffset = 0, yoffset = 0; int32_t xoffset = ~0, yoffset = ~0;
static const tokenlist tilefromtexturetokens[] = static const tokenlist tilefromtexturetokens[] =
{ {
@ -574,7 +574,10 @@ static int32_t defsparser(scriptfile *script)
case T_YOFFSET: case T_YOFFSET:
scriptfile_getsymbol(script,&yoffset); break; scriptfile_getsymbol(script,&yoffset); break;
case T_TEXHITSCAN: case T_TEXHITSCAN:
texhitscan = 1; flags |= PICANM_TEXHITSCAN_BIT;
break;
case T_NOFULLBRIGHT:
flags |= PICANM_NOFULLBRIGHT_BIT;
break; break;
default: default:
break; break;
@ -590,13 +593,14 @@ static int32_t defsparser(scriptfile *script)
if (!fn) if (!fn)
{ {
// filefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data // tilefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data
if (texhitscan) picanm[tile].sf |= flags;
picanm[tile].sf |= PICANM_TEXHITSCAN_BIT; if (xoffset != ~0)
if (nofullbright) picanm[tile].xofs = clamp(xoffset, -128, 127);
picanm[tile].sf |= PICANM_NOFULLBRIGHT_BIT; if (yoffset != ~0)
picanm[tile].yofs = clamp(yoffset, -128, 127);
if (!texhitscan && !nofullbright) if (flags == 0 && xoffset == ~0 && yoffset == ~0)
initprintf("\nError: missing 'file name' for tilefromtexture definition near line %s:%d", initprintf("\nError: missing 'file name' for tilefromtexture definition near line %s:%d",
script->filename, scriptfile_getlinum(script,texturetokptr)); script->filename, scriptfile_getlinum(script,texturetokptr));
break; break;
@ -621,12 +625,9 @@ static int32_t defsparser(scriptfile *script)
break; break;
set_tilesiz(tile, xsiz, ysiz); set_tilesiz(tile, xsiz, ysiz);
picanm[tile].xofs = clamp(xoffset, -128, 127); picanm[tile].xofs = (xoffset == ~0) ? 0 : clamp(xoffset, -128, 127);
picanm[tile].yofs = clamp(yoffset, -128, 127); picanm[tile].yofs = (yoffset == ~0) ? 0 : clamp(yoffset, -128, 127);
if (texhitscan) picanm[tile].sf |= flags;
picanm[tile].sf |= PICANM_TEXHITSCAN_BIT;
if (nofullbright)
picanm[tile].sf |= PICANM_NOFULLBRIGHT_BIT;
tile_from_truecolpic(tile, picptr, alphacut); tile_from_truecolpic(tile, picptr, alphacut);