//------------------------------------------------------------------------ // override values with console player profile defaults void CPlayerProfile::LoadGamerProfileDefaults() { ICVar* pSysSpec = gEnv->pConsole->GetCVar("sys_spec"); if (pSysSpec && !(pSysSpec->GetFlags() & VF_WASINCONFIG)) { gEnv->pSystem->AutoDetectSpec(true); } IPlatformOS::SUserProfileVariant preference; IPlatformOS::TUserName userName = GetName(); unsigned int user; if(gEnv->pSystem->GetPlatformOS()->UserIsSignedIn(userName, user) && user != IPlatformOS::Unknown_User) { if(gEnv->pSystem->GetPlatformOS()->GetUserProfilePreference(user, IPlatformOS::EUPP_CONTROLLER_INVERT_Y, preference)) { TFlowInputData value(preference.GetInt()); SetAttribute("InvertY", value); } if(gEnv->pSystem->GetPlatformOS()->GetUserProfilePreference(user, IPlatformOS::EUPP_CONTROLLER_SENSITIVITY, preference)) { TFlowInputData value(preference.GetFloat()); SetAttribute("Sensitivity", value); } if(gEnv->pSystem->GetPlatformOS()->GetUserProfilePreference(user, IPlatformOS::EUPP_GAME_DIFFICULTY, preference)) { TFlowInputData value(preference.GetInt()); SetAttribute("SP/Difficulty", value); } if(gEnv->pSystem->GetPlatformOS()->GetUserProfilePreference(user, IPlatformOS::EUPP_AIM_ASSIST, preference)) { TFlowInputData value(preference.GetInt()); SetAttribute("AimAssistance", value); } } }
void CRevertibleConfigLoader::ApplyAndStoreCVar( const char *szKey, const char *szValue ) { ICVar * var = gEnv->pConsole->GetCVar(szKey); if (var == NULL) { GameWarning("Variable \"%s\" not found (trying to set it to '%s')", szKey, szValue); return; } const char * oldValue = var->GetString(); if (oldValue!=0 && 0 == strcmp(szValue, oldValue)) { CryLog("No need to change \"%s\" to '%s' as that's also its current value", szKey, szValue ); return; } if (m_allowCheatCVars || (var->GetFlags() & VF_CHEAT) == 0) { const int numStoredCvars = (int)m_savedCVars.size(); #ifndef _RELEASE const char* savedValue = NULL; for (int i=0; i<numStoredCvars; i++) { if (stricmp(m_savedCVars[i].m_name, szKey) == 0) { savedValue = m_savedCVars[i].m_value; break; } } if (savedValue) { GameWarning("Already got an old value for cvar \"%s\" (currently '%s'), about to add another entry...", szKey, savedValue); } #endif SSavedCVar savedCvar; savedCvar.m_name = m_cvarsTextBlock.StoreText(szKey); savedCvar.m_value = m_cvarsTextBlock.StoreText(var->GetString()); if (savedCvar.m_name && savedCvar.m_value) { m_savedCVars.push_back(savedCvar); CryLog("Changing \"%s\" cvar from '%s' to '%s' (now got %" PRISIZE_T " %s to revert when switching game type)", szKey, oldValue, szValue, m_savedCVars.size(), (m_savedCVars.size() == 1) ? "cvar" : "cvars"); } else { GameWarning("!Ran out of room in cvar array.\nPlease increase maxTextBufferSize - current value is %" PRISIZE_T ".\nFor now, game won't remember to undo \"%s = %s\".", m_cvarsTextBlock.GetSizeNeeded(), szKey, var->GetString()); } } else { GameWarning("!Can't change \"%s\" cvar from '%s' to '%s' because it is a cheat var and cannot be changed in release mode", szKey, oldValue, szValue); return; } CryFixedStringT<128> cmd; cmd.Format("%s %s", szKey, szValue); IConsole * pConsole = gEnv->pConsole; pConsole->ExecuteString(cmd.c_str(), true); }