From dcf7277ee9442534edc711d6d541bbd50a431aef Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 27 Jul 2016 16:17:56 +0100 Subject: [PATCH] Only increment player death stat once. --- src/battle/player.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/battle/player.c b/src/battle/player.c index 07e7c1b..8c9d63e 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -38,6 +38,7 @@ static int isPriorityMissionTarget(Entity *e, int dist, int closest); static int targetOutOfRange(void); static void rechargeBoostECM(void); static void setPilotName(void); +static void updateDeathStats(void); static int selectedPlayerIndex; static int availableGuns[BT_MAX]; @@ -146,27 +147,25 @@ void doPlayer(void) if (player->health <= 0 && battle.status == MS_IN_PROGRESS) { - battle.stats[STAT_PLAYER_KILLED]++; - - /* the player is known as "Player", so we need to check the craft they were assigned to */ - if (strcmp(game.currentMission->craft, "ATAF") == 0) - { - awardTrophy("ATAF_DESTROYED"); - } - if (game.currentMission->challengeData.isChallenge) { if (!game.currentMission->challengeData.allowPlayerDeath) { + updateDeathStats(); + failMission(); } } else if (!battle.isEpic) { + updateDeathStats(); + failMission(); } else if (player->health == -FPS) { + updateDeathStats(); + initPlayerSelect(); } } @@ -197,6 +196,17 @@ void doPlayer(void) } } +static void updateDeathStats(void) +{ + battle.stats[STAT_PLAYER_KILLED]++; + + /* the player is known as "Player", so we need to check the craft they were assigned to */ + if (strcmp(game.currentMission->craft, "ATAF") == 0) + { + awardTrophy("ATAF_DESTROYED"); + } +} + static void rechargeBoostECM(void) { int boostTimer, ecmTimer;