Ensure BlockingMobj checks don't fail on destroyed Actors when handling physics

This commit is contained in:
Boondorl 2025-07-27 15:04:20 -04:00 committed by Ricardo Luís Vaz Silva
commit 9a4c2dc111
3 changed files with 19 additions and 16 deletions

View file

@ -4757,14 +4757,15 @@ DEFINE_ACTION_FUNCTION(AActor, CheckBlock)
ACTION_RETURN_BOOL(false);
}
if (mobj->BlockingMobj)
auto blocking = mobj->BlockingMobj.ForceGet();
if (blocking != nullptr && !(blocking->ObjectFlags & OF_EuthanizeMe))
{
AActor *setter = (flags & CBF_SETONPTR) ? mobj : self;
if (setter)
{
if (flags & CBF_SETTARGET) setter->target = mobj->BlockingMobj;
if (flags & CBF_SETMASTER) setter->master = mobj->BlockingMobj;
if (flags & CBF_SETTRACER) setter->tracer = mobj->BlockingMobj;
if (flags & CBF_SETTARGET) setter->target = blocking;
if (flags & CBF_SETMASTER) setter->master = blocking;
if (flags & CBF_SETTRACER) setter->tracer = blocking;
}
}
@ -4772,7 +4773,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckBlock)
//If an actor is loaded with pointers, they don't really have any options to spare.
//Also, fail if a dropoff or a step is too great to pass over when checking for dropoffs.
ACTION_RETURN_BOOL((!(flags & CBF_NOACTORS) && (mobj->BlockingMobj)) || (!(flags & CBF_NOLINES) && mobj->BlockingLine != NULL) ||
ACTION_RETURN_BOOL((!(flags & CBF_NOACTORS) && blocking != nullptr) || (!(flags & CBF_NOLINES) && mobj->BlockingLine != NULL) ||
((flags & CBF_DROPOFF) && !checker));
}