From e543e26bdc1fc269a0c55721a843a4714460a41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Mon, 13 Jan 2025 11:33:43 -0300 Subject: [PATCH] expand deprecation allowance for gzdoom.pk3 --- src/common/scripting/backend/codegen.cpp | 19 ++++++++++++------- src/common/scripting/core/types.cpp | 3 +-- src/common/scripting/core/types.h | 5 ++--- wadsrc/static/zscript/actors/mbf21.zs | 18 +++++++++--------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 07ced853ed..009f22a0e9 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -6783,11 +6783,8 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) { if (sym->mVersion <= ctx.Version) { - // 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. - const bool internal = (ctx.Function->Variants[0].Flags & VARF_Deprecated) && fileSystem.GetFileContainer(ctx.Lump) == 0; + // Allow use of deprecated symbols in the internal code. + const bool internal = fileSystem.GetFileContainer(ctx.Lump) == 0; const FString &deprecationMessage = vsym->DeprecationMessage; ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING, @@ -6877,8 +6874,12 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType * { if (sym->mVersion <= ctx.Version) { + // Allow use of deprecated symbols in internal code. + const bool internal = fileSystem.GetFileContainer(ctx.Lump) == 0; const FString &deprecationMessage = vsym->DeprecationMessage; - ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s - deprecated since %d.%d.%d%s%s", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision, + + ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING, + "Accessing deprecated member variable %s - deprecated since %d.%d.%d%s%s", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision, deprecationMessage.IsEmpty() ? "" : ", ", deprecationMessage.GetChars()); } } @@ -9661,8 +9662,12 @@ bool FxVMFunctionCall::CheckAccessibility(const VersionInfo &ver) { if (Function->mVersion <= ver) { + // Allow use of deprecated symbols in internal code. + const bool internal = fileSystem.GetFileContainer(Function->OwningClass->mDefFileNo) == 0; const FString &deprecationMessage = Function->Variants[0].DeprecationMessage; - ScriptPosition.Message(MSG_WARNING, "Accessing deprecated function %s - deprecated since %d.%d.%d%s%s", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision, + + ScriptPosition.Message(internal ? MSG_DEBUGMSG : MSG_WARNING, + "Accessing deprecated function %s - deprecated since %d.%d.%d%s%s", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision, deprecationMessage.IsEmpty() ? "" : ", ", deprecationMessage.GetChars()); } } diff --git a/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index b70783f3e1..d99f7eb13f 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -3231,12 +3231,11 @@ PFunctionPointer * NewFunctionPointer(PPrototype * proto, TArray && ar //========================================================================== PStruct::PStruct(FName name, PTypeBase *outer, bool isnative, int fileno) -: PContainerType(name, outer) +: PContainerType(name, outer, fileno) { mDescriptiveName.Format("%sStruct<%s>", isnative? "Native" : "", name.GetChars()); Size = 0; isNative = isnative; - mDefFileNo = fileno; } //========================================================================== diff --git a/src/common/scripting/core/types.h b/src/common/scripting/core/types.h index a092247dea..f09ddb32b9 100644 --- a/src/common/scripting/core/types.h +++ b/src/common/scripting/core/types.h @@ -253,13 +253,14 @@ class PContainerType : public PCompoundType public: PTypeBase *Outer = nullptr; // object this type is contained within FName TypeName = NAME_None; // this type's name + int mDefFileNo = 0; PContainerType() { mDescriptiveName = "ContainerType"; Flags |= TYPE_Container; } - PContainerType(FName name, PTypeBase *outer) : Outer(outer), TypeName(name) + PContainerType(FName name, PTypeBase *outer, int fileno) : Outer(outer), TypeName(name), mDefFileNo(fileno) { mDescriptiveName = name.GetChars(); Flags |= TYPE_Container; @@ -648,7 +649,6 @@ public: // Some internal structs require explicit construction and destruction of fields the VM cannot handle directly so use these two functions for it. VMFunction *mConstructor = nullptr; VMFunction *mDestructor = nullptr; - int mDefFileNo; PField *AddField(FName name, PType *type, uint32_t flags=0) override; PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0) override; @@ -681,7 +681,6 @@ class PClassType : public PContainerType public: PClass *Descriptor; PClassType *ParentType; - int mDefFileNo; PClassType(PClass *cls = nullptr, int fileno = 0); PField *AddField(FName name, PType *type, uint32_t flags = 0) override; diff --git a/wadsrc/static/zscript/actors/mbf21.zs b/wadsrc/static/zscript/actors/mbf21.zs index c7fc2a8fb9..c286f7bde2 100644 --- a/wadsrc/static/zscript/actors/mbf21.zs +++ b/wadsrc/static/zscript/actors/mbf21.zs @@ -18,7 +18,7 @@ extend class Actor // args[7]: Z velocity (fixed point) // deprecated("2.3", "for Dehacked use only") - void MBF21_SpawnObject(class type, double angle, double xofs, double yofs, double zofs, double xvel, double yvel, double zvel) + action void MBF21_SpawnObject(class type, double angle, double xofs, double yofs, double zofs, double xvel, double yvel, double zvel) { if (type == null) return; @@ -219,7 +219,7 @@ extend class Actor // args[1]: Health threshold // deprecated("2.3", "for Dehacked use only") - void MBF21_JumpIfHealthBelow(State tstate, int health) + action void MBF21_JumpIfHealthBelow(State tstate, int health) { if (self.health < health) self.SetState(tstate); } @@ -310,7 +310,7 @@ extend class Weapon // args[4]: Z spawn offset, relative to player's default projectile fire height // deprecated("2.3", "for Dehacked use only") - void MBF21_WeaponProjectile(class type, double angle, double pitch, double Spawnofs_xy, double Spawnofs_z) + action void MBF21_WeaponProjectile(class type, double angle, double pitch, double Spawnofs_xy, double Spawnofs_z) { if (!player || !type) return; @@ -342,7 +342,7 @@ extend class Weapon // args[4]: Attack damage modulus (e.g. for 5d3, customize the 3); if not set, defaults to 3 // deprecated("2.3", "for Dehacked use only") - void MBF21_WeaponBulletAttack(double hspread, double vspread, int numbullets, int damagebase, int damagemod) + action void MBF21_WeaponBulletAttack(double hspread, double vspread, int numbullets, int damagebase, int damagemod) { let bangle = angle; let slope = BulletSlope(); @@ -367,7 +367,7 @@ extend class Weapon // args[4]: Range (fixed point); if not set, defaults to player mobj's melee range // deprecated("2.3", "for Dehacked use only") - void MBF21_WeaponMeleeAttack(int damagebase, int damagemod, double zerkfactor, Sound hitsound, double range) + action void MBF21_WeaponMeleeAttack(int damagebase, int damagemod, double zerkfactor, Sound hitsound, double range) { if (range == 0) range = meleerange; @@ -394,7 +394,7 @@ extend class Weapon // A_WeaponAlert // Alerts monsters to the player's presence. Handy when combined with WPF_SILENT. // - void A_WeaponAlert() + action void A_WeaponAlert() { SoundAlert(self); } @@ -424,7 +424,7 @@ extend class Weapon // args[0]: Amount of ammo to consume. If zero, use the weapon's ammo-per-shot amount. // deprecated("2.3", "for Dehacked use only") - void MBF21_ConsumeAmmo(int consume) + action void MBF21_ConsumeAmmo(int consume) { let player = self.player; if (!player) return; @@ -492,7 +492,7 @@ extend class Weapon // args[1]: If nonzero, don't change the player actor state // deprecated("2.3", "for Dehacked use only") - void MBF21_GunFlashTo(State tstate, int dontchangeplayer) + action void MBF21_GunFlashTo(State tstate, int dontchangeplayer) { let player = self.player; if (player == null) return; @@ -505,7 +505,7 @@ extend class Weapon // needed to call A_SeekerMissile with proper defaults. deprecated("2.3", "for Dehacked use only") - void MBF21_SeekTracer(double threshold, double turnmax) + action void MBF21_SeekTracer(double threshold, double turnmax) { A_SeekerMissile(int(threshold), int(turnmax), flags: SMF_PRECISE); // args get truncated to ints here, but it's close enough }