Skip to content

Commit

Permalink
Fix handling a mix of unconscious and MIA units
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MeridianOXC committed Nov 26, 2018
1 parent db24774 commit e9f2098
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Battlescape/DebriefingState.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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<BattleUnit*>::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
}
}
}
}
Expand Down

0 comments on commit e9f2098

Please sign in to comment.