From 84baa5bb4d29ac708aa2023f2c7f97d285fcb08b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jan 2019 14:33:02 +0100 Subject: [PATCH] - deprecated the global 'level' variable. This will currently output 9 warnings for the UDMF property getters. To silence these a bit more work is needed. --- src/scripting/backend/codegen.cpp | 14 +++++++++++++- src/scripting/vmthunks_actors.cpp | 1 + wadsrc/static/zscript/base.txt | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 4beb56d67..2a854d346 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -6132,9 +6132,21 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) { if (sym->mVersion <= ctx.Version) { - 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); + 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, + // 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. + // 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); + } } } + newex = new FxGlobalVariable(static_cast(sym), ScriptPosition); goto foundit; diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 01fb90f84..d52e6e28e 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -1681,6 +1681,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(APlayerPawn, GetPrintableDisplayName, GetPrintable +DEFINE_FIELD(DThinker, Level) DEFINE_FIELD(AActor, snext) DEFINE_FIELD(AActor, player) DEFINE_FIELD_NAMED(AActor, __Pos, pos) diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 775a38488..d449bfd34 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -7,7 +7,7 @@ struct _ native // These are the global variables, the struct is only here to av native readonly Array<@Team> Teams; native int validcount; native readonly bool multiplayer; - native play @LevelLocals level; + deprecated("3.8") native play @LevelLocals level; native @KeyBindings Bindings; native @KeyBindings AutomapBindings; native play @DehInfo deh; @@ -461,6 +461,8 @@ class Thinker : Object native play } const TICRATE = 35; + + native LevelLocals Level; virtual native void Tick(); virtual native void PostBeginPlay();