forked from Mirrors/openclonk
Fix crash when grab target is lost.
parent
4eddeba9aa
commit
26084af502
|
@ -2882,7 +2882,6 @@ bool C4Object::SetAction(C4PropList * Act, C4Object *pTarget, C4Object *pTarget2
|
|||
}
|
||||
}
|
||||
// Set new action
|
||||
|
||||
SetProperty(P_Action, C4VPropList(Act));
|
||||
Action.Phase=Action.PhaseDelay=0;
|
||||
// Set target if specified
|
||||
|
@ -3019,12 +3018,10 @@ int32_t C4Object::GetProcedure() const
|
|||
return pActionDef->GetPropertyP(P_Procedure);
|
||||
}
|
||||
|
||||
void GrabLost(C4Object *cObj)
|
||||
void GrabLost(C4Object *cObj, C4Object *prev_target)
|
||||
{
|
||||
// Grab lost script call on target (quite hacky stuff...)
|
||||
cObj->Action.Target->Call(PSF_GrabLost);
|
||||
// Also, delete the target from the clonk's action (Newton)
|
||||
cObj->Action.Target = NULL;
|
||||
if (prev_target && prev_target->Status) prev_target->Call(PSF_GrabLost);
|
||||
// Clear commands down to first PushTo (if any) in command stack
|
||||
for (C4Command *pCom=cObj->Command; pCom; pCom=pCom->Next)
|
||||
if (pCom->Next && pCom->Next->Command==C4CMD_PushTo)
|
||||
|
@ -3042,6 +3039,7 @@ void C4Object::NoAttachAction()
|
|||
if (GetAction())
|
||||
{
|
||||
int32_t iProcedure = GetProcedure();
|
||||
C4Object *prev_target = Action.Target;
|
||||
// Scaling upwards: corner scale
|
||||
if (iProcedure == DFA_SCALE && Action.ComDir != COMD_Stop && ComDirLike(Action.ComDir, COMD_Up))
|
||||
if (ObjectActionCornerScale(this)) return;
|
||||
|
@ -3058,7 +3056,7 @@ void C4Object::NoAttachAction()
|
|||
{ if (ObjectActionJump(this,itofix(-1),Fix0,false)) return; }
|
||||
}
|
||||
// Pushing: grab loss
|
||||
if (iProcedure==DFA_PUSH) GrabLost(this);
|
||||
if (iProcedure==DFA_PUSH) GrabLost(this, prev_target);
|
||||
// Else jump
|
||||
ObjectActionJump(this,xdir,ydir,false);
|
||||
}
|
||||
|
@ -3773,10 +3771,11 @@ void C4Object::ExecAction()
|
|||
if (!Inside(GetX()-sax,-iPushRange,sawdt-1+iPushRange)
|
||||
|| !Inside(GetY()-say,-iPushRange,sahgt-1+iPushRange))
|
||||
{
|
||||
C4Object *prev_target = Action.Target;
|
||||
// Wait command (why, anyway?)
|
||||
StopActionDelayCommand(this);
|
||||
// Grab lost action
|
||||
GrabLost(this);
|
||||
GrabLost(this, prev_target);
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
|
@ -3847,10 +3846,12 @@ void C4Object::ExecAction()
|
|||
if (!Inside(GetX()-sax,-iPushRange,sawdt-1+iPushRange)
|
||||
|| !Inside(GetY()-say,-iPushRange,sahgt-1+iPushRange))
|
||||
{
|
||||
// Remember target. Will be lost on changing action.
|
||||
C4Object *prev_target = Action.Target;
|
||||
// Wait command (why, anyway?)
|
||||
StopActionDelayCommand(this);
|
||||
// Grab lost action
|
||||
GrabLost(this);
|
||||
GrabLost(this, prev_target);
|
||||
// Lose target
|
||||
Action.Target=NULL;
|
||||
// Done
|
||||
|
|
Loading…
Reference in New Issue