Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various crash fixes #3646

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
{
// FIXME: change when adding submarines to the game
// modifiedModelMatrix *= glm::translate(glm::vec3(0.f, -world_coord(1) / 2.3f, 0.f));
position.y += (world_coord(1) / 2.3f);

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [GCC]

conversion from ‘float’ to ‘int’ may change value [-Wfloat-conversion]

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC -m32]

conversion from 'float' to 'int' may change value [-Wfloat-conversion]

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC]

conversion from 'float' to 'int' may change value [-Wfloat-conversion]

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]

Check warning on line 255 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]
}

EFFECT_TYPE type = DROID_ANIMEVENT_DYING_NORMAL;
Expand Down Expand Up @@ -2279,12 +2279,20 @@
}
for (const DROID* psDroid : *dList)
{
if (psDroid == nullptr || isDead(psDroid))
{
continue;
}
if (getDroidLevel(psDroid) == level)
{
++count;
}
if (psDroid->isTransporter())
{
if (psDroid->psGroup == nullptr)
{
continue;
}
for (const DROID *psCurr : psDroid->psGroup->psList)
{
if (psCurr != psDroid && getDroidLevel(psCurr) == level)
Expand Down
12 changes: 10 additions & 2 deletions src/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,11 @@ void countUpdate(bool synch)
setLasSatExists(false, i);
for (const STRUCTURE *psCBuilding : apsStructLists[i])
{
if (psCBuilding->pStructureType->type == REF_SAT_UPLINK && psCBuilding->status == SS_BUILT)
if (psCBuilding == nullptr || isDead(psCBuilding))
{
continue;
}
if (psCBuilding->pStructureType && psCBuilding->pStructureType->type == REF_SAT_UPLINK && psCBuilding->status == SS_BUILT)
{
setSatUplinkExists(true, i);
}
Expand All @@ -472,7 +476,11 @@ void countUpdate(bool synch)
}
for (const STRUCTURE *psCBuilding : mission.apsStructLists[i])
{
if (psCBuilding->pStructureType->type == REF_SAT_UPLINK && psCBuilding->status == SS_BUILT)
if (psCBuilding == nullptr || isDead(psCBuilding))
{
continue;
}
if (psCBuilding->pStructureType && psCBuilding->pStructureType->type == REF_SAT_UPLINK && psCBuilding->status == SS_BUILT)
{
setSatUplinkExists(true, i);
}
Expand Down
10 changes: 9 additions & 1 deletion src/scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,17 @@ END_GAME_STATS_DATA collectEndGameStatsData()
}
for (const DROID* psDroid : *dList)
{
if (psDroid == nullptr || isDead(psDroid))
{
continue;
}
++fullStats.numUnits;
if (psDroid->isTransporter())
{
if (psDroid->psGroup == nullptr)
{
continue;
}
for (DROID *psCurr : psDroid->psGroup->psList)
{
if (psCurr != psDroid)
Expand All @@ -320,7 +329,6 @@ END_GAME_STATS_DATA collectEndGameStatsData()
}
}
}
++fullStats.numUnits;
}
} while (++idx < 3);
}
Expand Down
Loading