diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-12-05 19:50:27 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-12-05 19:50:27 -0800 |
commit | 645ba66e2dabafd6edda743347ce420174ec4274 (patch) | |
tree | f1a1e542468ecac07a61f996bac8c94cff2a1271 | |
parent | 1d8f30eb26a13c5be62526e201948aaa16caf236 (diff) |
sars,game: add --cheat flag intended for dev/testing
currently this just overrides teepee quantities to always be 128
128 is used instead of 256 so you can still exercise the teepee
boost _without_ winning event, and it doesn't take long to
collect two teepee boosts so iteration still isn't bad.
-rw-r--r-- | src/game.c | 3 | ||||
-rw-r--r-- | src/sars.c | 38 | ||||
-rw-r--r-- | src/sars.h | 1 |
3 files changed, 32 insertions, 10 deletions
@@ -735,6 +735,9 @@ static void update_entities(play_t *play, game_t *game) game->teepee->quantity = quantities[i].qty; } + if (game->sars->cheat) + game->teepee->quantity = 128; + bonus_node_new(&(stage_conf_t){.parent = game->game_node, .active = 1, .alpha = 1.f, .name = "teepee-bonus", .layer = 6}, game->teepee->quantity, &game->sars->projection_x, @@ -236,6 +236,33 @@ sars_winmode_t sars_winmode_set(sars_t *sars, sars_winmode_t winmode) } +/* returns -errno on failure, 0 on success + * but prints errors/warnings so the caller probably doesn't + * care about the errno beyond being a negative value. + */ +static int sars_parse_argv(sars_t *sars, int argc, char *argv[]) +{ + for (int i = 1; i < argc; i++) { + char *flag = argv[i]; + + if (!strcmp(flag, "--window")) { + sars->winmode = SARS_WINMODE_WINDOW; /* this is kinda redundant since we default to windowed now (except on emscripten) */ + if (i + 1 < argc && argv[i + 1][0] != '-' && argv[i + 1][1] != '-') { + /* --window WxH is optionally supported */ + sscanf(argv[i + 1], "%ux%u", &sars->window_width, &sars->window_height); /* FIXME: parse errors */ + i++; + } + } else if (!strcmp(flag, "--cheat")) { + sars->cheat = 1; + } else { + warn_if(1, "Unsupported flag \"%s\", ignoring", argv[i]); + } /* TODO: add --fullscreen? */ + } + + return 0; +} + + static void * sars_init(play_t *play, int argc, char *argv[], unsigned flags) { sars_t *sars; @@ -260,16 +287,7 @@ static void * sars_init(play_t *play, int argc, char *argv[], unsigned flags) sars->window_height = SARS_DEFAULT_HEIGHT; sars->winmode = SARS_DEFAULT_WINMODE; - if (argc > 1) { - /* for now just support --window [WxH] */ - if (!strcasecmp(argv[1], "--window")) { - sars->winmode = SARS_WINMODE_WINDOW; /* this is kinda redundant since we default to windowed now */ - - if (argc > 2) - sscanf(argv[2], "%ux%u", &sars->window_width, &sars->window_height); - } - /* TODO: add --fullscreen? */ - } + fatal_if(sars_parse_argv(sars, argc, argv) < 0, "Unable to parse argv"); #ifdef __EMSCRIPTEN__ /* XXX only request an actual GLES2 context on emscripten, @@ -43,6 +43,7 @@ typedef struct sars_t { stage_t *stage; unsigned window_width, window_height; sars_winmode_t winmode; + unsigned cheat:1; m4f_t projection_x; m4f_t projection_x_inv; |