Skip to content

Commit

Permalink
expand deprecation allowance for gzdoom.pk3
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Jan 13, 2025
1 parent 61df133 commit 09266ca
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
19 changes: 12 additions & 7 deletions src/common/scripting/backend/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/common/scripting/core/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3231,12 +3231,11 @@ PFunctionPointer * NewFunctionPointer(PPrototype * proto, TArray<uint32_t> && 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;
}

//==========================================================================
Expand Down
5 changes: 2 additions & 3 deletions src/common/scripting/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -648,7 +649,6 @@ class PStruct : public PContainerType
// 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;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions wadsrc/static/zscript/actors/mbf21.zs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extend class Actor
// args[7]: Z velocity (fixed point)
//
deprecated("2.3", "for Dehacked use only")
void MBF21_SpawnObject(class<Actor> type, double angle, double xofs, double yofs, double zofs, double xvel, double yvel, double zvel)
action void MBF21_SpawnObject(class<Actor> type, double angle, double xofs, double yofs, double zofs, double xvel, double yvel, double zvel)
{
if (type == null)
return;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<Actor> type, double angle, double pitch, double Spawnofs_xy, double Spawnofs_z)
action void MBF21_WeaponProjectile(class<Actor> type, double angle, double pitch, double Spawnofs_xy, double Spawnofs_z)
{
if (!player || !type)
return;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
}
Expand Down

0 comments on commit 09266ca

Please sign in to comment.