diff --git a/src/cli.c b/src/cli.c index 7d05cd48..1676ff18 100644 --- a/src/cli.c +++ b/src/cli.c @@ -29,6 +29,7 @@ enum { OPT_FORCE_INTRO, OPT_REREPLAY, OPT_POPCACHE, + OPT_UNLOCKALL, }; static void print_help(struct TsOption* opts) { @@ -89,6 +90,7 @@ int cli_args(int argc, char **argv, CLIAction *a) { {{"list-cutscenes", no_argument, 0, OPT_CUTSCENE_LIST}, "List all registered cutscenes with their numeric IDs and names, then exit" }, {{"intro", no_argument, 0, OPT_FORCE_INTRO}, "Play the intro cutscene even if already seen"}, {{"skip-to-bookmark", required_argument, 0, 'b'}, "Fast-forward stage to a specific STAGE_BOOKMARK call"}, + {{"unlock-all", no_argument, 0, OPT_UNLOCKALL}, "Unlock all content"}, #endif {{"frameskip", optional_argument, 0, 'f'}, "Disable FPS limiter, render only every %s frame", "FRAME"}, {{"credits", no_argument, 0, 'c'}, "Show the credits scene and exit"}, @@ -252,6 +254,9 @@ int cli_args(int argc, char **argv, CLIAction *a) { env_set("TAISEI_AGGRESSIVE_PRELOAD", 1, true); a->type = CLI_QuitLate; break; + case OPT_UNLOCKALL: + a->unlock_all = true; + break; default: UNREACHABLE; } diff --git a/src/cli.h b/src/cli.h index f2890ba8..dc784ba0 100644 --- a/src/cli.h +++ b/src/cli.h @@ -26,15 +26,16 @@ typedef enum { typedef struct CLIAction CLIAction; struct CLIAction { + char *filename; + char *out_replay; + PlayerMode *plrmode; CLIActionType type; - bool force_intro; int stageid; int diff; int frameskip; CutsceneID cutscene; - char *filename; - char *out_replay; - PlayerMode *plrmode; + bool force_intro; + bool unlock_all; }; int cli_args(int argc, char **argv, CLIAction *a); diff --git a/src/main.c b/src/main.c index fa2dcfa3..104e161f 100644 --- a/src/main.c +++ b/src/main.c @@ -390,6 +390,12 @@ static void main_post_vfsinit(CallChainResult ccr) { menu_preload(&ctx->rg); gamepad_init(); progress_load(); + + if(ctx->cli.unlock_all) { + log_info("Unlocking all content because of --unlock-all"); + progress_unlock_all(); + } + video_post_init(); set_transition(TransLoader, 0, FADE_TIME*2, NO_CALLCHAIN); diff --git a/src/progress.c b/src/progress.c index f7f9f7cb..9fdd1280 100644 --- a/src/progress.c +++ b/src/progress.c @@ -719,13 +719,14 @@ static void progress_write(SDL_RWops *file) { SDL_RWclose(vfile); } -#ifdef PROGRESS_UNLOCK_ALL -static void progress_unlock_all(void) { - StageInfo *stg; +void progress_unlock_all(void) { + size_t num_stages = stageinfo_get_num_stages(); + + for(size_t i = 0; i < num_stages; ++i) { + StageInfo *stg = NOT_NULL(stageinfo_get_by_index(i)); - for(stg = stages; stg->procs; ++stg) { for(Difficulty diff = D_Any; diff <= D_Lunatic; ++diff) { - StageProgress *p = stage_get_progress_from_info(stg, diff, true); + StageProgress *p = stageinfo_get_progress(stg, diff, true); if(p) { p->unlocked = true; } @@ -733,8 +734,12 @@ static void progress_unlock_all(void) { } progress.unlocked_bgms = UINT64_MAX; + progress.unlocked_cutscenes = UINT64_MAX; + + for(int i = 0; i < NUM_ENDINGS; ++i) { + progress.achieved_endings[i] = imax(1, progress.achieved_endings[i]); + } } -#endif static void fix_ending_cutscene(EndingID ending, CutsceneID cutscene) { if(progress.achieved_endings[ending] > 0) { diff --git a/src/progress.h b/src/progress.h index 131aae25..730ed38d 100644 --- a/src/progress.h +++ b/src/progress.h @@ -16,10 +16,6 @@ #define PROGRESS_FILE "storage/progress.dat" #define PROGRESS_MAXFILESIZE 4096 -#ifdef DEBUG - // #define PROGRESS_UNLOCK_ALL -#endif - typedef enum ProgfileCommand { // Do not reorder this! @@ -113,6 +109,7 @@ extern GlobalProgress progress; void progress_load(void); void progress_save(void); void progress_unload(void); +void progress_unlock_all(void); uint32_t progress_times_any_ending_achieved(void); uint32_t progress_times_any_good_ending_achieved(void);