Permit starting a netgame or match race from the console via the map command

None of the following can be combined together, and Grand Prix is still the default with no parameter from the menus.

- `-server`
    - Starts a server
- `-match`
    - Starts a Match (Race) round
- `-skill`
    - Already existed, but can now only be used for GP

Also guarantees the main menu wil be closed, which wasn't previously guaranteed.
This commit is contained in:
toaster 2023-07-22 16:55:30 +01:00
parent 7c3d3282f0
commit 67a1fda79b

View file

@ -2877,6 +2877,8 @@ static void Command_Map_f(void)
size_t option_gametype;
size_t option_encore;
size_t option_skill;
size_t option_server;
size_t option_match;
boolean newresetplayers;
boolean newforcespecialstage;
@ -2900,7 +2902,9 @@ static void Command_Map_f(void)
option_force = COM_CheckPartialParm("-f");
option_gametype = COM_CheckPartialParm("-g");
option_encore = COM_CheckPartialParm("-e");
option_skill = COM_CheckPartialParm("-s");
option_skill = COM_CheckParm("-skill");
option_server = COM_CheckParm("-server");
option_match = COM_CheckParm("-match");
newresetplayers = ! COM_CheckParm("-noresetplayers");
newforcespecialstage = COM_CheckParm("-forcespecialstage");
@ -3011,10 +3015,73 @@ static void Command_Map_f(void)
}
}
if (!(netgame || multiplayer))
{
if ((option_match && option_server)
|| (option_match && option_skill)
|| (option_server && option_skill))
{
CONS_Alert(CONS_WARNING, M_GetText("These options can't be combined.\nSelect only one out of -server, -match, or -skill.\n"));
Z_Free(realmapname);
Z_Free(mapname);
return;
}
if (!Playing())
{
UINT8 ssplayers = cv_splitplayers.value-1;
boolean newnetgame = (option_server != 0);
multiplayer = true;
netgame = false;
strncpy(connectedservername, cv_servername.string, MAXSERVERNAME);
if (cv_maxconnections.value < ssplayers+1)
CV_SetValue(&cv_maxconnections, ssplayers+1);
SV_StartSinglePlayerServer(newgametype, newnetgame);
if (splitscreen != ssplayers)
{
splitscreen = ssplayers;
SplitScreen_OnChange();
}
if (!newnetgame && option_match == 0)
{
grandprixinfo.gp = true;
grandprixinfo.initalize = true;
grandprixinfo.cup = NULL;
grandprixinfo.gamespeed = (cv_kartspeed.value == KARTSPEED_AUTO ? KARTSPEED_NORMAL : cv_kartspeed.value);
grandprixinfo.masterbots = false;
}
if (newnetgame)
{
restoreMenu = &PLAY_MP_OptSelectDef;
}
else
{
restoreMenu = NULL;
}
M_ClearMenus(true);
}
else if (
((grandprixinfo.gp == true ? option_match : option_skill) != 0) // Can't swap between.
|| (!netgame && (option_server != 0)) // Can't promote to server.
)
{
CONS_Alert(CONS_WARNING, M_GetText("You are already playing a game.\nReturn to the menu to use this option.\n"));
Z_Free(realmapname);
Z_Free(mapname);
return;
}
if (grandprixinfo.gp)
{
grandprixinfo.wonround = false;
if (option_skill)
{
@ -3052,30 +3119,6 @@ static void Command_Map_f(void)
}
}
}
grandprixinfo.gp = true;
grandprixinfo.wonround = false;
if (!Playing())
{
UINT8 ssplayers = cv_splitplayers.value-1;
grandprixinfo.cup = NULL;
grandprixinfo.initalize = true;
multiplayer = true;
restoreMenu = NULL;
strncpy(connectedservername, cv_servername.string, MAXSERVERNAME);
if (cv_maxconnections.value < ssplayers+1)
CV_SetValue(&cv_maxconnections, ssplayers+1);
if (splitscreen != ssplayers)
{
splitscreen = ssplayers;
SplitScreen_OnChange();
}
}
}