Skip to content

Commit

Permalink
Defs: Implement ifmatch subtoken for voxel token
Browse files Browse the repository at this point in the history
Note that due to the nature of the voxel token, this subtoken must appear
*before* any tile subtokens in order to take effect.

Fixes terminx/eduke32#305
  • Loading branch information
Hendricks266 committed Jun 4, 2024
1 parent b674881 commit 30deaa5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions source/build/src/defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,9 +1941,11 @@ static int32_t defsparser(scriptfile *script)
char *voxeltokptr = script->ltextptr;
char *fn, *voxelend;
int32_t tile0 = MAXTILES, tile1 = -1, tilex = -1;
TileMatchChecker matcher;

static const tokenlist voxeltokens[] =
{
{ "ifmatch", T_IFMATCH },
{ "tile", T_TILE },
{ "tile0", T_TILE0 },
{ "tile1", T_TILE1 },
Expand Down Expand Up @@ -1981,12 +1983,19 @@ static int32_t defsparser(scriptfile *script)
{
switch (getatoken(script, voxeltokens, ARRAY_SIZE(voxeltokens)))
{
case T_IFMATCH:
matcher.parse_ifmatch(script);
break;

case T_TILE:
scriptfile_getsymbol(script,&tilex);

if (check_tile("voxel", tilex, script, voxeltokptr))
break;

if (matcher.is_different("voxel", tilex))
break;

tiletovox[tilex] = lastvoxid;

break;
Expand All @@ -2002,7 +2011,12 @@ static int32_t defsparser(scriptfile *script)
break;

for (tilex=tile0; tilex<=tile1; tilex++)
{
if (matcher.is_different("voxel", tilex))
continue;

tiletovox[tilex] = lastvoxid;
}

break;

Expand Down

0 comments on commit 30deaa5

Please sign in to comment.