twn_loop.c: add --debug and --release overrides, fix incorrect argv iteration
This commit is contained in:
parent
64d1c20b4a
commit
0e68ecbc88
@ -193,9 +193,9 @@ static bool initialize(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* TODO: recognize cli parameter to turn it on on release */
|
||||
/* debug mode _defaults_ to being enabled on debug builds. */
|
||||
/* you should be able to enable it at runtime on any build */
|
||||
/* debug mode defaults to being enabled on debug builds. */
|
||||
/* pass --debug to enable it on release builds */
|
||||
/* or, on debug builds, pass --release to disable it */
|
||||
#ifndef NDEBUG
|
||||
ctx.game.debug = true;
|
||||
#else
|
||||
@ -403,12 +403,33 @@ int enter_loop(int argc, char **argv) {
|
||||
if (!initialize())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
for (int i = 1; i < (argc - 1); ++i) {
|
||||
/* process arguments */
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
/* override data directory */
|
||||
if (SDL_strcmp(argv[i], "--data-dir") == 0) {
|
||||
if (argv[i+1] == NULL || SDL_strncmp(argv[i+1], "--", 2) == 0) {
|
||||
CRY("Data dir mount override failed.", "No arguments passed (expected 1).");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!PHYSFS_mount(argv[i+1], NULL, true)) {
|
||||
CRY_PHYSFS("Data dir mount override failed.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* force debug mode */
|
||||
if (SDL_strcmp(argv[i], "--debug") == 0) {
|
||||
ctx.game.debug = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* force release mode */
|
||||
if (SDL_strcmp(argv[i], "--release") == 0) {
|
||||
ctx.game.debug = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user