Skip to content

Commit

Permalink
Removed the loading of the legacy `system_<platform>_<asset_platform>…
Browse files Browse the repository at this point in the history
….cfg` files (#13721)

* Removed the loading of the legacy
`system_<platform>_<asset_platform>.cfg` files

The settings registry has replaced the loading of platform specific
setreg files using the Platform Abstraction Layer to determine platform
specific folders.
This is detailed in the documentation
[here](https://www.o3de.org/docs/user-guide/settings/developer-documentation/#specialization-system-in-depth)

The settings registry can also issue console commands which is described
on the [Issue Console
Commands](https://www.o3de.org/docs/user-guide/settings/issue-az-console-commands/)
page

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated RemoteConsole, sys_localization_format and log_includeTime to AZ CVars

Adding Settings Registry files for setting console variable values that
modify the windows layout to replicate the existing settings from the
old `system_<platform>_<asset_platform>.cfg` files

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removed `system_<platform>_<asset>.cfg` uses from LyTestTools

The test tools were setting the `log_RemoteConsoleAllowedAddresses`
console variable, through those settings files and they have been
updated to specify those values through the command line arguments.
For Android test tools launcher, that console variable is set through
the Settings Registry
'/O3DE/Autoexec/ConsoleCommands/log_RemoteConsoleAllowedAddresses'
mechanism.

Also removed the validation of the `system_<platform>_<asset>.cfg` from
the CMake layout tool `verify_layout` method as it is no longer needed.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
  • Loading branch information
lemonade-dm authored Jan 10, 2023
1 parent d50a3e1 commit c9bb592
Show file tree
Hide file tree
Showing 31 changed files with 126 additions and 351 deletions.
45 changes: 35 additions & 10 deletions Code/Legacy/CrySystem/LocalizedStringManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ const char c_sys_localization_encode[] = "sys_localization_encode";
#endif // !defined(_RELEASE)

#define LOC_WINDOW "Localization"
const char c_sys_localization_format[] = "sys_localization_format";
const char* c_sys_localization_format = "sys_localization_format";
AZ_CVAR(int32_t, sys_localization_format, 0, nullptr, AZ::ConsoleFunctorFlags::Null,
"Usage: sys_localization_format [0..1]\n"
" 0: O3DE Legacy Localization (Excel 2003)\n"
" 1: AGS XML\n"
"Default is 1 (AGS Xml)");

enum ELocalizedXmlColumns
{
Expand Down Expand Up @@ -239,11 +244,6 @@ CLocalizedStringsManager::CLocalizedStringsManager(ISystem* pSystem)
"Default is 1.");
#endif //#if !defined(_RELEASE)

REGISTER_CVAR2(c_sys_localization_format, &m_cvarLocalizationFormat, 1, VF_NULL,
"Usage: sys_localization_format [0..1]\n"
" 0: O3DE Legacy Localization (Excel 2003)\n"
" 1: AGS XML\n"
"Default is 1 (AGS Xml)");
//Check that someone hasn't added a language ID without a language name
assert(PLATFORM_INDEPENDENT_LANGUAGE_NAMES[ ILocalizationManager::ePILID_MAX_OR_INVALID - 1 ] != 0);

Expand All @@ -270,7 +270,13 @@ CLocalizedStringsManager::CLocalizedStringsManager(ISystem* pSystem)
}
}

AZ_Warning("Localization", !(m_cvarLocalizationFormat == 0 && availableLanguages == 0 && ProjectUsesLocalization()), "No localization files found!");
int32_t localizationFormat{};
if (auto console = AZ::Interface<AZ::IConsole>::Get();
console !=nullptr)
{
console->GetCvarValue(c_sys_localization_format, localizationFormat);
}
AZ_Warning("Localization", !(localizationFormat == 0 && availableLanguages == 0 && ProjectUsesLocalization()), "No localization files found!");

SetAvailableLocalizationsBitfield(availableLanguages);
LocalizationManagerRequestBus::Handler::BusConnect();
Expand Down Expand Up @@ -448,7 +454,13 @@ bool CLocalizedStringsManager::SetLanguage(const char* sLanguage)
//////////////////////////////////////////////////////////////////////////
int CLocalizedStringsManager::GetLocalizationFormat() const
{
return m_cvarLocalizationFormat;
int32_t localizationFormat{};
if (auto console = AZ::Interface<AZ::IConsole>::Get();
console !=nullptr)
{
console->GetCvarValue(c_sys_localization_format, localizationFormat);
}
return localizationFormat;
}

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -716,12 +728,19 @@ bool CLocalizedStringsManager::LoadLocalizationDataByTag(

stack_string const sLocalizationFolder(PathUtil::GetLocalizationFolder());

int32_t localizationFormat{};
if (auto console = AZ::Interface<AZ::IConsole>::Get();
console !=nullptr)
{
console->GetCvarValue(c_sys_localization_format, localizationFormat);
}

LoadFunc loadFunction = GetLoadFunction();
TStringVec& vEntries = it->second.filenames;
for (TStringVec::iterator it2 = vEntries.begin(); it2 != vEntries.end(); ++it2)
{
//Only load files of the correct type for the configured format
if ((m_cvarLocalizationFormat == 0 && strstr(it2->c_str(), ".xml")) || (m_cvarLocalizationFormat == 1 && strstr(it2->c_str(), ".agsxml")))
if ((localizationFormat == 0 && strstr(it2->c_str(), ".xml")) || (localizationFormat == 1 && strstr(it2->c_str(), ".agsxml")))
{
bResult &= (this->*loadFunction)(it2->c_str(), it->second.id, bReload);
}
Expand Down Expand Up @@ -1715,7 +1734,13 @@ CLocalizedStringsManager::LoadFunc CLocalizedStringsManager::GetLoadFunction() c
CRY_ASSERT_MESSAGE(gEnv && gEnv->pConsole, "System environment or console missing!");
if (gEnv && gEnv->pConsole)
{
if(m_cvarLocalizationFormat == 1)
int32_t localizationFormat{};
if (auto console = AZ::Interface<AZ::IConsole>::Get();
console !=nullptr)
{
console->GetCvarValue(c_sys_localization_format, localizationFormat);
}
if(localizationFormat == 1)
{
return &CLocalizedStringsManager::DoLoadAGSXmlDocument;
}
Expand Down
1 change: 0 additions & 1 deletion Code/Legacy/CrySystem/LocalizedStringManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class CLocalizedStringsManager
// CVARs
int m_cvarLocalizationDebug;
int m_cvarLocalizationEncode; //Encode/Compress translated text to save memory
int m_cvarLocalizationFormat;

//The localizations that are available for this SKU. Used for determining what to show on a language select screen or whether to show one at all
TLocalizationBitfield m_availableLocalizations;
Expand Down
38 changes: 20 additions & 18 deletions Code/Legacy/CrySystem/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
#include <AzFramework/Utils/SystemUtilsApple.h>
#endif

AZ_CVAR(int32_t, log_IncludeTime, 1, nullptr, AZ::ConsoleFunctorFlags::Null,
"Toggles time stamping of log entries.\n"
"Usage: log_IncludeTime [0/1/2/3/4/5]\n"
" 0=off (default)\n"
" 1=current time\n"
" 2=relative time\n"
" 3=current+relative time\n"
" 4=absolute time in seconds since this mode was started\n"
" 5=current time+server time"
" 6=current date+current time");


//////////////////////////////////////////////////////////////////////
namespace LogCVars
{
Expand Down Expand Up @@ -142,7 +154,6 @@ CLog::CLog(ISystem* pSystem)
m_pLogWriteToFile = 0;
m_pLogWriteToFileVerbosity = 0;
m_pLogVerbosityOverridesWriteToFile = 0;
m_pLogIncludeTime = 0;
m_pLogSpamDelay = 0;
m_pLogModule = 0;
m_fLastLoadingUpdateTime = -1.f; // for streaming engine update
Expand Down Expand Up @@ -201,18 +212,6 @@ void CLog::RegisterConsoleVariables()
"4=additional comments");
m_pLogVerbosityOverridesWriteToFile = REGISTER_INT("log_VerbosityOverridesWriteToFile", 1, VF_DUMPTODISK, "when enabled, setting log_verbosity to 0 will stop all logging including writing to file");

// put time into begin of the string if requested by cvar
m_pLogIncludeTime = REGISTER_INT("log_IncludeTime", 0, 0,
"Toggles time stamping of log entries.\n"
"Usage: log_IncludeTime [0/1/2/3/4/5]\n"
" 0=off (default)\n"
" 1=current time\n"
" 2=relative time\n"
" 3=current+relative time\n"
" 4=absolute time in seconds since this mode was started\n"
" 5=current time+server time"
" 6=current date+current time");

m_pLogSpamDelay = REGISTER_FLOAT("log_SpamDelay", 0.0f, 0, "Sets the minimum time interval between messages classified as spam");

m_pLogModule = REGISTER_STRING("log_Module", "", VF_NULL, "Only show warnings from specified module");
Expand Down Expand Up @@ -253,7 +252,6 @@ void CLog::UnregisterConsoleVariables()
m_pLogWriteToFile = 0;
m_pLogWriteToFileVerbosity = 0;
m_pLogVerbosityOverridesWriteToFile = 0;
m_pLogIncludeTime = 0;
m_pLogSpamDelay = 0;
}

Expand Down Expand Up @@ -754,11 +752,13 @@ void CLog::LogWithCallback(ELogType type, const LogWriteCallback& messageCallbac

// this is a temp timeStr, it is reused in many branches(moved here to reduce stack usage)
LogStringType timeStr;
if (m_pLogIncludeTime)
auto console = AZ::Interface<AZ::IConsole>::Get();
if (uint32_t dwCVarState;
console != nullptr
&& console->GetCvarValue("log_IncludeTime", dwCVarState) == AZ::GetValueResult::Success)
{
// See the log_IncludeTime CVar description as to what
// values correspond to what time strings
const uint32 dwCVarState = m_pLogIncludeTime->GetIVal();
switch (dwCVarState)
{
case 1:
Expand Down Expand Up @@ -1254,11 +1254,13 @@ void CLog::LogStringToFile(AZStd::string_view message, ELogType logType, bool ap
}
#endif

if (m_pLogIncludeTime)
auto console = AZ::Interface<AZ::IConsole>::Get();
if (uint32_t dwCVarState;
console != nullptr
&& console->GetCvarValue("log_IncludeTime", dwCVarState) == AZ::GetValueResult::Success)
{
// See the log_IncludeTime CVar description as to what
// values correspond to what time strings
const uint32 dwCVarState = m_pLogIncludeTime->GetIVal();
switch (dwCVarState)
{
case 1:
Expand Down
2 changes: 0 additions & 2 deletions Code/Legacy/CrySystem/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ class CLog
string m_assetScopeString;
#endif

ICVar* m_pLogIncludeTime; //

IConsole* m_pConsole; //

struct SLogHistoryItem
Expand Down
3 changes: 0 additions & 3 deletions Code/Legacy/CrySystem/RemoteConsole/RemoteConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class CRemoteConsole

#if defined(USE_REMOTE_CONSOLE)
SRemoteServer* m_pServer;
ICVar* m_pLogEnableRemoteConsole = nullptr;
ICVar* m_remoteConsoleAllowedHostList = nullptr;
ICVar* m_remoteConsolePort = nullptr;
#endif
};

Expand Down
30 changes: 17 additions & 13 deletions Code/Legacy/CrySystem/RemoteConsole/RemoteConsole_impl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

#include <RemoteConsoleCore.h>

AZ_CVAR(AZ::CVarFixedString, log_RemoteConsoleAllowedAddresses, "127.0.0.1",
nullptr, AZ::ConsoleFunctorFlags::Null,
"COMMA separated list of allowed hosts or IP addresses which can connect");

AZ_CVAR(bool, log_EnableRemoteConsole, true,
nullptr, AZ::ConsoleFunctorFlags::Null,
"enables/disables the remote console");

AZ_CVAR(uint16_t, log_RemoteConsolePort, static_cast<uint16_t>(defaultRemoteConsolePort),
nullptr, AZ::ConsoleFunctorFlags::Null,
"Base port (4600 for example) for remote console to listen on. It will start there and continue upwards until an unused one is found.");

/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -17,11 +28,7 @@ CRemoteConsole::CRemoteConsole()
: m_listener(1)
, m_lastPortValue(0)
, m_running(false)

, m_pServer(nullptr)
, m_pLogEnableRemoteConsole(nullptr)
, m_remoteConsoleAllowedHostList(nullptr)
, m_remoteConsolePort(nullptr)
{
}

Expand All @@ -34,18 +41,12 @@ CRemoteConsole::~CRemoteConsole()
/////////////////////////////////////////////////////////////////////////////////////////////
void CRemoteConsole::RegisterConsoleVariables()
{
m_pLogEnableRemoteConsole = REGISTER_INT("log_EnableRemoteConsole", 1, VF_DUMPTODISK, "enables/disables the remote console");
m_remoteConsoleAllowedHostList = REGISTER_STRING("log_RemoteConsoleAllowedAddresses", "", VF_DUMPTODISK, "COMMA separated list of allowed hosts or IP addresses which can connect");
m_remoteConsolePort = REGISTER_INT("log_RemoteConsolePort", defaultRemoteConsolePort, VF_DUMPTODISK, "Base port (4600 for example) for remote console to listen on. It will start there and continue upwards until an unused one is found.");
m_lastPortValue = 0;
}

/////////////////////////////////////////////////////////////////////////////////////////////
void CRemoteConsole::UnregisterConsoleVariables()
{
m_pLogEnableRemoteConsole = nullptr;
m_remoteConsoleAllowedHostList = nullptr;
m_remoteConsolePort = nullptr;
}

/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -114,15 +115,18 @@ void CRemoteConsole::AddLogError(AZStd::string_view log)
/////////////////////////////////////////////////////////////////////////////////////////////
void CRemoteConsole::Update()
{
if (m_pLogEnableRemoteConsole)
auto console = AZ::Interface<AZ::IConsole>::Get();
if (bool enableRemoteConsole; console != nullptr
&& console->GetCvarValue("log_EnableRemoteConsole", enableRemoteConsole) == AZ::GetValueResult::Success)
{
// we disable the remote console in the editor, since there is no reason to remote into it and we don't want it eating up that port
// number anyway and preventing the game from using it.
bool isEditor = gEnv && gEnv->IsEditor();
bool isEnabled = (!isEditor) && (m_pLogEnableRemoteConsole->GetIVal());
bool isEnabled = !isEditor && enableRemoteConsole;
bool isStarted = IsStarted();

int newPortValue = m_remoteConsolePort->GetIVal();
uint16_t newPortValue = static_cast<uint16_t>(defaultRemoteConsolePort);
console->GetCvarValue("log_RemoteConsolePort", newPortValue);

// the editor never allows remote control.
if ((isEnabled) && (!isStarted))
Expand Down
1 change: 0 additions & 1 deletion Code/Legacy/CrySystem/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ class CSystem
CCmdLine* m_pCmdLine;

AZStd::string m_currentLanguageAudio;
AZStd::string m_systemConfigName; // computed from system_(hardwareplatform)_(assetsPlatform) - eg, system_android_android.cfg or system_windows_pc.cfg

std::vector< std::pair<CTimeValue, float> > m_updateTimes;

Expand Down
28 changes: 0 additions & 28 deletions Code/Legacy/CrySystem/SystemInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,6 @@ void CSystem::ShutdownFileSystem()
/////////////////////////////////////////////////////////////////////////////////
bool CSystem::InitFileSystem_LoadEngineFolders(const SSystemInitParams&)
{
LoadConfiguration(m_systemConfigName.c_str());
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Loading system configuration from %s...", m_systemConfigName.c_str());

#if defined(AZ_PLATFORM_ANDROID)
AZ::Android::Utils::SetLoadFilesToMemory(m_sys_load_files_to_memory->GetString());
#endif
Expand Down Expand Up @@ -693,25 +690,6 @@ bool CSystem::Init(const SSystemInitParams& startupParams)
azConsole->LinkDeferredFunctors(AZ::ConsoleFunctorBase::GetDeferredHead());
}

if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry)
{
AZ::SettingsRegistryInterface::FixedValueString assetPlatform;
if (!AZ::SettingsRegistryMergeUtils::PlatformGet(*settingsRegistry, assetPlatform,
AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey, "assets"))
{
assetPlatform = AzFramework::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
AZ_Warning(AZ_TRACE_SYSTEM_WINDOW, false, R"(A valid asset platform is missing in "%s/assets" key in the SettingsRegistry.)""\n"
R"(This typically done by setting the "assets" field within a .setreg file)""\n"
R"(A fallback of %s will be used.)",
AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey,
assetPlatform.c_str());
}

m_systemConfigName = "system_" AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER "_";
m_systemConfigName += assetPlatform.c_str();
m_systemConfigName += ".cfg";
}

#if defined(WIN32) || defined(WIN64)
// check OS version - we only want to run on XP or higher - talk to Martin Mittring if you want to change this
{
Expand Down Expand Up @@ -918,8 +896,6 @@ AZ_POP_DISABLE_WARNING
}

{
// We have to load this file again since first time we did it without devmode
LoadConfiguration(m_systemConfigName.c_str());
// Optional user defined overrides
LoadConfiguration("user.cfg");

Expand Down Expand Up @@ -1217,11 +1193,7 @@ void CSystem::CreateSystemVars()
"Default: Localization\n",
CSystem::OnLocalizationFolderCVarChanged);

#if (defined(WIN32) || defined(WIN64)) && defined(_DEBUG)
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 2, 0, "Use or not use floating point exceptions.");
#else // Float exceptions by default disabled for console builds.
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 0, 0, "Use or not use floating point exceptions.");
#endif

REGISTER_CVAR2("sys_update_profile_time", &g_cvars.sys_update_profile_time, 1.0f, 0, "Time to keep updates timings history for.");
REGISTER_CVAR2("sys_no_crash_dialog", &g_cvars.sys_no_crash_dialog, m_bNoCrashDialog, VF_NULL, "Whether to disable the crash dialog window");
Expand Down
Loading

0 comments on commit c9bb592

Please sign in to comment.