- 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.
This commit is contained in:
Christoph Oelckers 2016-10-22 16:46:47 +02:00
parent d714670acc
commit 32ac1a8ad7
2 changed files with 35 additions and 36 deletions

View file

@ -797,7 +797,7 @@ void SetDehParams(FState *state, int codepointer)
// Let's identify the codepointer we're dealing with.
PFunction *sym;
sym = dyn_cast<PFunction>(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(FName(MBFCodePointers[codepointer].name), true));
sym = dyn_cast<PFunction>(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<PFunction>(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(symname, true));
PFunction *sym = dyn_cast<PFunction>(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<PFunction>(RUNTIME_CLASS(AInventory)->Symbols.FindSymbol(name, true));
PFunction *sym = dyn_cast<PFunction>(RUNTIME_CLASS(AStateProvider)->Symbols.FindSymbol(name, true));
if (sym == NULL)
{
sc.ScriptError("Unknown code pointer '%s'", sc.String);

View file

@ -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<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = "");
action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", int flags = 1, float range = 0, class<Actor> 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<Actor> pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> 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