diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index af232cda1..86c61e3f2 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -17,19 +17,22 @@ static void print_help(void) { #if defined(_WIN32) || defined(_WIN64) printf("--console Enables the Windows console.\n"); #endif - printf("--savepath SAVEPATH Overrides the default save/config path ('!' expands to executable path).\n"); - printf("--configfile CONFIGNAME Saves the configuration file as CONFIGNAME.\n"); - printf("--hide-loading-screen Hides the loading screen before the menu boots up.\n"); - printf("--fullscreen Starts the game in full screen mode.\n"); - printf("--windowed Starts the game in windowed mode.\n"); - printf("--skip-intro Skips the Peach and Lakitu intros when on a zero star save.\n"); - printf("--server PORT Starts the game and creates a new server on PORT.\n"); - printf("--client IP PORT Starts the game and joins an existing server.\n"); - printf("--playername PLAYERNAME Starts the game with a specific playername.\n"); - printf("--skip-update-check Skips the update check when loading the game.\n"); - printf("--no-discord Disables discord integration.\n"); - printf("--disable-mods Disables all mods that are already enabled.\n"); - printf("--enable-mod MODNAME Enables a mod."); + printf("--savepath SAVEPATH Overrides the default save/config path ('!' expands to executable path).\n"); + printf("--configfile CONFIGNAME Saves the configuration file as CONFIGNAME.\n"); + printf("--hide-loading-screen Hides the loading screen before the menu boots up.\n"); + printf("--fullscreen Starts the game in full screen mode.\n"); + printf("--windowed Starts the game in windowed mode.\n"); + printf("--width WIDTH Sets the window width.\n"); + printf("--height HEIGHT Sets the window height.\n"); + printf("--skip-intro Skips the Peach and Lakitu intros when on a zero star save.\n"); + printf("--server PORT Starts the game and creates a new server on PORT.\n"); + printf("--client IP PORT Starts the game and joins an existing server.\n"); + printf("--playername PLAYERNAME Starts the game with a specific playername.\n"); + printf("--playercount PLAYERCOUNT Starts the game with a specific player count limit.\n"); + printf("--skip-update-check Skips the update check when loading the game.\n"); + printf("--no-discord Disables discord integration.\n"); + printf("--disable-mods Disables all mods that are already enabled.\n"); + printf("--enable-mod MODNAME Enables a mod."); } static inline int arg_string(const char *name, const char *value, char *target, int maxLength) { @@ -70,6 +73,10 @@ bool parse_cli_opts(int argc, char* argv[]) { gCLIOpts.fullscreen = 1; } else if (!strcmp(argv[i], "--windowed")) { gCLIOpts.fullscreen = 2; + } else if (!strcmp(argv[i], "--width")) { + arg_uint("--width ", argv[++i], &gCLIOpts.width); + } else if (!strcmp(argv[i], "--height")) { + arg_uint("--height ", argv[++i], &gCLIOpts.height); } else if (!strcmp(argv[i], "--skip-intro")) { gCLIOpts.skipIntro = true; } else if (!strcmp(argv[i], "--server") && (i + 1) < argc) { @@ -84,7 +91,9 @@ bool parse_cli_opts(int argc, char* argv[]) { gCLIOpts.networkPort = 7777; } } else if (!strcmp(argv[i], "--playername") && (i + 1) < argc) { - arg_string("--playername", argv[++i], gCLIOpts.playerName, MAX_CONFIG_STRING); + arg_string("--playername ", argv[++i], gCLIOpts.playerName, MAX_CONFIG_STRING); + } else if (!strcmp(argv[i], "--playercount") && (i + 1) < argc) { + arg_uint("--playercount ", argv[++i], &gCLIOpts.playerCount); } else if (!strcmp(argv[i], "--skip-update-check")) { gCLIOpts.skipUpdateCheck = true; } else if (!strcmp(argv[i], "--no-discord")) { diff --git a/src/pc/cliopts.h b/src/pc/cliopts.h index 62d30cdee..94b36f451 100644 --- a/src/pc/cliopts.h +++ b/src/pc/cliopts.h @@ -20,11 +20,14 @@ struct CLIOptions { char savePath[SYS_MAX_PATH]; char configFile[SYS_MAX_PATH]; unsigned int fullscreen; + unsigned int width; + unsigned int height; bool skipIntro; enum NetworkType network; unsigned int networkPort; char joinIp[IP_MAX_LEN]; char playerName[MAX_CONFIG_STRING]; + unsigned int playerCount; bool hideLoadingScreen; bool skipUpdateCheck; bool noDiscord; diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 2b9ac7b11..f10f66304 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -148,7 +148,7 @@ char configPlayerName[MAX_CONFIG_STRING] = ""; unsigned int configPlayerModel = 0; struct PlayerPalette configPlayerPalette = { { { 0x00, 0x00, 0xff }, { 0xff, 0x00, 0x00 }, { 0xff, 0xff, 0xff }, { 0x72, 0x1c, 0x0e }, { 0x73, 0x06, 0x00 }, { 0xfe, 0xc1, 0x79 }, { 0xff, 0x00, 0x00 }, { 0xff, 0x00, 0x00 } } }; // coop settings -unsigned int configAmountofPlayers = MAX_PLAYERS; +unsigned int configAmountOfPlayers = MAX_PLAYERS; bool configBubbleDeath = true; unsigned int configHostPort = DEFAULT_PORT; unsigned int configHostSaveSlot = 1; @@ -283,7 +283,7 @@ static const struct ConfigOption options[] = { {.name = "coop_player_palette_cap", .type = CONFIG_TYPE_COLOR, .colorValue = &configPlayerPalette.parts[CAP]}, {.name = "coop_player_palette_emblem", .type = CONFIG_TYPE_COLOR, .colorValue = &configPlayerPalette.parts[EMBLEM]}, // coop settings - {.name = "amount_of_players", .type = CONFIG_TYPE_UINT, .uintValue = &configAmountofPlayers}, + {.name = "amount_of_players", .type = CONFIG_TYPE_UINT, .uintValue = &configAmountOfPlayers}, {.name = "bubble_death", .type = CONFIG_TYPE_BOOL, .boolValue = &configBubbleDeath}, {.name = "coop_host_port", .type = CONFIG_TYPE_UINT, .uintValue = &configHostPort}, {.name = "coop_host_save_slot", .type = CONFIG_TYPE_UINT, .uintValue = &configHostSaveSlot}, @@ -739,11 +739,25 @@ NEXT_OPTION: if (configDjuiTheme >= DJUI_THEME_MAX) { configDjuiTheme = 0; } if (configDjuiScale >= 5) { configDjuiScale = 0; } + if (gCLIOpts.fullscreen == 1) { + configWindow.fullscreen = true; + } else if (gCLIOpts.fullscreen == 2) { + configWindow.fullscreen = false; + } + if (gCLIOpts.width != 0) { configWindow.w = gCLIOpts.width; } + if (gCLIOpts.height != 0) { configWindow.h = gCLIOpts.height; } + + if (gCLIOpts.playerName[0]) { snprintf(configPlayerName, MAX_CONFIG_STRING, "%s", gCLIOpts.playerName); } + for (int i = 0; i < gCLIOpts.enabledModsCount; i++) { enable_mod(gCLIOpts.enableMods[i]); } free(gCLIOpts.enableMods); + if (gCLIOpts.playerCount != 0) { + configAmountOfPlayers = MIN(gCLIOpts.playerCount, MAX_PLAYERS); + } + #ifndef COOPNET configNetworkSystem = NS_SOCKET; #endif diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 29570e6db..046d898bc 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -101,7 +101,7 @@ extern char configPlayerName[MAX_CONFIG_STRING]; extern unsigned int configPlayerModel; extern struct PlayerPalette configPlayerPalette; // coop settings -extern unsigned int configAmountofPlayers; +extern unsigned int configAmountOfPlayers; extern bool configBubbleDeath; extern unsigned int configHostPort; extern unsigned int configHostSaveSlot; diff --git a/src/pc/discord/discord_activity.c b/src/pc/discord/discord_activity.c index 304044471..43d49c681 100644 --- a/src/pc/discord/discord_activity.c +++ b/src/pc/discord/discord_activity.c @@ -110,7 +110,7 @@ void discord_activity_update(void) { sCurActivity.party.size.max_size = 1; } - if ((sCurActivity.party.size.current_size > 1 || configAmountofPlayers == 1) && !gDjuiInMainMenu) { + if ((sCurActivity.party.size.current_size > 1 || configAmountOfPlayers == 1) && !gDjuiInMainMenu) { strcpy(sCurActivity.state, "Playing!"); } else if (gNetworkType == NT_SERVER) { strcpy(sCurActivity.state, "Waiting for players..."); diff --git a/src/pc/djui/djui_panel_host.c b/src/pc/djui/djui_panel_host.c index 56afb6161..b1b069e4b 100644 --- a/src/pc/djui/djui_panel_host.c +++ b/src/pc/djui/djui_panel_host.c @@ -70,7 +70,7 @@ static void djui_panel_host_do_host(struct DjuiBase* caller) { } // Doesn't let you host if the player limit is not good - if (configAmountofPlayers < 1 || configAmountofPlayers > MAX_PLAYERS) { + if (configAmountOfPlayers < 1 || configAmountOfPlayers > MAX_PLAYERS) { return; } @@ -78,7 +78,7 @@ static void djui_panel_host_do_host(struct DjuiBase* caller) { if (gNetworkType == NT_SERVER) { network_rehost_begin(); - } else if (configNetworkSystem == NS_COOPNET || configAmountofPlayers == 1) { + } else if (configNetworkSystem == NS_COOPNET || configAmountOfPlayers == 1) { network_reset_reconnect_and_rehost(); djui_panel_do_host(false, true); } else { diff --git a/src/pc/djui/djui_panel_host_message.c b/src/pc/djui/djui_panel_host_message.c index ccb05ed98..218564726 100644 --- a/src/pc/djui/djui_panel_host_message.c +++ b/src/pc/djui/djui_panel_host_message.c @@ -24,7 +24,7 @@ void djui_panel_do_host(bool reconnecting, bool playSound) { #ifndef COOPNET if (configNetworkSystem == NS_COOPNET) { configNetworkSystem = NS_SOCKET; } #endif - if (configNetworkSystem == NS_COOPNET && configAmountofPlayers == 1) { configNetworkSystem = NS_SOCKET; } + if (configNetworkSystem == NS_COOPNET && configAmountOfPlayers == 1) { configNetworkSystem = NS_SOCKET; } if (configNetworkSystem >= NS_MAX) { configNetworkSystem = NS_MAX; } network_set_system(configNetworkSystem); diff --git a/src/pc/djui/djui_panel_host_settings.c b/src/pc/djui/djui_panel_host_settings.c index c405ab0e0..068a3b319 100644 --- a/src/pc/djui/djui_panel_host_settings.c +++ b/src/pc/djui/djui_panel_host_settings.c @@ -39,7 +39,7 @@ static void djui_panel_host_player_text_change(struct DjuiBase* caller) { djui_inputbox_set_text_color(inputbox1, 255, 0, 0, 255); return; } - configAmountofPlayers = atoi(sPlayerAmount->buffer); + configAmountOfPlayers = atoi(sPlayerAmount->buffer); } void djui_panel_host_settings_create(struct DjuiBase* caller) { @@ -83,7 +83,7 @@ void djui_panel_host_settings_create(struct DjuiBase* caller) { djui_base_set_size(&inputbox1->base, 0.45f, 32); djui_base_set_alignment(&inputbox1->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); char limitString[32] = { 0 }; - snprintf(limitString, 32, "%d", configAmountofPlayers); + snprintf(limitString, 32, "%d", configAmountOfPlayers); djui_inputbox_set_text(inputbox1, limitString); djui_interactable_hook_value_change(&inputbox1->base, djui_panel_host_player_text_change); sPlayerAmount = inputbox1; diff --git a/src/pc/network/coopnet/coopnet.c b/src/pc/network/coopnet/coopnet.c index 928dba054..d8850acf3 100644 --- a/src/pc/network/coopnet/coopnet.c +++ b/src/pc/network/coopnet/coopnet.c @@ -217,7 +217,7 @@ void ns_coopnet_update(void) { LOG_INFO("Create lobby"); snprintf(gCoopNetPassword, 64, "%s", configPassword); coopnet_populate_description(); - coopnet_lobby_create(GAME_NAME, get_version(), configPlayerName, mode, (uint16_t)configAmountofPlayers, gCoopNetPassword, sCoopNetDescription); + coopnet_lobby_create(GAME_NAME, get_version(), configPlayerName, mode, (uint16_t)configAmountOfPlayers, gCoopNetPassword, sCoopNetDescription); } } else if (sNetworkType == NT_CLIENT) { LOG_INFO("Join lobby"); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 3ba110a69..86eda1ded 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -129,7 +129,7 @@ bool network_init(enum NetworkType inNetworkType, bool reconnecting) { gServerSettings.enablePlayersInLevelDisplay = TRUE; gServerSettings.enablePlayerList = TRUE; gServerSettings.nametags = configNametags; - gServerSettings.maxPlayers = configAmountofPlayers; + gServerSettings.maxPlayers = configAmountOfPlayers; gServerSettings.pauseAnywhere = configPauseAnywhere; gServerSettings.pvpType = configPvpType; #if defined(RAPI_DUMMY) || defined(WAPI_DUMMY) diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 52deb4a6d..7fdaecc0b 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -406,9 +406,6 @@ void* main_game_init(UNUSED void* dummy) { loading_screen_set_segment_text("Starting Game"); ); - if (gCLIOpts.fullscreen == 1) { configWindow.fullscreen = true; } - else if (gCLIOpts.fullscreen == 2) { configWindow.fullscreen = false; } - audio_init(); sound_init(); network_player_init();