sdl3: improve cmdline map selection logic

This commit is contained in:
erysdren 2024-10-13 10:10:43 -05:00
parent 5ec96d087a
commit ffb24fc06f

View file

@ -22,7 +22,7 @@ static bool focused = true;
static Sint64 now = 0, then = 0; static Sint64 now = 0, then = 0;
static int requested_map = 0; static int requested_map = -1;
static void die(const char *fmt, ...) static void die(const char *fmt, ...)
{ {
@ -87,14 +87,15 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
/* get requested map */ /* get requested map */
if (argc > 1) if (argc > 1)
{
requested_map = SDL_atoi(argv[1]); requested_map = SDL_atoi(argv[1]);
SDL_Log("Loading map %d", requested_map); SDL_Log("Loading map %d", requested_map);
if (requested_map >= 0)
game_load_map(&yeti, maps[requested_map]); game_load_map(&yeti, maps[requested_map]);
}
else else
{
game_load_map(&yeti, &map_e1m1); game_load_map(&yeti, &map_e1m1);
}
game_goto(&yeti.game, GAME_MODE_PLAY); game_goto(&yeti.game, GAME_MODE_PLAY);