diff --git a/src/constants.h b/src/constants.h index 521367ba489..84e00a6c3c6 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}, @@ -1333,26 +1333,25 @@ class Constants { }; std::string get(const std::string& mapName, const std::string& key) { - // Use the find function to search for the map by name auto mapIt = mapCollection.find(mapName); 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 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 { + if (it->second.index() == 0) { + // Handle int case return std::to_string(std::get(it->second)); } + else if (it->second.index() == 1) { + // Handle string case + return std::get(it->second); + } } } } - return "0"; // Key not found + return "0"; } // Helper function to convert a string to lowercase