From 1760c9e3b3afe7bca60511be4304e1384df30565 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 14 Nov 2015 08:41:31 +0000 Subject: [PATCH] Centralized mission failure logic. --- src/battle/objectives.c | 2 -- src/battle/player.c | 10 ++-------- src/battle/player.h | 1 + src/galaxy/mission.h | 1 + 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/battle/objectives.c b/src/battle/objectives.c index 3b2b206..b708282 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -79,8 +79,6 @@ void doObjectives(void) if (objectiveFailed) { failMission(); - - failIncompleteObjectives(); } } } diff --git a/src/battle/player.c b/src/battle/player.c index bdcd964..84406fd 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -132,10 +132,7 @@ void doPlayer(void) { if (!battle.epic) { - failIncompleteObjectives(); - - battle.status = MS_FAILED; - battle.missionFinishedTimer = FPS; + failMission(); } else if (player->health == -FPS) { @@ -171,10 +168,7 @@ void initPlayerSelect(void) { battle.epic = 0; - failIncompleteObjectives(); - - battle.status = MS_FAILED; - battle.missionFinishedTimer = FPS; + failMission(); } } diff --git a/src/battle/player.h b/src/battle/player.h index bf00211..dc40794 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -33,6 +33,7 @@ extern int getDistance(int x1, int y1, int x2, int y2); extern void failIncompleteObjectives(void); extern void addHudMessage(SDL_Color c, char *format, ...); extern int mod(int n, int x); +extern void failMission(void); extern App app; extern Battle battle; diff --git a/src/galaxy/mission.h b/src/galaxy/mission.h index 5828811..a2c8ab2 100644 --- a/src/galaxy/mission.h +++ b/src/galaxy/mission.h @@ -39,6 +39,7 @@ extern Entity *spawnWaypoint(void); extern void activateNextWaypoint(void); extern void selectWidget(const char *name, const char *group); extern Entity *spawnExtractionPoint(void); +extern void failIncompleteObjectives(void); extern Battle battle; extern Entity *player;