From 28ca97015811225f5be0e70c0feff53ffa07e7bd Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 30 Oct 2010 17:56:38 +0200 Subject: [PATCH] Fixed: #1146 Store last login in client.cfg instead of Registry --- code/ryzom/client/src/client_cfg.cpp | 24 +++++++++++++----------- code/ryzom/client/src/client_cfg.h | 10 ++++++---- code/ryzom/client/src/login.cpp | 9 +++++---- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index a15271527..96054e19c 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -1480,6 +1480,8 @@ void CClientConfig::setValues() // DebugStringManager READ_BOOL_DEV(DebugStringManager) + // LastLogin + READ_STRING_FV(LastLogin) ////////////// // VERBOSES // @@ -2037,11 +2039,11 @@ bool CClientConfig::readBool (const std::string &varName) return bVal; } -void CClientConfig::writeBool (const std::string &varName, bool bVal) +void CClientConfig::writeBool (const std::string &varName, bool bVal, bool bForce) { - CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName); + CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName); if(varPtr) - varPtr->forceAsInt(bVal); + varPtr->forceAsInt(bVal ? 1:0); else nlwarning("CFG: Default value used for '%s' !!!",varName.c_str()); } @@ -2057,9 +2059,9 @@ sint32 CClientConfig::readInt (const std::string &varName) return bVal; } -void CClientConfig::writeInt (const std::string &varName, sint32 bVal) +void CClientConfig::writeInt (const std::string &varName, sint32 bVal, bool bForce) { - CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName); + CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName); if(varPtr) varPtr->forceAsInt(bVal); else @@ -2077,11 +2079,11 @@ double CClientConfig::readDouble (const std::string &varName) return bVal; } -void CClientConfig::writeDouble (const std::string &varName, double bVal) +void CClientConfig::writeDouble (const std::string &varName, double dVal, bool bForce) { - CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName); + CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName); if(varPtr) - varPtr->forceAsDouble(bVal); + varPtr->forceAsDouble(dVal); else nlwarning("CFG: Default value used for '%s' !!!",varName.c_str()); } @@ -2097,11 +2099,11 @@ string CClientConfig::readString (const std::string &varName) return sVal; } -void CClientConfig::writeString (const std::string &varName, const std::string &bVal) +void CClientConfig::writeString (const std::string &varName, const std::string &strVal, bool bForce) { - CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName); + CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName); if(varPtr) - varPtr->forceAsString(bVal); + varPtr->forceAsString(strVal); else nlwarning("CFG: Default value used for '%s' !!!",varName.c_str()); } diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index 4289a1b0b..048869cf6 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -622,6 +622,8 @@ struct CClientConfig bool PreCacheShapes; bool ResetShapeBankOnRetCharSelect; + std::string LastLogin; + uint32 SimulatePacketLossRatio; // Parameters for colors of messages in system info @@ -810,12 +812,12 @@ public: void release (); bool readBool (const std::string &varName); - void writeBool (const std::string &varName, bool val); + void writeBool (const std::string &varName, bool val, bool bForce = false); sint32 readInt (const std::string &varName); - void writeInt (const std::string &varName, sint32 val); + void writeInt (const std::string &varName, sint32 val, bool bForce = false); double readDouble (const std::string &varName); - void writeDouble (const std::string &varName, double val); - void writeString (const std::string &varName, const std::string &bVal); + void writeDouble (const std::string &varName, double val, bool bForce = false); + void writeString (const std::string &varName, const std::string &bVal, bool bForce = false); // return 0 / false if not succeed bool readBoolNoWarning (const std::string &varName); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index cf3df21b7..726d8aa2b 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -733,9 +733,7 @@ void initLoginScreen() ClientApp = ClientCfg.ConfigFile.getVar("Application").asString(0); - CSystemUtils::setRootKey("Software\\Nevrax\\Ryzom"); - - string l = CSystemUtils::getRegKey("Login"); + string l = ClientCfg.LastLogin; if(!l.empty()) { @@ -1106,7 +1104,10 @@ void onlogin(bool vanishScreen = true) removeSpace(LoginPassword); if(!LoginLogin.empty()) - CSystemUtils::setRegKey("Login", LoginLogin); + { + ClientCfg.LastLogin = LoginLogin; + ClientCfg.writeString("LastLogin", ClientCfg.LastLogin, true); + } if(vanishScreen) pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(-1);