From 10ea805659425eb5f0648bfa27366d6531120f7a Mon Sep 17 00:00:00 2001 From: Mauro Junior <45118493+jetrotal@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:59:11 -0300 Subject: [PATCH] dynRPG raw - fix for unsuported get() function dynRPG raw - fix for unsuported get() function (Mac, Android, etc)... --- src/constants.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/constants.h b/src/constants.h index 521367ba489..e04d0342665 100644 --- a/src/constants.h +++ b/src/constants.h @@ -777,10 +777,10 @@ class Constants { {"TERRAIN_EVENT_TRANSPARENT", 3}, // Special Text Parts - {"CR", "Chr(0x0D)"}, - {"LF", "Chr(0x0A)"}, - {"CRLF", "CR..LF"}, - {"QUOTE", "\"\""}, + {"CR", std::string("Chr(0x0D)")}, + {"LF", std::string("Chr(0x0A)")}, + {"CRLF", std::string("CR..LF")}, + {"QUOTE", std::string("\"\"")}, // Text Colors {"TEXTCOLOR_DEFAULT", 0}, @@ -1338,21 +1338,28 @@ class Constants { if (mapIt != mapCollection.end()) { // Use the map associated with the mapName to look up the key in a case-insensitive manner auto& map = mapIt->second; - // Convert the search key and map keys to lowercase (or uppercase) for a case-insensitive search + // Convert the search key to lowercase for a case-insensitive search std::string lowercaseKey = toLower(key); for (auto it = map.begin(); it != map.end(); ++it) { std::string lowercaseMapKey = toLower(it->first); if (lowercaseMapKey == lowercaseKey) { - if (std::holds_alternative(it->second)) { - return std::get(it->second); - } - else { - return std::to_string(std::get(it->second)); - } + // Use std::visit to access the value stored in the variant + std::variant& value = it->second; + std::string result; + std::visit([&result](auto&& arg) { + using T = std::decay_t; + if constexpr (std::is_same_v) { + result = arg; + } + else if constexpr (std::is_same_v) { + result = std::to_string(arg); + } + }, value); + return result; } } } - return "0"; // Key not found + return "0"; // 0 when Key not found } // Helper function to convert a string to lowercase