From 9f4be9a7803114ccef6ca67f428ac5ce79fd8fc2 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 18 Apr 2016 10:54:59 +0100 Subject: [PATCH] If a mission has hidden objectives, don't complete when all current ones are finished. --- src/battle/objectives.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/battle/objectives.c b/src/battle/objectives.c index 759b91d..b6ac80c 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -23,12 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void doObjectives(void) { int objectiveFailed; - int numHiddenObjectives; + int hasHidden; Objective *o; battle.numObjectivesComplete = battle.numObjectivesTotal = battle.numConditions = 0; objectiveFailed = 0; - numHiddenObjectives = 0; + hasHidden = 0; for (o = battle.objectiveHead.next ; o != NULL ; o = o->next) { @@ -45,7 +45,7 @@ void doObjectives(void) } else { - numHiddenObjectives++; + hasHidden = 1; } if (o->currentValue == o->targetValue) @@ -65,7 +65,7 @@ void doObjectives(void) if (battle.status == MS_IN_PROGRESS) { - if (!battle.manualComplete && numHiddenObjectives == 0 && battle.numObjectivesTotal > 0 && battle.numObjectivesComplete == battle.numObjectivesTotal) + if (!battle.manualComplete && !hasHidden && battle.numObjectivesTotal > 0 && battle.numObjectivesComplete == battle.numObjectivesTotal) { completeMission(); } @@ -80,10 +80,12 @@ void doObjectives(void) void updateObjective(char *name, int type) { Objective *o; - int completed; + int completed, hasHidden; completed = battle.numObjectivesComplete; + hasHidden = 0; + for (o = battle.objectiveHead.next ; o != NULL ; o = o->next) { if (o->active && o->status != OS_COMPLETE) @@ -127,9 +129,14 @@ void updateObjective(char *name, int type) runScriptFunction("OBJECTIVES_COMPLETE %d", ++completed); } } + + if (!o->active) + { + hasHidden = 1; + } } - if (completed == battle.numObjectivesTotal) + if (completed == battle.numObjectivesTotal && !hasHidden) { runScriptFunction("ALL_OBJECTIVES_COMPLETE"); }