- 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.
This commit is contained in:
Christoph Oelckers 2018-11-25 10:09:06 +01:00
parent f4789bdefc
commit 43d434b071
6 changed files with 14 additions and 27 deletions

View file

@ -401,10 +401,3 @@ CCMD (targetinv)
"the NOBLOCKMAP flag or have height/radius of 0.\n"); "the NOBLOCKMAP flag or have height/radius of 0.\n");
} }
//===========================================================================
//===========================================================================
IMPLEMENT_CLASS(AStateProvider, false, false)

View file

@ -103,11 +103,4 @@ public:
FSoundIDNoInit PickupSound; FSoundIDNoInit PickupSound;
}; };
class AStateProvider : public AInventory
{
DECLARE_CLASS (AStateProvider, AInventory)
public:
bool CallStateChain(AActor *actor, FState *state);
};
#endif //__A_PICKUPS_H__ #endif //__A_PICKUPS_H__

View file

@ -201,6 +201,7 @@ xx(PowerDrain)
xx(Reflection) xx(Reflection)
xx(CustomInventory) xx(CustomInventory)
xx(Inventory) xx(Inventory)
xx(StateProvider)
xx(CallTryPickup) xx(CallTryPickup)
xx(QuestItem25) xx(QuestItem25)
xx(QuestItem28) xx(QuestItem28)

View file

@ -98,7 +98,7 @@ FRandom pr_cajump("CustomJump");
extern TArray<VMValue> actionParams; // this can use the same storage as CallAction extern TArray<VMValue> 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; INTBOOL result = false;
int counter = 0; int counter = 0;
@ -111,7 +111,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
ret[0].PointerAt((void **)&nextstate); ret[0].PointerAt((void **)&nextstate);
ret[1].IntAt(&retval); ret[1].IntAt(&retval);
FState *savedstate = this->state; FState *savedstate = self->state;
while (state != NULL) while (state != NULL)
{ {
@ -121,7 +121,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
return false; return false;
} }
this->state = state; self->state = state;
nextstate = NULL; // assume no jump nextstate = NULL; // assume no jump
if (state->ActionFunc != NULL) if (state->ActionFunc != NULL)
@ -170,7 +170,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
try try
{ {
state->CheckCallerType(actor, this); state->CheckCallerType(actor, self);
if (state->ActionFunc->DefaultArgs.Size() > 0) if (state->ActionFunc->DefaultArgs.Size() > 0)
{ {
@ -187,7 +187,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
} }
if (state->ActionFunc->ImplicitArgs == 3) if (state->ActionFunc->ImplicitArgs == 3)
{ {
actionParams[index + 1] = this; actionParams[index + 1] = self;
actionParams[index + 2] = VMValue(&stp); actionParams[index + 2] = VMValue(&stp);
} }
@ -196,14 +196,14 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
} }
else else
{ {
VMValue params[3] = { actor, this, VMValue(&stp) }; VMValue params[3] = { actor, self, VMValue(&stp) };
VMCallAction(state->ActionFunc, params, state->ActionFunc->ImplicitArgs, wantret, numret); VMCallAction(state->ActionFunc, params, state->ActionFunc->ImplicitArgs, wantret, numret);
} }
} }
catch (CVMAbortException &err) catch (CVMAbortException &err)
{ {
err.MaybePrintMessage(); 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; throw;
} }
@ -231,16 +231,16 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
} }
state = nextstate; state = nextstate;
} }
this->state = savedstate; self->state = savedstate;
return !!result; return !!result;
} }
DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain) DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain)
{ {
PARAM_SELF_PROLOGUE(AStateProvider); PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(affectee, AActor); PARAM_OBJECT(affectee, AActor);
PARAM_POINTER(state, FState); PARAM_POINTER(state, FState);
ACTION_RETURN_BOOL(self->CallStateChain(affectee, state)); ACTION_RETURN_BOOL(CallStateChain(self, affectee, state));
} }
//========================================================================== //==========================================================================

View file

@ -324,7 +324,7 @@ static void CheckForUnsafeStates(PClassActor *obj)
if (obj->Size == citype->Size) return; // This class cannot have user variables. if (obj->Size == citype->Size) return; // This class cannot have user variables.
test = pickupstates; 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++) for (; *test != NAME_None; test++)
@ -483,7 +483,7 @@ void LoadActors()
CheckStates(ti); CheckStates(ti);
if (ti->bDecorateClass && ti->IsDescendantOf(RUNTIME_CLASS(AStateProvider))) if (ti->bDecorateClass && ti->IsDescendantOf(NAME_StateProvider))
{ {
// either a DECORATE based weapon or CustomInventory. // either a DECORATE based weapon or CustomInventory.
// These are subject to relaxed rules for user variables in states. // These are subject to relaxed rules for user variables in states.

View file

@ -1,5 +1,5 @@
class StateProvider : Inventory native class StateProvider : Inventory
{ {
//========================================================================== //==========================================================================
// //