mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
- Re-jigged DoJump() to not be recursive so that 0-tic A_Jump* loops are no longer
able to potentially blow up the stack. SVN r3902 (scripting)
This commit is contained in:
parent
47eec0b275
commit
d0c91083bc
3 changed files with 19 additions and 1 deletions
|
@ -205,6 +205,7 @@ enum EObjectFlags
|
|||
OF_JustSpawned = 1 << 8, // Thinker was spawned this tic
|
||||
OF_SerialSuccess = 1 << 9, // For debugging Serialize() calls
|
||||
OF_Sentinel = 1 << 10, // Object is serving as the sentinel in a ring list
|
||||
OF_StateChanged = 1 << 11, // Used by A_Jump* functions to feed back to SetState()
|
||||
};
|
||||
|
||||
template<class T> class TObjPtr;
|
||||
|
|
|
@ -482,7 +482,16 @@ bool AActor::SetState (FState *newstate, bool nofunction)
|
|||
{
|
||||
// Check whether the called action function resulted in destroying the actor
|
||||
if (ObjectFlags & OF_EuthanizeMe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ObjectFlags & OF_StateChanged)
|
||||
{ // The action was an A_Jump-style function that wants to change the next state.
|
||||
ObjectFlags &= ~OF_StateChanged;
|
||||
newstate = state;
|
||||
tics = 0; // make sure we loop and set the new state properly
|
||||
continue;
|
||||
}
|
||||
}
|
||||
newstate = newstate->GetNextState();
|
||||
} while (tics == 0);
|
||||
|
|
|
@ -610,7 +610,15 @@ static void DoJump(AActor *self, AActor *stateowner, FState *callingstate, FStat
|
|||
}
|
||||
else if (callingstate == self->state)
|
||||
{
|
||||
self->SetState(jumpto);
|
||||
// Rather than using self->SetState(jumpto) to set the state,
|
||||
// set the state directly. Since this function is only called by
|
||||
// action functions, which are only called by SetState(), we
|
||||
// know that somewhere above us in the stack, a SetState()
|
||||
// call is waiting for us to return. We use the flag OF_StateChanged
|
||||
// to cause it to bypass the normal next state mechanism and use
|
||||
// the one we set here instead.
|
||||
self->state = jumpto;
|
||||
self->ObjectFlags |= OF_StateChanged;
|
||||
}
|
||||
else
|
||||
{ // something went very wrong. This should never happen.
|
||||
|
|
Loading…
Reference in a new issue