diff --git a/source/duke3d/src/cmdline.cpp b/source/duke3d/src/cmdline.cpp index eab0b9bb7..19f04d0ae 100644 --- a/source/duke3d/src/cmdline.cpp +++ b/source/duke3d/src/cmdline.cpp @@ -428,8 +428,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv) { free(g_rtsNamePtr); g_rtsNamePtr = dup_filename(argv[i+1]); - Bstrncpyz(ud.rtsname, g_rtsNamePtr, sizeof(ud.rtsname)); - initprintf("Using RTS file \"%s\".\n", ud.rtsname); + initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr); i++; } i++; @@ -822,8 +821,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv) { free(g_rtsNamePtr); g_rtsNamePtr = dup_filename(argv[i++]); - Bstrncpyz(ud.rtsname, g_rtsNamePtr, sizeof(ud.rtsname)); - initprintf("Using RTS file \"%s\".\n", ud.rtsname); + initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr); continue; } #ifdef LUNATIC diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index 2da7ad4f1..d9a3da1fd 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -452,7 +452,10 @@ void G_LoadGroups(int32_t autoload) g_defNamePtr = dup_filename(type->defname); if (type->rtsname && g_rtsNamePtr == NULL) + { + free(g_rtsNamePtr); g_rtsNamePtr = dup_filename(type->rtsname); + } } else { diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index 3ead450d4..38777ecc0 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -260,8 +260,7 @@ void CONFIG_SetDefaults(void) ud.config.CheckForUpdates = 1; - if (g_rtsNamePtr == NULL) - Bstrcpy(ud.rtsname, G_DefaultRtsFile()); + Bstrcpy(ud.rtsname, G_DefaultRtsFile()); Bstrcpy(szPlayerName, "Player"); @@ -584,8 +583,7 @@ int32_t CONFIG_ReadSetup(void) Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName)); - if (g_rtsNamePtr == NULL) - SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); + SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ConfigVersion", &ud.configversion); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.config.ForceSetup); @@ -860,8 +858,7 @@ void CONFIG_WriteSetup(uint32_t flags) SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","PlayerName",&szPlayerName[0]); - if (g_rtsNamePtr == NULL) - SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); + SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); char commmacro[] = "CommbatMacro# "; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 056bdb175..b42ce5cf5 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6451,29 +6451,12 @@ int app_main(int argc, char const * const * argv) } g_mostConcurrentPlayers = ud.multimode; // XXX: redundant? - ud.last_level = 0; - - // the point of this block is to avoid overwriting the default in the cfg while asserting our selection - if (g_rtsNamePtr == NULL && - (!Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_DUKE]) || - !Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_WW2GI]) || - !Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_NAM]) || - !Bstrcasecmp(ud.rtsname,defaultrtsfilename[GAME_NAPALM]))) - { - // ud.last_level is used as a flag here to reset the string to default after load - ud.last_level = (Bstrcpy(ud.rtsname, G_DefaultRtsFile()) == ud.rtsname); - } CONFIG_WriteSetup(1); CONFIG_ReadSetup(); - RTS_Init(ud.rtsname); - - if (RTS_IsInitialized()) - initprintf("Using RTS file \"%s\".\n", ud.rtsname); - - if (ud.last_level) - Bstrcpy(ud.rtsname, defaultrtsfilename[0]); + char const * rtsname = g_rtsNamePtr ? g_rtsNamePtr : ud.rtsname; + RTS_Init(rtsname); ud.last_level = -1;