diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2023-01-13 09:13:37 +0100 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2023-01-13 09:13:37 +0100 |
commit | a1af9ba65d57be898e079a98229845f42069c1e6 (patch) | |
tree | c984549ef81201be921485c03b027bb137965a6d /src/cli | |
parent | 8f9b0958e8a2d976a274f7c12ee05a4863fce3ad (diff) | |
download | OFQT-a1af9ba65d57be898e079a98229845f42069c1e6.tar.gz OFQT-a1af9ba65d57be898e079a98229845f42069c1e6.zip |
separate launching logic, add run-time option to choose method
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/commands.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/cli/commands.c b/src/cli/commands.c index 9ff4791..08b7ed4 100644 --- a/src/cli/commands.c +++ b/src/cli/commands.c @@ -200,6 +200,48 @@ static int run(int c, char** v) int exit_val = EXIT_SUCCESS; char* of_dir = getOpenFortressDir(); + int (*launch_func)(char**, size_t) = runOpenFortress; + + int arg_index; + for (arg_index = 1; arg_index < c; ++arg_index) + { + if (v[arg_index][0] != '-' && v[arg_index][1] != '-') + break; + + if (!strcmp(v[arg_index]+2, "direct")) + { + + launch_func = runOpenFortressDirect; + } + else if (!strcmp(v[arg_index]+2, "naive")) + { + + launch_func = runOpenFortressNaive; + } + else if (!strcmp(v[arg_index]+2, "steam")) + { + + launch_func = runOpenFortressSteam; + } + else + { + fprintf(stderr, + "OFCL run [flags] [options]\n" + "\n" + " flags:\n" + " --direct launch OpenFortress directly\n" + " --naive tell steam to launch the game\n" + " --steam launch game via Steam\n" + ); + return 0; + } + } + + + if (launch_func == runOpenFortressDirect) { fprintf(stderr, "Launching directly\n"); } + else if (launch_func == runOpenFortressNaive) { fprintf(stderr, "Launching naively\n"); } + else if (launch_func == runOpenFortressSteam) { fprintf(stderr, "Launching via Steam\n"); } + int local_rev = getLocalRevision(of_dir); if (0 > local_rev) { @@ -215,7 +257,7 @@ static int run(int c, char** v) goto run_cleanup; } - runOpenFortress(v+1, (size_t)(c-1)); + launch_func(v+1, (size_t)(c-1)); run_cleanup: free(of_dir); |