Skip to content

Commit

Permalink
Updated RemoteConsole, sys_localization_format and log_includeTime to…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
lemonade-dm committed Jan 7, 2023
1 parent bf51cae commit 55faa40
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 62 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
4 changes: 0 additions & 4 deletions Code/Legacy/CrySystem/SystemInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,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
24 changes: 13 additions & 11 deletions Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*
*/
#include <AzCore/PlatformDef.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Socket/AzSocket.h>

#include <AzFramework/StringFunc/StringFunc.h>
Expand All @@ -19,11 +20,8 @@
#include "RemoteConsoleCore.h"
#include <RemoteConsole_Traits_Platform.h>



const int defaultRemoteConsolePort = 4600; // externed in the header to expose publicly


namespace
{
static const int kDefaultBufferSize = 32768;
Expand All @@ -37,19 +35,23 @@ namespace

bool RCON_IsRemoteAllowedToConnect(const AZ::AzSock::AzSocketAddress& connectee)
{
if ((!gEnv) || (!gEnv->pConsole))
auto console = AZ::Interface<AZ::IConsole>::Get();
if ((!gEnv) || console == nullptr)
{
CryLog("Cannot allow incoming connection for remote console, because we do not yet have a console or an environment.");
return false;
}
ICVar* remoteConsoleAllowedHostList = gEnv->pConsole->GetCVar("log_RemoteConsoleAllowedAddresses");
if (!remoteConsoleAllowedHostList)

AZ::CVarFixedString remoteConsoleAllowedHostList;

if (console->GetCvarValue("log_RemoteConsoleAllowedAddresses", remoteConsoleAllowedHostList)
!= AZ::GetValueResult::Success)
{
CryLog("Cannot allow incoming connection for remote console, because there is no registered log_RemoteConsoleAllowedAddresses console variable.");
return false;
}

const char* value = remoteConsoleAllowedHostList->GetString();
const char* value = remoteConsoleAllowedHostList.c_str();
// the default or empty string indicates localhost.
if (!value)
{
Expand Down Expand Up @@ -194,13 +196,13 @@ void SRemoteServer::Run()
}

// this CVAR is optional.
AZ::u16 remotePort = defaultRemoteConsolePort;
ICVar* remoteConsolePort = gEnv->pConsole->GetCVar("log_RemoteConsolePort");
if (remoteConsolePort)
AZ::u16 remotePort = static_cast<AZ::u16>(defaultRemoteConsolePort);
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
{
remotePort = static_cast<AZ::u16>(remoteConsolePort->GetIVal());
console->GetCvarValue("log_RemoteConsolePort", remotePort);
}


//
// There may be multiple processes running, and each process will require a unique port for remote console to work.
// So we need to be able to bind to ascending ports so that automated tests can connect to each process. QA's Automated
Expand Down
9 changes: 9 additions & 0 deletions Registry/Platform/Android/window.setreg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"O3DE": {
"Autoexec": {
"ConsoleCommands": {
"sys_PakLogInvalidFileAccess" : 1
}
}
}
}
9 changes: 9 additions & 0 deletions Registry/Platform/Linux/window.setreg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"O3DE": {
"Autoexec": {
"ConsoleCommands": {
"r_displayInfo": 3
}
}
}
}
10 changes: 10 additions & 0 deletions Registry/Platform/iOS/window.setreg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"O3DE": {
"Autoexec": {
"ConsoleCommands": {
"r_fullscreen": 1,
"sys_PakLogInvalidFileAccess" : 1
}
}
}
}

0 comments on commit 55faa40

Please sign in to comment.