Ticket #3737: writeValue.patch
File writeValue.patch, 9.6 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup_mp.js
193 193 { 194 194 // Save player name 195 195 Engine.ConfigDB_CreateValue("user", "playername", playername); 196 Engine.ConfigDB_Write File("user", "config/user.cfg");196 Engine.ConfigDB_WriteValueToFile("user", "playername", playername, "config/user.cfg"); 197 197 // Disallow identically named games in the multiplayer lobby 198 198 if (Engine.HasXmppClient()) 199 199 { … … 253 253 if (Engine.HasXmppClient()) 254 254 // Set player lobby presence 255 255 Engine.LobbySetPlayerPresence("playing"); 256 else { 256 else 257 { 257 258 // Only save the player name and host address if they're valid and we're not in the lobby 258 259 Engine.ConfigDB_CreateValue("user", "playername", playername); 260 Engine.ConfigDB_WriteValueToFile("user", "playername", playername, "config/user.cfg"); 259 261 Engine.ConfigDB_CreateValue("user", "multiplayerserver", ip); 260 Engine.ConfigDB_Write File("user", "config/user.cfg");262 Engine.ConfigDB_WriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg"); 261 263 } 262 264 return true; 263 265 } -
binaries/data/mods/public/gui/lobby/prelobby.js
180 180 Engine.PopGuiPage(); 181 181 Engine.SwitchGuiPage("page_lobby.xml"); 182 182 Engine.ConfigDB_CreateValue("user", "playername", sanitizePlayerName(username, true, true)); 183 Engine.ConfigDB_WriteValueToFile("user", "playername", sanitizePlayerName(username, true, true), "config/user.cfg"); 183 184 Engine.ConfigDB_CreateValue("user", "lobby.login", username); 185 Engine.ConfigDB_WriteValueToFile("user", "lobby.login", username, "config/user.cfg"); 184 186 // We only store the encrypted password, so make sure to re-encrypt it if changed before saving. 185 187 if (password != g_EncrytedPassword.substring(0, 10)) 186 188 g_EncrytedPassword = Engine.EncryptPassword(password, username); 187 189 Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncrytedPassword); 188 Engine.ConfigDB_Write File("user", "config/user.cfg");190 Engine.ConfigDB_WriteValueToFile("user", "lobby.password", g_EncrytedPassword, "config/user.cfg"); 189 191 break; 190 192 } 191 193 } -
binaries/data/mods/public/gui/splashscreen/splashscreen.xml
27 27 <object name="btnOK" type="button" style="ModernButtonRed" size="18 100%-45 50%-5 100%-17" hotkey="cancel"> 28 28 <translatableAttribute id="caption">OK</translatableAttribute> 29 29 <action on="Press"><![CDATA[ 30 if (Engine.GetGUIObjectByName("displaySplashScreen").checked) 31 Engine.ConfigDB_CreateValue("user", "splashscreenversion", 0); 32 else 33 Engine.ConfigDB_CreateValue("user", "splashscreenversion", Engine.GetFileMTime("gui/splashscreen/splashscreen.txt")); 34 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 30 let version = Engine.GetGUIObjectByName("displaySplashScreen").checked ? 0 : Engine.GetFileMTime("gui/splashscreen/splashscreen.txt"); 31 Engine.ConfigDB_CreateValue("user", "splashscreenversion", version); 32 Engine.ConfigDB_WriteValueToFile("user", "splashscreenversion", version, "config/user.cfg"); 35 33 Engine.PopGuiPageCB(); 36 34 ]]></action> 37 35 </object> -
source/i18n/L10n.cpp
93 93 return false; 94 94 95 95 g_ConfigDB.SetValueString(CFG_USER, "locale", locale.getName()); 96 g_ConfigDB.Write File(CFG_USER);96 g_ConfigDB.WriteValueToFile(CFG_USER, "locale", locale.getName()); 97 97 return true; 98 98 } 99 99 -
source/network/NetServer.cpp
310 310 311 311 // Cache root descriptor URL to try to avoid discovery next time. 312 312 g_ConfigDB.SetValueString(CFG_USER, "network.upnprootdescurl", urls.controlURL); 313 g_ConfigDB.Write File(CFG_USER);313 g_ConfigDB.WriteValueToFile(CFG_USER, "network.upnprootdescurl", urls.controlURL); 314 314 LOGMESSAGE("Net server: cached UPnP root descriptor URL as %s", urls.controlURL); 315 315 316 316 // Make sure everything is properly freed. -
source/ps/ConfigDB.cpp
398 424 return true; 399 425 } 400 426 427 bool CConfigDB::WriteValueToFile(EConfigNamespace ns, const CStr& name, const CStr& value) 428 { 429 CHECK_NS(false); 430 431 CScopeLock s(&cfgdb_mutex); 432 return WriteValueToFile(ns, name, value, m_ConfigFile[ns]); 433 } 434 435 bool CConfigDB::WriteValueToFile(EConfigNamespace ns, const CStr& name, const CStr& value, const VfsPath& path) 436 { 437 CHECK_NS(false); 438 439 CScopeLock s(&cfgdb_mutex); 440 441 TConfigMap newMap; 442 m_Map[ns].swap(newMap); 443 if (!Reload(ns)) 444 return false; 445 446 SetValueString(ns, name, value); 447 bool ret = WriteFile(ns, path); 448 m_Map[ns].swap(newMap); 449 return ret; 450 } 451 401 452 #undef CHECK_NS -
source/ps/ConfigDB.h
135 148 * false: if an error occurred 136 149 */ 137 150 bool WriteFile(EConfigNamespace ns) const; 151 152 /** 153 * Write a config value to the file specified by 'path' 154 * 155 * Returns: 156 * true: if the config value was successfully saved and written to the file 157 * false: if an error occurred 158 */ 159 bool WriteValueToFile(EConfigNamespace ns, const CStr& name, const CStr& value, const VfsPath& path); 160 161 bool WriteValueToFile(EConfigNamespace ns, const CStr& name, const CStr& value); 138 162 }; 139 163 140 164 -
source/ps/UserReport.cpp
538 538 } 539 539 540 540 g_ConfigDB.SetValueString(CFG_USER, "userreport.id", userID); 541 g_ConfigDB.Write File(CFG_USER);541 g_ConfigDB.WriteValueToFile(CFG_USER, "userreport.id", userID); 542 542 } 543 543 544 544 return userID; … … 555 555 { 556 556 CStr val = CStr::FromInt(enabled ? REPORTER_VERSION : 0); 557 557 g_ConfigDB.SetValueString(CFG_USER, "userreport.enabledversion", val); 558 g_ConfigDB.Write File(CFG_USER);558 g_ConfigDB.WriteValueToFile(CFG_USER, "userreport.enabledversion", val); 559 559 560 560 if (m_Worker) 561 561 m_Worker->SetEnabled(enabled); -
source/ps/scripting/JSInterface_ConfigDB.cpp
73 102 return ret; 74 103 } 75 104 105 bool JSI_ConfigDB::WriteValueToFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path) 106 { 107 EConfigNamespace cfgNs; 108 if (!GetConfigNamespace(cfgNsString, cfgNs)) 109 return false; 110 111 bool ret = g_ConfigDB.WriteValueToFile(cfgNs, name, value, path); 112 return ret; 113 } 114 76 115 bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString) 77 116 { 78 117 EConfigNamespace cfgNs; … … 95 134 96 135 void JSI_ConfigDB::RegisterScriptFunctions(ScriptInterface& scriptInterface) 97 136 { 98 137 scriptInterface.RegisterFunction<std::string, std::wstring, std::string, &JSI_ConfigDB::GetValue>("ConfigDB_GetValue"); 99 138 scriptInterface.RegisterFunction<bool, std::wstring, std::string, std::string, &JSI_ConfigDB::CreateValue>("ConfigDB_CreateValue"); 100 139 scriptInterface.RegisterFunction<bool, std::wstring, Path, &JSI_ConfigDB::WriteFile>("ConfigDB_WriteFile"); 140 scriptInterface.RegisterFunction<bool, std::wstring, std::string, std::string, Path, &JSI_ConfigDB::WriteValueToFile>("ConfigDB_WriteValueToFile"); 101 141 scriptInterface.RegisterFunction<bool, std::wstring, Path, &JSI_ConfigDB::SetFile>("ConfigDB_SetFile"); 102 142 scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::Reload>("ConfigDB_Reload"); 103 104 143 } -
source/ps/scripting/JSInterface_ConfigDB.h
24 24 namespace JSI_ConfigDB 25 25 { 26 26 bool GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs); 27 27 std::string GetValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name); 28 28 bool CreateValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value); 29 29 bool WriteFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path); 30 bool WriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path); 30 31 bool Reload(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString); 31 32 bool SetFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path); 32 33 void RegisterScriptFunctions(ScriptInterface& scriptInterface);