diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 0ed7faeb5..99beccbb3 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -17,6 +17,7 @@ #include "gamecontrol.h" #include "palettecontainer.h" #include "mapinfo.h" +#include "parsefuncs.h" int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags); int tileSetSkybox(int picnum, int palnum, const char** facenames, int flags); @@ -655,15 +656,9 @@ static int32_t defsparser(scriptfile *script) break; } case T_ANIMTILERANGE: - { - SetAnim set; - if (scriptfile_getsymbol(script,&set.tile1)) break; - if (scriptfile_getsymbol(script,&set.tile2)) break; - if (scriptfile_getsymbol(script,&set.speed)) break; - if (scriptfile_getsymbol(script,&set.type)) break; - processSetAnim("animtilerange", pos, set); + parseAnimTileRange(*script, pos); break; - } + case T_TILEFROMTEXTURE: { auto texturepos = scriptfile_getposition(script); diff --git a/source/common/engine/sc_man.h b/source/common/engine/sc_man.h index 6c37806a8..3a894fcb3 100644 --- a/source/common/engine/sc_man.h +++ b/source/common/engine/sc_man.h @@ -113,6 +113,13 @@ public: void MustGetNumber(bool evaluate = false); bool CheckNumber(bool evaluate = false); + bool GetNumber(int& var, bool evaluate = false) + { + if (!GetNumber(evaluate)) return false; + var = Number; + return true; + } + bool GetFloat(bool evaluate = false); void MustGetFloat(bool evaluate = false); bool CheckFloat(bool evaluate = false); diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h new file mode 100644 index 000000000..05b3aa87b --- /dev/null +++ b/source/core/parsefuncs.h @@ -0,0 +1,48 @@ + +/* +** parsefuncs.h +** handlers for .def parser +** only to be included by the actual parser +** +**--------------------------------------------------------------------------- +** Copyright 2021 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + + +void parseAnimTileRange(FScanner& sc, FScriptPosition& pos) +{ + SetAnim set; + if (!sc.GetNumber(set.tile1, true)) return; + if (!sc.GetNumber(set.tile2, true)) return; + if (!sc.GetNumber(set.speed, true)) return; + if (!sc.GetNumber(set.type, true)) return; + processSetAnim("animtilerange", pos, set); +} +