Handle mission result correctly.
This commit is contained in:
parent
e887e385c7
commit
5a134f2250
|
@ -40,11 +40,8 @@ void initPostMission(void)
|
|||
|
||||
updateMissionStatus();
|
||||
|
||||
if (status != MS_INCOMPLETE)
|
||||
if (status == MS_COMPLETE || (!world.isReturnVisit && status != MS_INCOMPLETE))
|
||||
{
|
||||
app.delegate.logic = logic;
|
||||
app.delegate.draw = draw;
|
||||
|
||||
app.restrictTrophyAlert = 0;
|
||||
|
||||
canContinue = 0;
|
||||
|
@ -53,8 +50,32 @@ void initPostMission(void)
|
|||
|
||||
playSound(SND_MISSION_COMPLETE, 0);
|
||||
|
||||
app.delegate.logic = logic;
|
||||
app.delegate.draw = draw;
|
||||
|
||||
saveGame();
|
||||
|
||||
saveWorld();
|
||||
|
||||
endSectionTransition();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (world.isReturnVisit)
|
||||
{
|
||||
saveWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
restoreGameState();
|
||||
}
|
||||
|
||||
saveGame();
|
||||
|
||||
destroyWorld();
|
||||
|
||||
initHub();
|
||||
}
|
||||
}
|
||||
|
||||
static void updateMissionStatus(void)
|
||||
|
@ -77,16 +98,6 @@ static void updateMissionStatus(void)
|
|||
|
||||
STRNCPY(t->key, world.id, MAX_NAME_LENGTH);
|
||||
t->value.i = status = getMissionStatus();
|
||||
|
||||
if (status != MS_INCOMPLETE)
|
||||
{
|
||||
saveGame();
|
||||
saveWorld();
|
||||
}
|
||||
else
|
||||
{
|
||||
restoreGameState();
|
||||
}
|
||||
}
|
||||
|
||||
static void logic(void)
|
||||
|
|
|
@ -24,7 +24,6 @@ static int isMissingHeartCell(char *targetName);
|
|||
static int countTargetsInWorld(char *targetName);
|
||||
|
||||
static int missingHeartCell;
|
||||
static int isReturnVisit;
|
||||
static int isEliminateAllEnemies;
|
||||
|
||||
void initObjectives(void)
|
||||
|
@ -32,10 +31,11 @@ void initObjectives(void)
|
|||
int totalTargets;
|
||||
Objective *o;
|
||||
|
||||
isReturnVisit = world.currentStatus == MS_PARTIAL || world.currentStatus == MS_MISSING_HEART_CELL;
|
||||
world.isReturnVisit = world.currentStatus == MS_PARTIAL || world.currentStatus == MS_MISSING_HEART_CELL;
|
||||
|
||||
missingHeartCell = world.currentStatus == MS_MISSING_HEART_CELL;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "isReturnVisit = %d", isReturnVisit);
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.isReturnVisit = %d", world.isReturnVisit);
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "missingHeartCell = %d", missingHeartCell);
|
||||
|
||||
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
|
@ -64,7 +64,7 @@ void initObjectives(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (o->required && isReturnVisit)
|
||||
if (o->required && world.isReturnVisit)
|
||||
{
|
||||
o->targetValue = o->totalValue;
|
||||
o->required = 0;
|
||||
|
@ -150,7 +150,7 @@ void updateObjective(char *targetName)
|
|||
{
|
||||
if (o->currentValue < o->targetValue)
|
||||
{
|
||||
if (o->required || isReturnVisit)
|
||||
if (o->required || world.isReturnVisit)
|
||||
{
|
||||
world.allObjectivesComplete = 0;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ static void drawQuit(void);
|
|||
static void quitMission(void);
|
||||
static void returnFromOptions(void);
|
||||
int getMissionStatus(void);
|
||||
static void completeTrainingMission(void);
|
||||
|
||||
static Texture *background;
|
||||
static int observationIndex;
|
||||
|
@ -663,11 +664,6 @@ int getMissionStatus(void)
|
|||
Objective *o;
|
||||
Entity *e;
|
||||
int status;
|
||||
|
||||
if (world.missionType == MT_TRAINING)
|
||||
{
|
||||
return MS_COMPLETE;
|
||||
}
|
||||
|
||||
status = MS_COMPLETE;
|
||||
|
||||
|
@ -808,6 +804,11 @@ static void quitMission(void)
|
|||
stopMusic();
|
||||
world.state = WS_COMPLETE;
|
||||
world.missionCompleteTimer = (FPS * 1.5) + 1;
|
||||
|
||||
if (world.missionType == MT_TRAINING)
|
||||
{
|
||||
completeTrainingMission();
|
||||
}
|
||||
}
|
||||
|
||||
static void returnFromOptions(void)
|
||||
|
@ -818,6 +819,39 @@ static void returnFromOptions(void)
|
|||
returnFromTrophyStats();
|
||||
}
|
||||
|
||||
static void completeTrainingMission(void)
|
||||
{
|
||||
Objective *o;
|
||||
Entity *e;
|
||||
|
||||
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
{
|
||||
o->currentValue = o->targetValue;
|
||||
}
|
||||
|
||||
for (e = world.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
switch (e->type)
|
||||
{
|
||||
case ET_MIA:
|
||||
e->alive = ALIVE_DEAD;
|
||||
game.stats[STAT_MIAS_RESCUED]++;
|
||||
break;
|
||||
|
||||
case ET_KEY:
|
||||
if (!(e->flags & EF_GONE))
|
||||
{
|
||||
e->alive = ALIVE_DEAD;
|
||||
game.stats[STAT_KEYS_FOUND]++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void destroyWorld(void)
|
||||
{
|
||||
int i;
|
||||
|
|
Loading…
Reference in New Issue