Make live-players default on if not written in default server_config.xml

This commit is contained in:
Benau
2019-01-16 00:59:50 +08:00
parent d1fc7732c3
commit 8951ef0cbf
2 changed files with 13 additions and 5 deletions

View File

@@ -109,8 +109,10 @@ MapServerConfigParam<T, U>::MapServerConfigParam(const char* param_name,
// ============================================================================
void loadServerConfig(const std::string& path)
{
bool default_config = false;
if (path.empty())
{
default_config = true;
g_server_config_path =
file_manager->getUserConfigFile("server_config.xml");
}
@@ -120,11 +122,11 @@ void loadServerConfig(const std::string& path)
->getAbsolutePath(path.c_str()).c_str();
}
const XMLNode* root = file_manager->createXMLTree(g_server_config_path);
loadServerConfigXML(root);
loadServerConfigXML(root, default_config);
} // loadServerConfig
// ----------------------------------------------------------------------------
void loadServerConfigXML(const XMLNode* root)
void loadServerConfigXML(const XMLNode* root, bool default_config)
{
if (!root || root->getName() != "server-config")
{
@@ -133,6 +135,12 @@ void loadServerConfigXML(const XMLNode* root)
"A new file will be created.", g_server_config_path.c_str());
if (root)
delete root;
if (default_config)
{
// Below option will have different default value when writing
// to server_config.xml in config directory
m_live_players = false;
}
writeServerConfigToDisk();
return;
}

View File

@@ -231,9 +231,9 @@ namespace ServerConfig
"mode will not be saved in this config file."));
SERVER_CFG_PREFIX BoolServerConfigParam m_live_players
SERVER_CFG_DEFAULT(BoolServerConfigParam(false, "live-players",
SERVER_CFG_DEFAULT(BoolServerConfigParam(true, "live-players",
"If true, players can live join or spectate the in-progress game. "
"Currently this feature is only available if the current game mode "
"Currently live joining is only available if the current game mode "
"used in server is FFA, CTF or soccer, also no addon karts will be "
"available for players to choose, and official-karts-threshold will "
"be made 1.0."));
@@ -336,7 +336,7 @@ namespace ServerConfig
// ========================================================================
void loadServerConfig(const std::string& path = "");
// ------------------------------------------------------------------------
void loadServerConfigXML(const XMLNode* root);
void loadServerConfigXML(const XMLNode* root, bool default_config = false);
// ------------------------------------------------------------------------
std::string getServerConfigXML();
// ------------------------------------------------------------------------