diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 582458de2..f3c9397e9 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -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; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index 9251ddcbc..4ab405826 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -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); +}