From ba953b2d6dd33e9283fd9da0c682dba3ce96913a Mon Sep 17 00:00:00 2001 From: Boondorl Date: Wed, 2 Jul 2025 00:58:06 -0400 Subject: [PATCH] Improve default starting map Instead of defaulting to MAP01/E1M1, select the map in the first episode after parsing. This significantly improves the autostart and netgame behavior by warping to the first defined and valid level. Also adds -episode to allow more easily specifying which episode to play for mapsets that don't have simple ExMy naming conventions. --- src/d_main.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 83ec01172..fe3812ddd 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -317,6 +317,7 @@ const char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh int NoWipe; // [RH] Allow wipe? (Needs to be set each time) bool singletics = false; // debug flag to cancel adaptiveness FString startmap; +bool setmap; bool autostart; bool advancedemo; FILE *debugfile; @@ -2114,6 +2115,7 @@ static void CheckCmdLine() dmflags3 = flags3; // get skill / episode / map from parms + setmap = false; if (gameinfo.gametype != GAME_Hexen) { startmap = (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"; @@ -2153,7 +2155,7 @@ static void CheckCmdLine() } startmap = CalcMapName (ep, map); - autostart = true; + autostart = setmap = true; } // [RH] Hack to handle +map. The standard console command line handler @@ -2169,7 +2171,7 @@ static void CheckCmdLine() else { startmap = mapvalue; - autostart = true; + autostart = setmap = true; } } @@ -2219,6 +2221,37 @@ static void CheckCmdLine() } } +// Attempt to account for wads with episodes much better when playing online. Defaulting to MAP01 is sometimes +// a really bad idea e.g. if a hub map is the actual start area. +static void CheckEpisodeCmd() +{ + bool setEpisode = false; + int episode = 0; + auto v = Args->CheckValue("-episode"); + if (v != nullptr) + { + episode = atoi(v) - 1; + if (episode < 0 || episode >= AllEpisodes.Size()) + { + Printf("Invalid episode %s\n", v); + episode = 0; + } + else + { + setEpisode = true; + } + } + + // If -warp or +map were already used, keep whatever existing value they had. + if (!setEpisode && setmap) + return; + + startmap = AllEpisodes[episode].mEpisodeMap; + setmap = true; + if (setEpisode) + autostart = true; +} + static void NewFailure () { I_FatalError ("Failed to allocate memory from system heap"); @@ -3288,6 +3321,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw // [RH] Parse through all loaded mapinfo lumps if (!batchrun) Printf ("G_ParseMapInfo: Load map definitions.\n"); G_ParseMapInfo (iwad_info->MapInfo); + CheckEpisodeCmd(); MessageBoxClass = gameinfo.MessageBoxClass; endoomName = gameinfo.Endoom; menuBlurAmount = gameinfo.bluramount;