Keep individually specified RTS files and the rtsname cfg setting completely separate. This fixes a few issues.

git-svn-id: https://svn.eduke32.com/eduke32@6668 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-02-16 08:33:44 +00:00
parent af69391c24
commit a8370e8d0c
4 changed files with 10 additions and 29 deletions

View file

@ -428,8 +428,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{ {
free(g_rtsNamePtr); free(g_rtsNamePtr);
g_rtsNamePtr = dup_filename(argv[i+1]); g_rtsNamePtr = dup_filename(argv[i+1]);
Bstrncpyz(ud.rtsname, g_rtsNamePtr, sizeof(ud.rtsname)); initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr);
initprintf("Using RTS file \"%s\".\n", ud.rtsname);
i++; i++;
} }
i++; i++;
@ -822,8 +821,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{ {
free(g_rtsNamePtr); free(g_rtsNamePtr);
g_rtsNamePtr = dup_filename(argv[i++]); g_rtsNamePtr = dup_filename(argv[i++]);
Bstrncpyz(ud.rtsname, g_rtsNamePtr, sizeof(ud.rtsname)); initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr);
initprintf("Using RTS file \"%s\".\n", ud.rtsname);
continue; continue;
} }
#ifdef LUNATIC #ifdef LUNATIC

View file

@ -452,7 +452,10 @@ void G_LoadGroups(int32_t autoload)
g_defNamePtr = dup_filename(type->defname); g_defNamePtr = dup_filename(type->defname);
if (type->rtsname && g_rtsNamePtr == NULL) if (type->rtsname && g_rtsNamePtr == NULL)
{
free(g_rtsNamePtr);
g_rtsNamePtr = dup_filename(type->rtsname); g_rtsNamePtr = dup_filename(type->rtsname);
}
} }
else else
{ {

View file

@ -260,8 +260,7 @@ void CONFIG_SetDefaults(void)
ud.config.CheckForUpdates = 1; ud.config.CheckForUpdates = 1;
if (g_rtsNamePtr == NULL) Bstrcpy(ud.rtsname, G_DefaultRtsFile());
Bstrcpy(ud.rtsname, G_DefaultRtsFile());
Bstrcpy(szPlayerName, "Player"); Bstrcpy(szPlayerName, "Player");
@ -584,8 +583,7 @@ int32_t CONFIG_ReadSetup(void)
Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName)); 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", "ConfigVersion", &ud.configversion);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.config.ForceSetup); 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]); 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# "; char commmacro[] = "CommbatMacro# ";

View file

@ -6451,29 +6451,12 @@ int app_main(int argc, char const * const * argv)
} }
g_mostConcurrentPlayers = ud.multimode; // XXX: redundant? 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_WriteSetup(1);
CONFIG_ReadSetup(); CONFIG_ReadSetup();
RTS_Init(ud.rtsname); char const * rtsname = g_rtsNamePtr ? g_rtsNamePtr : ud.rtsname;
RTS_Init(rtsname);
if (RTS_IsInitialized())
initprintf("Using RTS file \"%s\".\n", ud.rtsname);
if (ud.last_level)
Bstrcpy(ud.rtsname, defaultrtsfilename[0]);
ud.last_level = -1; ud.last_level = -1;