diff --git a/src/game/game.c b/src/game/game.c index ec24881..ae725ec 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -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; diff --git a/src/hub/hub.c b/src/hub/hub.c index b15880b..3dbb35b 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -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; diff --git a/src/hub/hub.h b/src/hub/hub.h index 675e7e5..6fd39aa 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -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; diff --git a/src/hub/postMission.c b/src/hub/postMission.c index 2b72a58..174f824 100644 --- a/src/hub/postMission.c +++ b/src/hub/postMission.c @@ -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; +} diff --git a/src/hub/postMission.h b/src/hub/postMission.h index 87b6604..a2b279e 100644 --- a/src/hub/postMission.h +++ b/src/hub/postMission.h @@ -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); diff --git a/src/main.c b/src/main.c index 0b8d053..ecb88c2 100644 --- a/src/main.c +++ b/src/main.c @@ -82,6 +82,8 @@ int main(int argc, char *argv[]) nextSecond = SDL_GetTicks() + 1000; awardTrophies(); + + expireTexts(0); } } diff --git a/src/main.h b/src/main.h index 83fe5e6..7ed23c6 100644 --- a/src/main.h +++ b/src/main.h @@ -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; diff --git a/src/system/text.c b/src/system/text.c index 27ff076..1ad2e39 100644 --- a/src/system/text.c +++ b/src/system/text.c @@ -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); } diff --git a/src/test/atlasTest.c b/src/test/atlasTest.c index 09d2839..111e8b6 100644 --- a/src/test/atlasTest.c +++ b/src/test/atlasTest.c @@ -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; } } diff --git a/src/world/world.c b/src/world/world.c index a4fa8fd..305ab92 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -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; diff --git a/src/world/world.h b/src/world/world.h index 371fb23..3668506 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -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;