Skip to content

Commit fcd862e

Browse files
committed
easyrpg_raw: rebase and adapt old code + preparations for future features
1 parent 91288ad commit fcd862e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/constants.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -1345,12 +1345,17 @@ class Constants {
13451345
};
13461346

13471347
// Function to retrieve a value from mapCollection ignoring case
1348-
std::string get(const std::string& mapName, const std::string& key) {
1348+
std::string get(const std::string& mapName, const std::string& key, bool convertMode = 0 ) {
13491349
std::unordered_map<std::string, int>& selectedMap = MapCollection(mapName);
13501350

1351-
for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it)
1352-
if ( Utils::StrICmp(it->first, key) == 0 ) return std::to_string(it->second);
1351+
if (convertMode == 0) // Name 2 ID
1352+
for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it)
1353+
if ( Utils::StrICmp(it->first, key) == 0 ) return std::to_string(it->second);
13531354

1354-
return key; // Key not found
1355+
if (convertMode == 1) // ID 2 Name
1356+
for (auto it = selectedMap.begin(); it != selectedMap.end(); ++it)
1357+
if (Utils::StrICmp(std::to_string(it->second), key) == 0) return it->first;
1358+
1359+
return key; // Match not found
13551360
}
13561361
};

src/game_dynrpg.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static std::string ParseToken(std::string token, StringView function_name) {
139139
return ToString(Main_Data::game_actors->GetActor(number)->GetName());
140140
} else if (*it == 'T' && Player::IsPatchManiac()) {
141141
// T (String Var) is last
142-
return Main_Data::game_strings->Get(number);
142+
std::string output(Main_Data::game_strings->Get(number));
143+
return output;
143144
} else {
144145
// Variable
145146
number = Main_Data::game_variables->Get(number);

0 commit comments

Comments
 (0)