From e9f209836f28b50a2e69f0adc43d0b6dba57de47 Mon Sep 17 00:00:00 2001 From: Meridian Date: Mon, 26 Nov 2018 16:35:05 +0100 Subject: [PATCH] Fix handling a mix of unconscious and MIA units Let's assume we have only 2 units on the craft. - 2 MIA units = craft lost - 2 unconscious units = craft lost - 1 MIA unit + 1 unconscious unit = craft NOT lost (and unconscious unit survives) This is now fixed and in all 3 cases the craft is lost. --- src/Battlescape/DebriefingState.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Battlescape/DebriefingState.cpp b/src/Battlescape/DebriefingState.cpp index e5d0e508cc..3eb9ab2169 100644 --- a/src/Battlescape/DebriefingState.cpp +++ b/src/Battlescape/DebriefingState.cpp @@ -806,6 +806,7 @@ void DebriefingState::prepareDebriefing() int playersSurvived = 0; // if this stays 0 the craft is lost... int playersUnconscious = 0; int playersInEntryArea = 0; + int playersMIA = 0; _stats.push_back(new DebriefingStat("STR_ALIENS_KILLED", false)); _stats.push_back(new DebriefingStat("STR_ALIEN_CORPSES_RECOVERED", false)); @@ -1000,20 +1001,36 @@ void DebriefingState::prepareDebriefing() { playersInEntryArea++; } + else if (aborted) + { + // if aborted, conscious xcom unit that is not on start/end point counts as MIA + playersMIA++; + } playersSurvived++; } else if ((*j)->getOriginalFaction() == FACTION_PLAYER && (*j)->getStatus() == STATUS_DEAD) deadSoldiers++; } // if all our men are unconscious, the aliens get to have their way with them. - if (playersUnconscious == playersSurvived) + if (playersUnconscious + playersMIA == playersSurvived) { - playersSurvived = 0; + playersSurvived = playersMIA; for (std::vector::iterator j = battle->getUnits()->begin(); j != battle->getUnits()->end(); ++j) { if ((*j)->getOriginalFaction() == FACTION_PLAYER && (*j)->getStatus() != STATUS_DEAD) { - (*j)->instaKill(); + if ((*j)->getStatus() == STATUS_UNCONSCIOUS || (*j)->getFaction() == FACTION_HOSTILE) + { + (*j)->instaKill(); + } + else if ((*j)->getStatus() == STATUS_IGNORE_ME && (*j)->getStunlevel() >= (*j)->getHealth()) + { + (*j)->instaKill(); + } + else + { + // do nothing, units will be marked MIA later + } } } }