Added some null pointer checks to prevent crashes.

This commit is contained in:
inkoalawetrust 2023-08-31 19:38:14 +03:00 committed by Christoph Oelckers
parent 44623daafe
commit 520b6af947
2 changed files with 4 additions and 1 deletions

View file

@ -1614,6 +1614,9 @@ DEFINE_ACTION_FUNCTION(AActor, PoisonMobj)
bool AActor::OkayToSwitchTarget(AActor *other) bool AActor::OkayToSwitchTarget(AActor *other)
{ {
if (other == nullptr)
return false;
if (other == this) if (other == this)
return false; // [RH] Don't hate self (can happen when shooting barrels) return false; // [RH] Don't hate self (can happen when shooting barrels)

View file

@ -1686,7 +1686,7 @@ FPathTraverse::~FPathTraverse()
// //
int P_CheckFov(AActor* t1, AActor* t2, double fov) int P_CheckFov(AActor* t1, AActor* t2, double fov)
{ {
return absangle(t1->AngleTo(t2), t1->Angles.Yaw) <= DAngle::fromDeg(fov); return absangle(t1->AngleTo(PARAM_NULLCHECK(t2,t2)), t1->Angles.Yaw) <= DAngle::fromDeg(fov);
} }
DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckFov, P_CheckFov) DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckFov, P_CheckFov)