diff --git a/src/entities/items/cell.c b/src/entities/items/cell.c index ddc46e8..0b62865 100644 --- a/src/entities/items/cell.c +++ b/src/entities/items/cell.c @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cell.h" static void touch(Entity *other); +static void init(void); Entity *initCell(void) { @@ -39,11 +40,20 @@ Entity *initCell(void) i->spriteFrame = 0; i->spriteTime = -1; + i->init = init; i->touch = touch; return (Entity*)i; } +static void init(void) +{ + if (game.isComplete) + { + self->alive = ALIVE_DEAD; + } +} + static void touch(Entity *other) { if (other != NULL && other->type == ET_BOB && self->alive == ALIVE_ALIVE) diff --git a/src/entities/items/heart.c b/src/entities/items/heart.c index 690ffe4..64183aa 100644 --- a/src/entities/items/heart.c +++ b/src/entities/items/heart.c @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void action(void); static void touch(Entity *other); +static void init(void); Entity *initHeart(Entity *e) { @@ -41,11 +42,20 @@ Entity *initHeart(Entity *e) i->spriteTime = -1; i->action = action; + i->init = init; i->touch = touch; return (Entity*)i; } +static void init(void) +{ + if (game.isComplete) + { + self->alive = ALIVE_DEAD; + } +} + static void action(void) { if (self->isOnGround) diff --git a/src/hub/hub.c b/src/hub/hub.c index 77de093..a7a300c 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -127,6 +127,8 @@ void initHub(void) cursor.x = SCREEN_WIDTH / 2; cursor.y = SCREEN_HEIGHT / 2; SDL_WarpMouseInWindow(app.window, cursor.x * app.scaleX, cursor.y * app.scaleY); + + game.isComplete = 0; for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) { @@ -138,6 +140,13 @@ void initHub(void) if (t->value.i == MS_COMPLETE) { game.stats[STAT_MISSIONS_COMPLETE]++; + + if (strcmp(t->key, "teeka") == 0) + { + game.isComplete = 1; + + unlockTeeka = 0; + } } } @@ -166,7 +175,11 @@ void initHub(void) for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next) { - if (mission->status == MS_MISSING_HEART_CELL) + if (game.isComplete) + { + STRNCPY(mission->description, _("As the game is now complete, free play for this mission has been unlocked."), MAX_DESCRIPTION_LENGTH); + } + else if (mission->status == MS_MISSING_HEART_CELL) { STRNCPY(mission->description, _("All objectives for this misson have been completed. However, there is a Cell or a Heart left to find. See if you can locate it."), MAX_DESCRIPTION_LENGTH); } @@ -483,9 +496,10 @@ static void unlockMission(char *id) { if (strcmp(t->key, id) == 0) { - if (t->value.i == MS_LOCKED) + if (t->value.i == MS_LOCKED || game.isComplete) { t->value.i = MS_INCOMPLETE; + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Unlocked mission %s", id); } diff --git a/src/world/objectives.c b/src/world/objectives.c index fad183b..54b6cef 100644 --- a/src/world/objectives.c +++ b/src/world/objectives.c @@ -27,7 +27,7 @@ void initObjectives(void) int totalTargets; Objective *o; - world.isReturnVisit = world.currentStatus == MS_PARTIAL || world.currentStatus == MS_MISSING_HEART_CELL; + world.isReturnVisit = world.currentStatus == MS_PARTIAL || world.currentStatus == MS_MISSING_HEART_CELL || game.isComplete; SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.isReturnVisit = %d", world.isReturnVisit); diff --git a/src/world/objectives.h b/src/world/objectives.h index 665d2cd..9beef1b 100644 --- a/src/world/objectives.h +++ b/src/world/objectives.h @@ -24,5 +24,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void setGameplayMessage(int type, char *format, ...); +extern Game game; extern World world; - diff --git a/src/world/worldLoader.c b/src/world/worldLoader.c index bd614d8..86802c6 100644 --- a/src/world/worldLoader.c +++ b/src/world/worldLoader.c @@ -40,7 +40,7 @@ void loadWorld(char *id) sprintf(filename, "%s/%s.json", app.saveDir, id); - if (fileExists(filename)) + if (!game.isComplete && fileExists(filename)) { text = readFile(filename); } diff --git a/src/world/worldLoader.h b/src/world/worldLoader.h index 682a7d6..52c88ee 100644 --- a/src/world/worldLoader.h +++ b/src/world/worldLoader.h @@ -28,5 +28,6 @@ extern char *readFile(const char *filename); extern App app; extern Dev dev; extern Entity *self; +extern Game game; extern World world;