diff --git a/src/droid.cpp b/src/droid.cpp index 970cf33b9ce..237868c1b14 100644 --- a/src/droid.cpp +++ b/src/droid.cpp @@ -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) diff --git a/src/scores.cpp b/src/scores.cpp index ef32fc5e015..70e12a5843c 100644 --- a/src/scores.cpp +++ b/src/scores.cpp @@ -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) @@ -320,7 +329,6 @@ END_GAME_STATS_DATA collectEndGameStatsData() } } } - ++fullStats.numUnits; } } while (++idx < 3); }