From c713850dac208fcf27ced07643b1a5e9d5cbe182 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Apr 2020 13:46:15 +0200 Subject: [PATCH] - moved sc_man and palettecontainer to the 'common' folder. --- src/CMakeLists.txt | 14 +++---- .../engine}/palettecontainer.cpp | 0 .../engine}/palettecontainer.h | 0 src/{utility => common/engine}/printf.h | 0 src/{utility => common/engine}/sc_man.cpp | 22 ++++++----- src/{utility => common/engine}/sc_man.h | 37 ++++++++++++++++++- .../engine}/sc_man_scanner.re | 0 .../engine}/sc_man_tokens.h | 0 src/common/utility/engineerrors.cpp | 5 +-- src/common/utility/m_alloc.cpp | 2 +- src/common/utility/memarena.cpp | 1 - src/doomtype.h | 31 ---------------- src/g_cvars.cpp | 5 ++- src/scripting/backend/vmbuilder.cpp | 6 ++- src/scripting/decorate/thingdef_parse.cpp | 2 +- src/scripting/symbols.h | 1 + src/scripting/thingdef.cpp | 3 +- src/sound/s_environment.cpp | 1 + 18 files changed, 71 insertions(+), 59 deletions(-) rename src/{utility => common/engine}/palettecontainer.cpp (100%) rename src/{utility => common/engine}/palettecontainer.h (100%) rename src/{utility => common/engine}/printf.h (100%) rename src/{utility => common/engine}/sc_man.cpp (98%) rename src/{utility => common/engine}/sc_man.h (76%) rename src/{utility => common/engine}/sc_man_scanner.re (100%) rename src/{utility => common/engine}/sc_man_tokens.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d0151c37..d3f723836 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -570,8 +570,8 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.c ${CMAKE_CURRE DEPENDS lemon ${CMAKE_CURRENT_SOURCE_DIR}/scripting/zscript/zcc-parse.lemon ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h - COMMAND re2c --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/utility/sc_man_scanner.re - DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/utility/sc_man_scanner.re ) + COMMAND re2c --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/common/engine/sc_man_scanner.re + DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/common/engine/sc_man_scanner.re ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) @@ -725,7 +725,7 @@ set( NOT_COMPILED_SOURCE_FILES ${SWRENDER_SOURCES} ${POLYRENDER_SOURCES} sc_man_scanner.h - utility/sc_man_scanner.re + common/engine/sc_man_scanner.re g_statusbar/sbarinfo_commands.cpp gamedata/xlat/xlat_parser.y xlat_parser.c @@ -1110,7 +1110,6 @@ set (PCH_SOURCES rendering/swrenderer/textures/warptexture.cpp rendering/swrenderer/textures/swcanvastexture.cpp events.cpp - utility/palettecontainer.cpp common/thirdparty/sfmt/SFMT.cpp common/utility/engineerrors.cpp common/utility/i_module.cpp @@ -1141,6 +1140,8 @@ set (PCH_SOURCES common/filesystem/file_whres.cpp common/filesystem/file_directory.cpp common/filesystem/resourcefile.cpp + common/engine/sc_man.cpp + common/engine/palettecontainer.cpp utility/m_png.cpp utility/m_random.cpp @@ -1150,7 +1151,6 @@ set (PCH_SOURCES utility/nodebuilder/nodebuild_extract.cpp utility/nodebuilder/nodebuild_gl.cpp utility/nodebuilder/nodebuild_utility.cpp - utility/sc_man.cpp utility/stats.cpp utility/m_bbox.cpp utility/v_collection.cpp @@ -1203,7 +1203,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE set_source_files_properties( ${FASTMATH_SOURCES} PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} ) set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" ) -set_source_files_properties( utility/sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) +set_source_files_properties( common/engine/sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) @@ -1436,4 +1436,4 @@ source_group("Utility\\Node Builder" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE source_group("Statusbar" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_statusbar/.+") source_group("Versioning" FILES version.h win32/zdoom.rc) source_group("Xlat" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/xlat/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h) -source_group("Source Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h utility/sc_man_scanner.re) +source_group("Source Files" FILES ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h common/engine/sc_man_scanner.re) diff --git a/src/utility/palettecontainer.cpp b/src/common/engine/palettecontainer.cpp similarity index 100% rename from src/utility/palettecontainer.cpp rename to src/common/engine/palettecontainer.cpp diff --git a/src/utility/palettecontainer.h b/src/common/engine/palettecontainer.h similarity index 100% rename from src/utility/palettecontainer.h rename to src/common/engine/palettecontainer.h diff --git a/src/utility/printf.h b/src/common/engine/printf.h similarity index 100% rename from src/utility/printf.h rename to src/common/engine/printf.h diff --git a/src/utility/sc_man.cpp b/src/common/engine/sc_man.cpp similarity index 98% rename from src/utility/sc_man.cpp rename to src/common/engine/sc_man.cpp index 4cf4f258b..af5d5d1c2 100644 --- a/src/utility/sc_man.cpp +++ b/src/common/engine/sc_man.cpp @@ -37,14 +37,17 @@ #include #include -#include "doomtype.h" #include "engineerrors.h" #include "sc_man.h" -#include "filesystem.h" #include "cmdlib.h" #include "templates.h" -#include "doomstat.h" +#include "printf.h" +#include "name.h" #include "v_text.h" +#include "templates.h" +#include "zstring.h" +#include "name.h" +#include "filesystem.h" // MACROS ------------------------------------------------------------------ @@ -1127,6 +1130,7 @@ void FScanner::CheckOpen() //========================================================================== int FScriptPosition::ErrorCounter; int FScriptPosition::WarnCounter; +int FScriptPosition::Developer; bool FScriptPosition::StrictErrors; // makes all OPTERROR messages real errors. bool FScriptPosition::errorout; // call I_Error instead of printing the error itself. @@ -1156,19 +1160,17 @@ FScriptPosition &FScriptPosition::operator=(FScanner &sc) // //========================================================================== -CVAR(Bool, strictdecorate, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) - void FScriptPosition::Message (int severity, const char *message, ...) const { FString composed; - if (severity == MSG_DEBUGLOG && developer < DMSG_NOTIFY) return; - if (severity == MSG_DEBUGERROR && developer < DMSG_ERROR) return; - if (severity == MSG_DEBUGWARN && developer < DMSG_WARNING) return; - if (severity == MSG_DEBUGMSG && developer < DMSG_NOTIFY) return; + if (severity == MSG_DEBUGLOG && Developer < DMSG_NOTIFY) return; + if (severity == MSG_DEBUGERROR && Developer < DMSG_ERROR) return; + if (severity == MSG_DEBUGWARN && Developer < DMSG_WARNING) return; + if (severity == MSG_DEBUGMSG && Developer < DMSG_NOTIFY) return; if (severity == MSG_OPTERROR) { - severity = StrictErrors || strictdecorate ? MSG_ERROR : MSG_WARNING; + severity = StrictErrors? MSG_ERROR : MSG_WARNING; } // This is mainly for catching the error with an exception handler. if (severity == MSG_ERROR && errorout) severity = MSG_FATAL; diff --git a/src/utility/sc_man.h b/src/common/engine/sc_man.h similarity index 76% rename from src/utility/sc_man.h rename to src/common/engine/sc_man.h index 908089b8e..684482e6c 100644 --- a/src/utility/sc_man.h +++ b/src/common/engine/sc_man.h @@ -1,7 +1,41 @@ #ifndef __SC_MAN_H__ #define __SC_MAN_H__ -#include "doomtype.h" +#include "zstring.h" +#include "name.h" +#include "basics.h" + +struct VersionInfo +{ + uint16_t major; + uint16_t minor; + uint32_t revision; + + bool operator <=(const VersionInfo& o) const + { + return o.major > this->major || (o.major == this->major && o.minor > this->minor) || (o.major == this->major && o.minor == this->minor && o.revision >= this->revision); + } + bool operator >=(const VersionInfo& o) const + { + return o.major < this->major || (o.major == this->major && o.minor < this->minor) || (o.major == this->major && o.minor == this->minor && o.revision <= this->revision); + } + bool operator > (const VersionInfo& o) const + { + return o.major < this->major || (o.major == this->major && o.minor < this->minor) || (o.major == this->major && o.minor == this->minor && o.revision < this->revision); + } + bool operator < (const VersionInfo& o) const + { + return o.major > this->major || (o.major == this->major && o.minor > this->minor) || (o.major == this->major && o.minor == this->minor && o.revision > this->revision); + } + void operator=(const char* string); +}; + +// Cannot be a constructor because Lemon would puke on it. +inline VersionInfo MakeVersion(unsigned int ma, unsigned int mi, unsigned int re = 0) +{ + return{ (uint16_t)ma, (uint16_t)mi, (uint32_t)re }; +} + class FScanner { @@ -164,6 +198,7 @@ struct FScriptPosition static int WarnCounter; static int ErrorCounter; static bool StrictErrors; + static int Developer; static bool errorout; FName FileName; int ScriptLine; diff --git a/src/utility/sc_man_scanner.re b/src/common/engine/sc_man_scanner.re similarity index 100% rename from src/utility/sc_man_scanner.re rename to src/common/engine/sc_man_scanner.re diff --git a/src/utility/sc_man_tokens.h b/src/common/engine/sc_man_tokens.h similarity index 100% rename from src/utility/sc_man_tokens.h rename to src/common/engine/sc_man_tokens.h diff --git a/src/common/utility/engineerrors.cpp b/src/common/utility/engineerrors.cpp index d15917761..ccc459f72 100644 --- a/src/common/utility/engineerrors.cpp +++ b/src/common/utility/engineerrors.cpp @@ -53,7 +53,6 @@ void I_DebugPrint(const char *cp) #endif #include "engineerrors.h" -#include "printf.h" //========================================================================== // @@ -70,7 +69,7 @@ void I_Error(const char *error, ...) char errortext[MAX_ERRORTEXT]; va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); va_end(argptr); I_DebugPrint(errortext); @@ -97,7 +96,7 @@ void I_FatalError(const char *error, ...) char errortext[MAX_ERRORTEXT]; va_list argptr; va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); va_end(argptr); I_DebugPrint(errortext); diff --git a/src/common/utility/m_alloc.cpp b/src/common/utility/m_alloc.cpp index 755e7b1b5..8e3b89ab6 100644 --- a/src/common/utility/m_alloc.cpp +++ b/src/common/utility/m_alloc.cpp @@ -44,7 +44,7 @@ #include #endif -#include "printf.h" +#include "engineerrors.h" #include "m_alloc.h" #ifndef _MSC_VER diff --git a/src/common/utility/memarena.cpp b/src/common/utility/memarena.cpp index c586a42c4..0e2be24ba 100644 --- a/src/common/utility/memarena.cpp +++ b/src/common/utility/memarena.cpp @@ -39,7 +39,6 @@ #include "basics.h" #include "memarena.h" -#include "printf.h" #include "cmdlib.h" #include "m_alloc.h" diff --git a/src/doomtype.h b/src/doomtype.h index ca7ce498f..cabd3f5be 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -102,37 +102,6 @@ public: }; -struct VersionInfo -{ - uint16_t major; - uint16_t minor; - uint32_t revision; - - bool operator <=(const VersionInfo &o) const - { - return o.major > this->major || (o.major == this->major && o.minor > this->minor) || (o.major == this->major && o.minor == this->minor && o.revision >= this->revision); - } - bool operator >=(const VersionInfo &o) const - { - return o.major < this->major || (o.major == this->major && o.minor < this->minor) || (o.major == this->major && o.minor == this->minor && o.revision <= this->revision); - } - bool operator > (const VersionInfo &o) const - { - return o.major < this->major || (o.major == this->major && o.minor < this->minor) || (o.major == this->major && o.minor == this->minor && o.revision < this->revision); - } - bool operator < (const VersionInfo &o) const - { - return o.major > this->major || (o.major == this->major && o.minor > this->minor) || (o.major == this->major && o.minor == this->minor && o.revision > this->revision); - } - void operator=(const char *string); -}; - -// Cannot be a constructor because Lemon would puke on it. -inline VersionInfo MakeVersion(unsigned int ma, unsigned int mi, unsigned int re = 0) -{ - return{ (uint16_t)ma, (uint16_t)mi, (uint32_t)re }; -} - enum class ELightMode : int8_t { NotSet = -1, diff --git a/src/g_cvars.cpp b/src/g_cvars.cpp index db029c566..47b7e1d81 100644 --- a/src/g_cvars.cpp +++ b/src/g_cvars.cpp @@ -51,7 +51,10 @@ CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, alwaysapplydmflags, false, CVAR_SERVERINFO); // Show developer messages if true. -CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + FScriptPosition::Developer = self; +} // [RH] Feature control cvars CVAR(Bool, var_friction, true, CVAR_SERVERINFO); diff --git a/src/scripting/backend/vmbuilder.cpp b/src/scripting/backend/vmbuilder.cpp index 78d9499d1..393e3a53d 100644 --- a/src/scripting/backend/vmbuilder.cpp +++ b/src/scripting/backend/vmbuilder.cpp @@ -38,6 +38,8 @@ #include "c_cvars.h" #include "scripting/vm/jit.h" +EXTERN_CVAR(Bool, strictdecorate); + struct VMRemap { uint8_t altOp, kReg, kType; @@ -832,7 +834,7 @@ void FFunctionBuildList::Build() ctx.FunctionArgs.Push(local); } - FScriptPosition::StrictErrors = !item.FromDecorate; + FScriptPosition::StrictErrors = !item.FromDecorate || strictdecorate; item.Code = item.Code->Resolve(ctx); // If we need extra space, load the frame pointer into a register so that we do not have to call the wasteful LFP instruction more than once. if (item.Function->ExtraSpace > 0) @@ -910,7 +912,7 @@ void FFunctionBuildList::Build() disasmdump.Flush(); } VMFunction::CreateRegUseInfo(); - FScriptPosition::StrictErrors = false; + FScriptPosition::StrictErrors = strictdecorate; if (FScriptPosition::ErrorCounter == 0 && Args->CheckParm("-dumpjit")) DumpJit(); mItems.Clear(); diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index adbeebe9e..e3c57b0ef 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -53,7 +53,7 @@ #endif // !_MSC_VER void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns); -EXTERN_CVAR(Bool, strictdecorate); +CVAR(Bool, strictdecorate, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) //========================================================================== diff --git a/src/scripting/symbols.h b/src/scripting/symbols.h index bba2ac8d1..2ae194e89 100644 --- a/src/scripting/symbols.h +++ b/src/scripting/symbols.h @@ -1,6 +1,7 @@ // Note: This must not be included by anything but dobject.h! #pragma once +#include "sc_man.h" class VMFunction; class PType; diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index bc8f1a876..1c7848684 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -62,6 +62,7 @@ void InitThingdef(); static TMap StateSourceLines; static FScriptPosition unknownstatesource("unknown file", 0); +EXTERN_CVAR(Bool, strictdecorate); //========================================================================== // @@ -462,7 +463,7 @@ void LoadActors() FScriptPosition::StrictErrors = true; ParseScripts(); - FScriptPosition::StrictErrors = false; + FScriptPosition::StrictErrors = strictdecorate; ParseAllDecorate(); SynthesizeFlagFields(); diff --git a/src/sound/s_environment.cpp b/src/sound/s_environment.cpp index 276770f6c..351de9093 100644 --- a/src/sound/s_environment.cpp +++ b/src/sound/s_environment.cpp @@ -36,6 +36,7 @@ #include "sc_man.h" #include "templates.h" #include "m_misc.h" +#include "cmdlib.h" FReverbField ReverbFields[] =