- parseArtFile.

This commit is contained in:
Christoph Oelckers 2021-04-13 18:17:04 +02:00
parent 2761ced670
commit 97637e4d2d
2 changed files with 34 additions and 39 deletions

View file

@ -368,44 +368,8 @@ static int32_t defsparser(scriptfile *script)
parseNoFloorpalRange(*script, pos);
break;
case T_ARTFILE:
{
FScanner::SavedPos blockend;
FString fn;
int32_t tile = -1, havetile = 0;
static const tokenlist artfiletokens[] =
{
{ "file", T_FILE },
{ "tile", T_TILE },
};
if (scriptfile_getbraces(script,&blockend)) break;
while (!scriptfile_endofblock(script, blockend))
{
int32_t token = getatoken(script,artfiletokens,countof(artfiletokens));
switch (token)
{
case T_FILE:
scriptfile_getstring(script,&fn);
break;
case T_TILE:
havetile = 1;
scriptfile_getsymbol(script,&tile);
break;
default:
break;
}
}
if (fn.IsEmpty())
{
pos.Message(MSG_ERROR, "missing 'file name' for artfile definition");
break;
}
if (!check_tile("artfile", tile, script, pos))
TileFiles.LoadArtFile(fn, nullptr, tile);
}
break;
parseArtFile(*script, pos);
break;
case T_SETUPTILE:
parseSetupTile(*script, pos);
break;

View file

@ -675,7 +675,10 @@ void parseEmptyBlock(FScanner& sc, FScriptPosition& pos)
FScanner::SavedPos blockend;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend)) {}
while (!sc.FoundEndBrace(blockend))
{
sc.MustGetString();
}
}
//===========================================================================
@ -718,3 +721,31 @@ void parseNoFullbrightRange(FScanner& sc, FScriptPosition& pos)
if (tex->isValid()) tex->SetDisableBrightmap();
}
}
//===========================================================================
//
//
//
//===========================================================================
void parseArtFile(FScanner& sc, FScriptPosition& pos)
{
FScanner::SavedPos blockend;
FString file;
int tile = -1;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))
{
sc.MustGetString();
if (sc.Compare("file")) sc.GetString(file);
else if (sc.Compare("tile")) sc.GetNumber(tile, true);
}
if (file.IsEmpty())
{
pos.Message(MSG_ERROR, "missing 'file name' for artfile definition");
}
else if (tile >= 0 && ValidateTilenum("artfile", tile, pos))
TileFiles.LoadArtFile(file, nullptr, tile);
}