From ef86b3975a23723762b7c2d09414f977f1a72a8d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 8 Jun 2016 10:56:11 +0200 Subject: [PATCH] - added 'strictdecorate' CVAR. If this is set to 'true', any DECORATE error that had to be demoted to a warning for backwards compatibility will be treated as an actual error. --- src/dobjtype.cpp | 4 +++- src/sc_man.cpp | 6 ++++++ src/sc_man.h | 1 + src/thingdef/thingdef_expression.cpp | 12 ++++++------ src/thingdef/thingdef_properties.cpp | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index febcad0b5c..6b963f6d4d 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -60,6 +60,7 @@ // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // EXTERNAL DATA DECLARATIONS ---------------------------------------------- +EXTERN_CVAR(Bool, strictdecorate); // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -3067,7 +3068,8 @@ void PClass::InsertIntoHash () if (found != NULL) { // This type has already been inserted // ... but there is no need whatsoever to make it a fatal error! - Printf (TEXTCOLOR_RED"Tried to register class '%s' more than once.\n", TypeName.GetChars()); + if (!strictdecorate) Printf (TEXTCOLOR_RED"Tried to register class '%s' more than once.\n", TypeName.GetChars()); + else I_Error("Tried to register class '%s' more than once.\n", TypeName.GetChars()); TypeTable.ReplaceType(this, found, bucket); } else diff --git a/src/sc_man.cpp b/src/sc_man.cpp index dadbae0ed1..da106927e3 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -1038,11 +1038,17 @@ FScriptPosition &FScriptPosition::operator=(const FScriptPosition &other) // //========================================================================== +CVAR(Bool, strictdecorate, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) + void FScriptPosition::Message (int severity, const char *message, ...) const { FString composed; if ((severity == MSG_DEBUG || severity == MSG_DEBUGLOG) && !developer) return; + if (severity == MSG_OPTERROR) + { + severity = strictdecorate ? MSG_ERROR : MSG_WARNING; + } if (message == NULL) { diff --git a/src/sc_man.h b/src/sc_man.h index b1231e547b..359dd81405 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -124,6 +124,7 @@ enum MSG_WARNING, MSG_FATAL, MSG_ERROR, + MSG_OPTERROR, MSG_DEBUG, MSG_LOG, MSG_DEBUGLOG, diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 2e60dfa971..d500458a2d 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -368,8 +368,8 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx) else { // Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :( - if (!basex->isConstant()) ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got a name"); - else ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got \"%s\"", static_cast(basex)->GetValue().GetName().GetChars()); + if (!basex->isConstant()) ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got a name"); + else ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got \"%s\"", static_cast(basex)->GetValue().GetName().GetChars()); FxExpression * x = new FxConstant(0, ScriptPosition); delete this; return x; @@ -466,8 +466,8 @@ FxExpression *FxFloatCast::Resolve(FCompileContext &ctx) else { // Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :( - if (!basex->isConstant()) ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got a name"); - else ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got \"%s\"", static_cast(basex)->GetValue().GetName().GetChars()); + if (!basex->isConstant()) ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got a name"); + else ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got \"%s\"", static_cast(basex)->GetValue().GetName().GetChars()); FxExpression *x = new FxConstant(0.0, ScriptPosition); delete this; return x; @@ -3924,7 +3924,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) { /* lax */ // Since this happens in released WADs it must pass without a terminal error... :( - ScriptPosition.Message(MSG_WARNING, + ScriptPosition.Message(MSG_OPTERROR, "Unknown class name '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); } @@ -4095,7 +4095,7 @@ FxExpression *FxMultiNameState::Resolve(FCompileContext &ctx) destination = scope->FindState(names.Size()-1, &names[1], false); if (destination == NULL) { - ScriptPosition.Message(MSG_WARNING, "Unknown state jump destination"); + ScriptPosition.Message(MSG_OPTERROR, "Unknown state jump destination"); /* lax */ return this; } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 3ec4c624d5..db6ef14a05 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -457,7 +457,7 @@ DEFINE_PROPERTY(skip_super, 0, Actor) } if (bag.StateSet) { - bag.ScriptPosition.Message(MSG_WARNING, + bag.ScriptPosition.Message(MSG_OPTERROR, "'skip_super' must appear before any state definitions."); return; }