From 32ac1a8ad7613baf369bb0e5d3780c72ee4b2d69 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 22 Oct 2016 16:46:47 +0200 Subject: [PATCH] - moved the special weapon functions from Inventory to StateProvider. This will restrict them to the only classes that may use them: Weapon and CustomInventory. Note: Should a mod surface which uses them improperly the better solution would be a warning message and NULLing the bogus code pointer instead of leaving them in Inventory. --- src/d_dehacked.cpp | 8 +-- wadsrc/static/zscript/shared/inventory.txt | 63 +++++++++++----------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 66bdc652c..71deb0169 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -797,7 +797,7 @@ void SetDehParams(FState *state, int codepointer) // Let's identify the codepointer we're dealing with. PFunction *sym; - sym = dyn_cast(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(FName(MBFCodePointers[codepointer].name), true)); + sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(FName(MBFCodePointers[codepointer].name), true)); if (sym == NULL) return; if (codepointer < 0 || (unsigned)codepointer >= countof(MBFCodePointerFactories)) @@ -2113,7 +2113,7 @@ static int PatchCodePtrs (int dummy) // This skips the action table and goes directly to the internal symbol table // DEH compatible functions are easy to recognize. - PFunction *sym = dyn_cast(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(symname, true)); + PFunction *sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(symname, true)); if (sym == NULL) { Printf("Frame %d: Unknown code pointer '%s'\n", frame, Line2); @@ -2721,11 +2721,11 @@ static bool LoadDehSupp () } else { - // all relevant code pointers are either defined in AInventory + // all relevant code pointers are either defined in AStateProvider // or AActor so this will find all of them. FString name = "A_"; name << sc.String; - PFunction *sym = dyn_cast(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(name, true)); + PFunction *sym = dyn_cast(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(name, true)); if (sym == NULL) { sc.ScriptError("Unknown code pointer '%s'", sc.String); diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index bf2f7e188..80771e1a1 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -10,6 +10,37 @@ class Inventory : Actor native Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } + // These are regular functions for the item itself. + private action native void A_RestoreSpecialPosition(); + private action native void A_RestoreSpecialDoomThing(); + private action native void A_RestoreSpecialThing1(); + private action native void A_RestoreSpecialThing2(); + + States + { + HideDoomish: + TNT1 A 1050; + TNT1 A 0 A_RestoreSpecialPosition; + TNT1 A 1 A_RestoreSpecialDoomThing; + Stop; + HideSpecial: + ACLO E 1400; + ACLO A 0 A_RestoreSpecialPosition; + ACLO A 4 A_RestoreSpecialThing1; + ACLO BABCBCDC 4; + ACLO D 4 A_RestoreSpecialThing2; + Stop; + Held: + TNT1 A -1; + Stop; + HoldAndDestroy: + TNT1 A 1; + Stop; + } +} + +class StateProvider : Inventory native +{ action native state A_JumpIfNoAmmo(state label); action native void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = ""); action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, float range = 0, class missile = "", float Spawnheight = 32, float Spawnofs_xy = 0); @@ -47,38 +78,6 @@ class Inventory : Actor native action native void A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus"); action native state A_CheckForReload(int counter, state label, bool dontincrement = false); action native void A_ResetReloadCounter(); - - // These are regular functions for the item itself. - private action native void A_RestoreSpecialPosition(); - private action native void A_RestoreSpecialDoomThing(); - private action native void A_RestoreSpecialThing1(); - private action native void A_RestoreSpecialThing2(); - - States - { - HideDoomish: - TNT1 A 1050; - TNT1 A 0 A_RestoreSpecialPosition; - TNT1 A 1 A_RestoreSpecialDoomThing; - Stop; - HideSpecial: - ACLO E 1400; - ACLO A 0 A_RestoreSpecialPosition; - ACLO A 4 A_RestoreSpecialThing1; - ACLO BABCBCDC 4; - ACLO D 4 A_RestoreSpecialThing2; - Stop; - Held: - TNT1 A -1; - Stop; - HoldAndDestroy: - TNT1 A 1; - Stop; - } -} - -class StateProvider : Inventory native -{ } class ScoreItem : Inventory native