diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c0179ca1b..d29431226 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2112,7 +2112,8 @@ static void Command_connect(void) CONS_Printf(M_GetText( "Connect (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 : ")); 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 \".\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; diff --git a/src/m_menu.c b/src/m_menu.c index c7a9fcc16..f3c994c59 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -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); diff --git a/src/m_menu.h b/src/m_menu.h index ccb1c1102..05e71d702 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -296,4 +296,6 @@ void Screenshot_option_Onchange(void); NULL\ } +void M_StartServer(INT32 choice); + #endif //__X_MENU__