diff --git a/src/constants.h b/src/constants.h index c5c96bd27d4..1bd10a5efde 100644 --- a/src/constants.h +++ b/src/constants.h @@ -1345,12 +1345,17 @@ class Constants { }; // Function to retrieve a value from mapCollection ignoring case - std::string get(const std::string& mapName, const std::string& key) { + std::string get(const std::string& mapName, const std::string& key, bool convertMode = 0 ) { std::unordered_map& selectedMap = MapCollection(mapName); - for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it) - if ( Utils::StrICmp(it->first, key) == 0 ) return std::to_string(it->second); + if (convertMode == 0) // Name 2 ID + for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it) + if ( Utils::StrICmp(it->first, key) == 0 ) return std::to_string(it->second); - return key; // Key not found + if (convertMode == 1) // ID 2 Name + for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it) + if (Utils::StrICmp(std::to_string(it->second), key) == 0) return it->first; + + return key; // Match not found } }; diff --git a/src/game_dynrpg.cpp b/src/game_dynrpg.cpp index 68ba7087a08..c9686cc7ab7 100644 --- a/src/game_dynrpg.cpp +++ b/src/game_dynrpg.cpp @@ -139,7 +139,8 @@ static std::string ParseToken(std::string token, StringView function_name) { return ToString(Main_Data::game_actors->GetActor(number)->GetName()); } else if (*it == 'T' && Player::IsPatchManiac()) { // T (String Var) is last - return Main_Data::game_strings->Get(number); + std::string output(Main_Data::game_strings->Get(number)); + return output; } else { // Variable number = Main_Data::game_variables->Get(number);