diff --git a/src/game/common/system/asciistring.cpp b/src/game/common/system/asciistring.cpp index 31400fa06..bee3198c9 100644 --- a/src/game/common/system/asciistring.cpp +++ b/src/game/common/system/asciistring.cpp @@ -389,6 +389,27 @@ void Utf8String::To_Lower() Set(buf); } +/** + * Converts this string to upper case + */ +void Utf8String::To_Upper() +{ + // Size specifically matches original code for compatibility. + char buf[MAX_TO_LOWER_BUF_LEN]; + + if (m_data == nullptr) { + return; + } + + strcpy(buf, Peek()); + + for (char *c = buf; *c != '\0'; ++c) { + *c = toupper(*c); + } + + Set(buf); +} + /** * @brief Convert any windows path separators to posix ('\' to '/'). */ diff --git a/src/game/common/system/asciistring.h b/src/game/common/system/asciistring.h index 30fca0541..5d847e588 100644 --- a/src/game/common/system/asciistring.h +++ b/src/game/common/system/asciistring.h @@ -126,6 +126,7 @@ class Utf8String void Trim(); void To_Lower(); + void To_Upper(); // Not in original code. void Remove_Last_Char(); void Format(const char *format, ...); diff --git a/src/game/common/system/registryget.cpp b/src/game/common/system/registryget.cpp index 2e191efd2..159dcdd82 100644 --- a/src/game/common/system/registryget.cpp +++ b/src/game/common/system/registryget.cpp @@ -90,7 +90,18 @@ bool Get_String_From_Registry(Utf8String subkey, Utf8String value, Utf8String &d return success; #else - return false; + Utf8String key = "CNC_ZH_"; + key += value; + key.To_Upper(); + captainslog_info( + "Get_String_From_Registry (environment) - looking in %s for key %s\n", key.Str(), value.Str()); + const char *env_value = getenv(key.Str()); + bool success = env_value != nullptr; + if (success) { + destination = env_value; + } + + return success; #endif } @@ -108,7 +119,18 @@ bool Get_String_From_Generals_Registry(Utf8String subkey, Utf8String value, Utf8 return success; #else - return false; + Utf8String key = "CNC_GEN_"; + key += value; + key.To_Upper(); + captainslog_info( + "Get_String_From_Generals_Registry (environment) - looking in %s for key %s\n", key.Str(), value.Str()); + const char *env_value = getenv(key.Str()); + bool success = env_value != nullptr; + if (success) { + destination = env_value; + } + + return success; #endif }