diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index e067971e5..6cda5fd9f 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -1326,27 +1326,8 @@ static int32_t defsparser(scriptfile *script) } break; case T_UNDEFPALOOKUPRANGE: - { - int32_t id0, id1; - - if (scriptfile_getsymbol(script,&id0)) - break; - if (scriptfile_getsymbol(script,&id1)) - break; - - if (id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS) - { - pos.Message(MSG_ERROR, "undefpalookuprange: Invalid range"); - break; - } - - for (bssize_t i = id0; i <= id1; i++) - lookups.clearTable(i); - - if (id0 == 0) - paletteloaded &= ~PALETTE_SHADE; - } - break; + parseUndefPalookupRange(*script, pos); + break; case T_RFFDEFINEID: parseRffDefineId(*script, pos); break; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index 41864dcd5..c8e677b44 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -1336,3 +1336,27 @@ void parseMakePalookup(FScanner& sc, FScriptPosition& pos) remappal == 0 ? 1 : (nofloorpal == -1 ? lookups.tables[remappal].noFloorPal : nofloorpal)); } } + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseUndefPalookupRange(FScanner& sc, FScriptPosition& pos) +{ + int id0, id1; + + if (!sc.GetNumber(id0, true)) return; + if (!sc.GetNumber(id1, true)) return; + + if (id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS) + { + pos.Message(MSG_ERROR, "undefpalookuprange: Invalid range"); + } + else + { + for (int i = id0; i <= id1; i++) lookups.clearTable(i); + if (id0 == 0) paletteloaded &= ~PALETTE_SHADE; + } +}