Autocomplete mission when Cell and Heart have been found, and we're in MS_MISSING_HEART_CELL.

This commit is contained in:
Steve 2018-03-09 07:32:23 +00:00
parent 0593bca212
commit 61dd0ceb40
5 changed files with 40 additions and 48 deletions

View File

@ -60,6 +60,6 @@ static void touch(Entity *other)
self->alive = ALIVE_DEAD;
updateObjective("HEART_CELL");
updateHeartCellObjective();
}
}

View File

@ -24,7 +24,7 @@ extern Entity *createItem(void);
extern Sprite *getSprite(char *name);
extern void playSound(int snd, int ch);
extern void setGameplayMessage(int type, char *format, ...);
extern void updateObjective(char *targetName);
extern void updateHeartCellObjective(void);
extern Entity *self;
extern Game game;

View File

@ -72,6 +72,6 @@ static void touch(Entity *other)
self->alive = ALIVE_DEAD;
updateObjective("HEART_CELL");
updateHeartCellObjective();
}
}

View File

@ -25,7 +25,7 @@ extern Sprite *getSprite(char *name);
extern void playSound(int snd, int ch);
extern int rrnd(int low, int high);
extern void setGameplayMessage(int type, char *format, ...);
extern void updateObjective(char *targetName);
extern void updateHeartCellObjective(void);
extern Entity *self;
extern Game game;

View File

@ -20,11 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "objectives.h"
static int isMissingHeartCell(char *targetName);
static int countTargetsInWorld(char *targetName);
static int missingHeartCell;
void initObjectives(void)
{
int totalTargets;
@ -32,10 +29,7 @@ void initObjectives(void)
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, "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)
{
@ -111,11 +105,8 @@ void updateObjective(char *targetName)
{
Objective *o;
if (missingHeartCell && !isMissingHeartCell(targetName))
if (world.currentStatus != MS_MISSING_HEART_CELL)
{
return;
}
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
{
if (strcmp(o->targetName, targetName) == 0)
@ -160,29 +151,30 @@ void updateObjective(char *targetName)
{
setGameplayMessage(MSG_OBJECTIVE, _("Mission Complete!"));
}
}
}
static int isMissingHeartCell(char *targetName)
void updateHeartCellObjective(void)
{
Entity *e;
if (targetName == NULL || strcmp(targetName, "HEART_CELL") == 0)
{
return 0;
}
for (e = world.entityHead.next ; e != NULL ; e = e->next)
{
if (e->alive == ALIVE_ALIVE)
{
if (e->type == ET_HEART || e->type == ET_CELL)
{
return 0;
return;
}
}
}
return 1;
if (world.currentStatus == MS_MISSING_HEART_CELL)
{
world.allObjectivesComplete = 1;
setGameplayMessage(MSG_OBJECTIVE, _("Mission Complete!"));
}
}
void destroyObjectives(void)