Read setup again after compiling scripts

git-svn-id: https://svn.eduke32.com/eduke32@6339 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-07-08 05:18:51 +00:00
parent b3b40c9581
commit c23b1fe076
2 changed files with 84 additions and 83 deletions

View file

@ -523,116 +523,115 @@ int32_t CONFIG_ReadSetup(void)
CONFIG_SetDefaults(); CONFIG_SetDefaults();
ud.config.setupread = 1; ud.config.setupread = 1;
pathsearchmode = 1; pathsearchmode = 1;
if (SafeFileExists(g_setupFileName) && ud.config.scripthandle < 0) // JBF 20031211
ud.config.scripthandle = SCRIPT_Load(g_setupFileName); if (ud.config.scripthandle < 0)
{
if (SafeFileExists(g_setupFileName)) // JBF 20031211
ud.config.scripthandle = SCRIPT_Load(g_setupFileName);
#if !defined(EDUKE32_TOUCH_DEVICES) && !defined(EDUKE32_STANDALONE) #if !defined(EDUKE32_TOUCH_DEVICES) && !defined(EDUKE32_STANDALONE)
else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0) else if (SafeFileExists(SETUPFILENAME))
{ {
int32_t i; int32_t i;
i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. "
"Import configuration data from \"%s\"?",g_setupFileName,SETUPFILENAME); "Import configuration data from \"%s\"?", g_setupFileName, SETUPFILENAME);
if (i) ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME); if (i) ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME);
} }
else if (SafeFileExists("duke3d.cfg") && ud.config.scripthandle < 0) else if (SafeFileExists("duke3d.cfg"))
{ {
int32_t i; int32_t i;
i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. "
"Import configuration data from \"duke3d.cfg\"?",g_setupFileName); "Import configuration data from \"duke3d.cfg\"?", g_setupFileName);
if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg"); if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg");
} }
#endif #endif
}
pathsearchmode = 0; pathsearchmode = 0;
if (ud.config.scripthandle < 0) return -1; if (ud.config.scripthandle < 0)
return -1;
if (ud.config.scripthandle >= 0) for (dummy = 0; dummy < MAXRIDECULE; dummy++)
{ {
char dummybuf[64]; commmacro[13] = dummy+'0';
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
}
for (dummy = 0; dummy < MAXRIDECULE; dummy++) Bmemset(tempbuf, 0, sizeof(tempbuf));
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
char nameBuf[64];
while (Bstrlen(OSD_StripColors(nameBuf, tempbuf)) > 10)
tempbuf[Bstrlen(tempbuf) - 1] = '\0';
Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName));
if (g_rtsNamePtr == NULL)
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);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.config.NoAutoLoad);
if (g_noSetup == 0 && g_modDir[0] == '/')
{
struct Bstat st;
SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
if (Bstat(g_modDir, &st))
{ {
commmacro[13] = dummy+'0'; if ((st.st_mode & S_IFDIR) != S_IFDIR)
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
}
Bmemset(tempbuf, 0, sizeof(tempbuf));
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
while (Bstrlen(OSD_StripColors(dummybuf,tempbuf)) > 10)
tempbuf[Bstrlen(tempbuf)-1] = '\0';
Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName));
if (g_rtsNamePtr == NULL)
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);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup","NoAutoLoad",&ud.config.NoAutoLoad);
// #ifdef _WIN32
if (g_noSetup == 0 && g_modDir[0] == '/')
{
struct Bstat st;
SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
if (Bstat(g_modDir, &st))
{ {
if ((st.st_mode & S_IFDIR) != S_IFDIR) initprintf("Invalid mod dir in cfg!\n");
{ Bsprintf(g_modDir,"/");
initprintf("Invalid mod dir in cfg!\n");
Bsprintf(g_modDir,"/");
}
} }
} }
// #endif }
if (g_grpNamePtr == NULL && g_addonNum == 0) if (g_grpNamePtr == NULL && g_addonNum == 0)
{ {
SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr); SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr);
if (g_grpNamePtr && !Bstrlen(g_grpNamePtr)) if (g_grpNamePtr && !Bstrlen(g_grpNamePtr))
g_grpNamePtr = dup_filename(G_DefaultGrpFile()); g_grpNamePtr = dup_filename(G_DefaultGrpFile());
} }
if (!NAM_WW2GI) if (!NAM_WW2GI)
{ {
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout);
SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
} }
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos);
windowx = -1;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
windowy = -1;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq); windowx = -1;
windowy = -1;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq);
if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP);
if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32;
#ifdef POLYMER #ifdef POLYMER
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Polymer", &dummy); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Polymer", &dummy);
if (dummy > 0 && ud.config.ScreenBPP >= 16) glrendmode = REND_POLYMER; if (dummy > 0 && ud.config.ScreenBPP >= 16) glrendmode = REND_POLYMER;
else glrendmode = REND_POLYMOST; else glrendmode = REND_POLYMOST;
#endif #endif
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions);
#ifdef _WIN32 #ifdef _WIN32
SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates); SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates);
SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck); SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck);
#endif #endif
}
ud.config.setupread = 1; ud.config.setupread = 1;
return 0; return 0;
} }

View file

@ -6378,6 +6378,8 @@ int app_main(int argc, char const * const * argv)
ud.last_level = (Bstrcpy(ud.rtsname, G_DefaultRtsFile()) == ud.rtsname); ud.last_level = (Bstrcpy(ud.rtsname, G_DefaultRtsFile()) == ud.rtsname);
} }
CONFIG_ReadSetup();
RTS_Init(ud.rtsname); RTS_Init(ud.rtsname);
if (RTS_IsInitialized()) if (RTS_IsInitialized())