restore empty strings in the config to their defaults on startup

This commit is contained in:
oy 2010-08-11 00:31:42 +02:00
parent d37c83962d
commit 1cde96ef79
4 changed files with 18 additions and 0 deletions

View file

@ -2031,6 +2031,9 @@ int main(int argc, const char **argv) // ignore_convention
if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
// restore empty config strings to their defaults
pConfig->RestoreStrings();
m_Client.Engine()->InitLogfile();
// run the client

View file

@ -11,6 +11,7 @@ public:
virtual void Init() = 0;
virtual void Reset() = 0;
virtual void RestoreStrings() = 0;
virtual void Save() = 0;
virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) = 0;

View file

@ -1432,6 +1432,9 @@ int main(int argc, const char **argv) // ignore_convention
// parse the command line arguments
if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
// restore empty config strings to their defaults
pConfig->RestoreStrings();
pServer->Engine()->InitLogfile();

View file

@ -58,6 +58,17 @@ public:
#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_STR
}
virtual void RestoreStrings()
{
#define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc) // nop
#define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) if(!g_Config.m_##Name[0] && def[0]) str_copy(g_Config.m_##Name, def, len);
#include "config_variables.h"
#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_STR
}
virtual void Save()
{