Skip to content

Commit

Permalink
Check for a nullptr/dead object in aiBestNearestTarget()
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Feb 19, 2024
1 parent 70eda32 commit 3ffdbff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
BASE_OBJECT *friendlyObj = nullptr;
BASE_OBJECT *targetInQuestion = *gi;

if (targetInQuestion == nullptr || isDead(targetInQuestion))
{
continue;
}

/* This is a friendly unit, check if we can reuse its target */
if (aiCheckAlliances(targetInQuestion->player, psDroid->player))
{
Expand Down

0 comments on commit 3ffdbff

Please sign in to comment.