- adjusted condition for ZScript global variable deprecation warning

The message is always printed for any use of deprecated global variable
If such variable is accessed inside a deprecated function from a core script lump, the message is printed only when verbosity level is set to highest

https://forum.zdoom.org/viewtopic.php?t=64830
This commit is contained in:
alexey.lysiuk 2019-05-30 10:20:49 +03:00 committed by Rachael Alexanderson
parent ae94aa029c
commit d94786a132

View file

@ -6126,19 +6126,16 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
if ((vsym->Flags & VARF_Deprecated)) if ((vsym->Flags & VARF_Deprecated))
{ {
if (sym->mVersion <= ctx.Version) if (sym->mVersion <= ctx.Version)
{
if (!(ctx.Function->Variants[0].Flags & VARF_Deprecated) && Wads.GetLumpFile(ctx.Lump) != 0)
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated global variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
}
else
{ {
// Allow use of deprecated symbols in deprecated functions of the internal code. This is meant to allow deprecated code to remain as it was, // Allow use of deprecated symbols in deprecated functions of the internal code. This is meant to allow deprecated code to remain as it was,
// even if it depends on some deprecated symbol. // even if it depends on some deprecated symbol.
// The main motivation here is to keep the deprecated static functions accessing the global level variable as they were. // The main motivation here is to keep the deprecated static functions accessing the global level variable as they were.
// Print these only if debug output is active and at the highest verbosity level. // Print these only if debug output is active and at the highest verbosity level.
ScriptPosition.Message(MSG_DEBUGMSG, TEXTCOLOR_BLUE "Accessing deprecated global variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision); const bool internal = (ctx.Function->Variants[0].Flags & VARF_Deprecated) && Wads.GetLumpFile(ctx.Lump) == 0;
}
ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING,
"%sAccessing deprecated global variable %s - deprecated since %d.%d.%d", internal ? TEXTCOLOR_BLUE : "",
sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
} }
} }