Post mission bug fixes.

This commit is contained in:
Steve 2018-02-22 07:45:57 +00:00
parent aba8d5aa3b
commit bd02ee2b4d
11 changed files with 64 additions and 64 deletions

View File

@ -235,6 +235,21 @@ void addKeysFromStash(void)
}
}
int getMissionStatus(char *id)
{
Tuple *t;
for (t = game.missionStatusHead.next ; t != NULL ; t = t->next)
{
if (strcmp(t->key, id) == 0)
{
return t->value.i;
}
}
return MS_LOCKED;
}
static void loadMetaInfo(void)
{
cJSON *root;

View File

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void unlockAllLevels(void);
static void unlockMission(char *id);
static int getMissionStatus(char *id);
static void loadMissions(void);
static void unlockNeighbouringMission(HubMission *sourceMission);
static int missionComparator(const void *a, const void *b);
@ -483,21 +482,6 @@ static void drawMissionInfo(void)
}
}
static int getMissionStatus(char *id)
{
Tuple *t;
for (t = game.missionStatusHead.next ; t != NULL ; t = t->next)
{
if (strcmp(t->key, id) == 0)
{
return t->value.i;
}
}
return MS_LOCKED;
}
static void unlockMission(char *id)
{
Tuple *t;

View File

@ -68,6 +68,7 @@ extern void awardTrophy(char *id);
extern void doTrophies(void);
extern void drawTrophies(void);
extern void initOptions(void (*callback)(void));
extern int getMissionStatus(char *id);
extern App app;
extern Colors colors;

View File

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void logic(void);
static void draw(void);
static void updateMissionStatus(void);
static int getPostMissionStatus(void);
static int status;
static float missionCompleteY;
@ -46,6 +47,8 @@ void initPostMission(void)
canContinue = 0;
oNum = 0;
missionCompleteY = SCREEN_HEIGHT;
playSound(SND_MISSION_COMPLETE, 0);
@ -86,7 +89,7 @@ static void updateMissionStatus(void)
{
if (strcmp(t->key, world.id) == 0)
{
t->value.i = status = getMissionStatus();
t->value.i = status = getPostMissionStatus();
return;
}
}
@ -97,7 +100,7 @@ static void updateMissionStatus(void)
game.missionStatusTail = t;
STRNCPY(t->key, world.id, MAX_NAME_LENGTH);
t->value.i = status = getMissionStatus();
t->value.i = status = getPostMissionStatus();
}
static void logic(void)
@ -175,3 +178,38 @@ static void draw(void)
canContinue = 1;
}
}
static int getPostMissionStatus(void)
{
Objective *o;
Entity *e;
int status;
status = MS_COMPLETE;
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
{
if (o->required && o->currentValue < o->targetValue)
{
return MS_INCOMPLETE;
}
if (o->currentValue < o->totalValue)
{
status = MS_PARTIAL;
}
}
if (status == MS_COMPLETE)
{
for (e = world.entityHead.next ; e != NULL ; e = e->next)
{
if (e->type == ET_HEART_CELL)
{
return MS_MISSING_HEART_CELL;
}
}
}
return status;
}

View File

@ -26,7 +26,6 @@ extern void initHub(void);
extern void saveGame(void);
extern void saveWorld(void);
extern void destroyWorld(void);
extern int getMissionStatus(void);
extern Texture *getTexture(const char *filename);
extern Atlas *getImageFromAtlas(char *filename);
extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center);

View File

@ -82,6 +82,8 @@ int main(int argc, char *argv[])
nextSecond = SDL_GetTicks() + 1000;
awardTrophies();
expireTexts(0);
}
}

View File

@ -33,6 +33,7 @@ extern void initLookups(void);
extern void awardTrophies(void);
extern void doTrophyAlerts(void);
extern void drawTrophyAlert(void);
extern void expireTexts(int all);
App app;
Camera camera;

View File

@ -287,7 +287,7 @@ void expireTexts(int all)
}
}
if (n > 0)
if (all && n > 0)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Expired %d texts", n);
}

View File

@ -34,7 +34,7 @@ void initAtlasTest(void)
loadGame();
test = 3;
test = 1;
switch (test)
{
@ -43,17 +43,12 @@ void initAtlasTest(void)
break;
case 1:
STRNCPY(game.worldId, "beachFront1", MAX_NAME_LENGTH);
STRNCPY(game.worldId, "greenlands1", MAX_NAME_LENGTH);
initWorld();
break;
case 2:
initHub();
break;
case 3:
STRNCPY(game.worldId, "beachFront1", MAX_NAME_LENGTH);
initWorld();
break;
}
}

View File

@ -46,7 +46,6 @@ static void returnFromTrophyStats(void);
static void drawQuit(void);
static void quitMission(void);
static void returnFromOptions(void);
int getMissionStatus(void);
static void completeTrainingMission(void);
static Texture *background;
@ -59,7 +58,7 @@ void initWorld(void)
loadWorld(game.worldId);
world.currentStatus = getMissionStatus();
world.currentStatus = getMissionStatus(game.worldId);
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.currentStatus = %d", world.currentStatus);
@ -659,41 +658,6 @@ static int canAdd(Unit *u, int mx, int my)
return 1;
}
int getMissionStatus(void)
{
Objective *o;
Entity *e;
int status;
status = MS_COMPLETE;
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
{
if (o->required && o->currentValue < o->targetValue)
{
return MS_INCOMPLETE;
}
if (o->currentValue < o->totalValue)
{
status = MS_PARTIAL;
}
}
if (status == MS_COMPLETE)
{
for (e = world.entityHead.next ; e != NULL ; e = e->next)
{
if (e->type == ET_HEART_CELL)
{
return MS_MISSING_HEART_CELL;
}
}
}
return status;
}
void observeActivation(Entity *e)
{
int i;

View File

@ -104,6 +104,7 @@ extern void doTrophies(void);
extern void drawTrophies(void);
extern void limitTextWidth(int width);
extern void initOptions(void (*callback)(void));
extern int getMissionStatus(char *id);
extern App app;
extern Colors colors;