From 43d434b071bbb17598fb7ab2b4b2690927dfbe51 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Nov 2018 10:09:06 +0100 Subject: [PATCH] - removed AStateProvider from native code. The only place still referencing it was CallStateChain, so this has been made a static function now instead of a class method. --- src/g_inventory/a_pickups.cpp | 7 ------- src/g_inventory/a_pickups.h | 7 ------- src/namedef.h | 1 + src/p_actionfunctions.cpp | 20 +++++++++---------- src/scripting/thingdef.cpp | 4 ++-- .../zscript/inventory/stateprovider.txt | 2 +- 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index a63030a3bf..0823fa7a1c 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -401,10 +401,3 @@ CCMD (targetinv) "the NOBLOCKMAP flag or have height/radius of 0.\n"); } -//=========================================================================== -//=========================================================================== - - - -IMPLEMENT_CLASS(AStateProvider, false, false) - diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index ca11da98d4..74c5071c68 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -103,11 +103,4 @@ public: FSoundIDNoInit PickupSound; }; -class AStateProvider : public AInventory -{ - DECLARE_CLASS (AStateProvider, AInventory) -public: - bool CallStateChain(AActor *actor, FState *state); -}; - #endif //__A_PICKUPS_H__ diff --git a/src/namedef.h b/src/namedef.h index c40b16ca60..fbb3056d62 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -201,6 +201,7 @@ xx(PowerDrain) xx(Reflection) xx(CustomInventory) xx(Inventory) +xx(StateProvider) xx(CallTryPickup) xx(QuestItem25) xx(QuestItem28) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 9d20b5bc56..e8dc860e94 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -98,7 +98,7 @@ FRandom pr_cajump("CustomJump"); extern TArray actionParams; // this can use the same storage as CallAction -bool AStateProvider::CallStateChain (AActor *actor, FState *state) +static bool CallStateChain (AActor *self, AActor *actor, FState *state) { INTBOOL result = false; int counter = 0; @@ -111,7 +111,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) ret[0].PointerAt((void **)&nextstate); ret[1].IntAt(&retval); - FState *savedstate = this->state; + FState *savedstate = self->state; while (state != NULL) { @@ -121,7 +121,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) return false; } - this->state = state; + self->state = state; nextstate = NULL; // assume no jump if (state->ActionFunc != NULL) @@ -170,7 +170,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) try { - state->CheckCallerType(actor, this); + state->CheckCallerType(actor, self); if (state->ActionFunc->DefaultArgs.Size() > 0) { @@ -187,7 +187,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) } if (state->ActionFunc->ImplicitArgs == 3) { - actionParams[index + 1] = this; + actionParams[index + 1] = self; actionParams[index + 2] = VMValue(&stp); } @@ -196,14 +196,14 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) } else { - VMValue params[3] = { actor, this, VMValue(&stp) }; + VMValue params[3] = { actor, self, VMValue(&stp) }; VMCallAction(state->ActionFunc, params, state->ActionFunc->ImplicitArgs, wantret, numret); } } catch (CVMAbortException &err) { err.MaybePrintMessage(); - err.stacktrace.AppendFormat("Called from state %s in inventory state chain in %s\n", FState::StaticGetStateName(state).GetChars(), GetClass()->TypeName.GetChars()); + err.stacktrace.AppendFormat("Called from state %s in inventory state chain in %s\n", FState::StaticGetStateName(state).GetChars(), self->GetClass()->TypeName.GetChars()); throw; } @@ -231,16 +231,16 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) } state = nextstate; } - this->state = savedstate; + self->state = savedstate; return !!result; } DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain) { - PARAM_SELF_PROLOGUE(AStateProvider); + PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(affectee, AActor); PARAM_POINTER(state, FState); - ACTION_RETURN_BOOL(self->CallStateChain(affectee, state)); + ACTION_RETURN_BOOL(CallStateChain(self, affectee, state)); } //========================================================================== diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 186f5275ab..287a499089 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -324,7 +324,7 @@ static void CheckForUnsafeStates(PClassActor *obj) if (obj->Size == citype->Size) return; // This class cannot have user variables. test = pickupstates; } - else return; // something else derived from AStateProvider. We do not know what this may be. + else return; // something else derived from StateProvider. We do not know what this may be. } for (; *test != NAME_None; test++) @@ -483,7 +483,7 @@ void LoadActors() CheckStates(ti); - if (ti->bDecorateClass && ti->IsDescendantOf(RUNTIME_CLASS(AStateProvider))) + if (ti->bDecorateClass && ti->IsDescendantOf(NAME_StateProvider)) { // either a DECORATE based weapon or CustomInventory. // These are subject to relaxed rules for user variables in states. diff --git a/wadsrc/static/zscript/inventory/stateprovider.txt b/wadsrc/static/zscript/inventory/stateprovider.txt index 3f5a88c558..28024fe443 100644 --- a/wadsrc/static/zscript/inventory/stateprovider.txt +++ b/wadsrc/static/zscript/inventory/stateprovider.txt @@ -1,5 +1,5 @@ -class StateProvider : Inventory native +class StateProvider : Inventory { //========================================================================== //