Skip to content

Commit

Permalink
dynRPG raw - fix for unsuported get<int>() function
Browse files Browse the repository at this point in the history
dynRPG raw - fix for unsuported get<int>() function
(Mac, Android, etc)...

Update constants.h
  • Loading branch information
jetrotal committed Nov 1, 2023
1 parent 5259545 commit dc57ced
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(it->second)) {
return std::get<std::string>(it->second);
}
else {
if (it->second.index() == 0) {
// Handle int case
return std::to_string(std::get<int>(it->second));
}
else if (it->second.index() == 1) {
// Handle string case
return std::get<std::string>(it->second);
}
}
}
}
return "0"; // Key not found
return "0";
}

// Helper function to convert a string to lowercase
Expand Down

0 comments on commit dc57ced

Please sign in to comment.