Skip to content

Commit

Permalink
Fix potential crash when recording end game unit stats
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Feb 19, 2024
1 parent cd03b07 commit ea751ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,12 +2279,20 @@ UDWORD getNumDroidsForLevel(uint32_t player, UDWORD level)
}
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
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

0 comments on commit ea751ab

Please sign in to comment.