add sub function connect: HOST

Start a server using connect command
This commit is contained in:
yellowtd 2016-03-05 22:28:33 -05:00
parent c37c906a03
commit 1816dafbe3
3 changed files with 76 additions and 4 deletions

View file

@ -2112,7 +2112,8 @@ static void Command_connect(void)
CONS_Printf(M_GetText(
"Connect <serveraddress> (port): connect to a server\n"
"Connect ANY: connect to the first lan server found\n"
"Connect SELF: connect to your own server.\n"));
"Connect SELF: connect to your own server.\n"
"Connect HOST <map> <gametype>: "));
return;
}
@ -2127,7 +2128,77 @@ static void Command_connect(void)
server = false;
if (!stricmp(COM_Argv(1), "self"))
// RedEnchilada: host a game from connect
if (!stricmp(COM_Argv(1), "HOST"))
{
const char *mapname;
INT32 newmapnum;
INT32 j, newgametype = INT32_MAX;
if (COM_Argc() != 4)
{
CONS_Printf("Command must be of form \"Connect"
" HOST <MAPxx> <gametype>\".\n");
return;
}
// Get map number from name
mapname = COM_Argv(2);
// internal wad lump always: map command doesn't support external files as in doom legacy
if (W_CheckNumForName(mapname) == LUMPERROR)
{
CONS_Alert(CONS_ERROR, M_GetText("Internal game level '%s' not found\n"), mapname);
return;
}
if (strlen(mapname) != 5
|| (newmapnum = M_MapNumber(mapname[3], mapname[4])) == 0)
{
CONS_Alert(CONS_ERROR, M_GetText("Invalid level name %s\n"), mapname);
return;
}
// Get gametype
for (j = 0; gametype_cons_t[j].strvalue; j++)
if (!strcasecmp(gametype_cons_t[j].strvalue, COM_Argv(3)))
{
// Don't do any variable setting here. Wait until you get your
// map packet first to avoid sending the same info twice!
newgametype = gametype_cons_t[j].value;
break;
}
if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
{
// assume they gave us a gametype number, which is okay too
for (j = 0; gametype_cons_t[j].strvalue != NULL; j++)
{
if (atoi(COM_Argv(3)) == gametype_cons_t[j].value)
{
newgametype = gametype_cons_t[j].value;
break;
}
}
}
if (gametype == INT32_MAX)
{
CONS_Alert(CONS_ERROR, M_GetText("Invalid gametype %s\n"), COM_Argv(3));
return;
}
// Goodbye, we're off to host a server
CV_SetValue(&cv_nextmap, newmapnum);
CV_SetValue(&cv_newgametype, newgametype);
server = true;
M_StartServer(0);
return;
}
else if (!stricmp(COM_Argv(1), "self"))
{
servernode = 0;
server = true;

View file

@ -260,7 +260,6 @@ static void M_ConnectMenu(INT32 choice);
static void M_ConnectIPMenu(INT32 choice);
#endif
static void M_StartSplitServerMenu(INT32 choice);
static void M_StartServer(INT32 choice);
#ifndef NONET
static void M_Refresh(INT32 choice);
static void M_Connect(INT32 choice);
@ -6123,7 +6122,7 @@ static INT32 M_FindFirstMap(INT32 gtype)
return 1;
}
static void M_StartServer(INT32 choice)
void M_StartServer(INT32 choice)
{
boolean StartSplitScreenGame = (currentMenu == &MP_SplitServerDef);

View file

@ -296,4 +296,6 @@ void Screenshot_option_Onchange(void);
NULL\
}
void M_StartServer(INT32 choice);
#endif //__X_MENU__