diff --git a/src/Features/Speedrun/Categories.cpp b/src/Features/Speedrun/Categories.cpp index 47e8b3c7e..f616e670e 100644 --- a/src/Features/Speedrun/Categories.cpp +++ b/src/Features/Speedrun/Categories.cpp @@ -252,7 +252,7 @@ ON_EVENT(RENDER) { for (std::string ruleName : g_categories[g_currentCategory].rules) { auto rule = SpeedrunTimer::GetRule(ruleName); if (!rule) continue; - if (rule->map != engine->GetCurrentMapName()) continue; + if (std::find(rule->maps.begin(), rule->maps.end(), engine->GetCurrentMapName()) == rule->maps.end()) continue; if (std::holds_alternative(rule->rule)) { std::get(rule->rule).DrawInWorld(); std::get(rule->rule).OverlayInfo(rule); @@ -541,7 +541,17 @@ bool SpeedrunTimer::CreateRule(std::string name, std::string type, std::mapaction = action; - rule->map = params["map"]; + + std::string mapToken, delimiter = "|"; + if (params["map"].find(delimiter) != std::string::npos) { + size_t pos = 0; + while ((pos = params["map"].find(delimiter)) != std::string::npos) { + mapToken = params["map"].substr(0, pos); + rule->maps.push_back(mapToken); + params["map"].erase(0, pos + delimiter.length()); + } + } + if (params["map"].length() > 0) rule->maps.push_back(params["map"]); auto after = lookupMap(params, "after"); if (!after) { diff --git a/src/Features/Speedrun/Rules.cpp b/src/Features/Speedrun/Rules.cpp index 841ef3343..1b0e61ad0 100644 --- a/src/Features/Speedrun/Rules.cpp +++ b/src/Features/Speedrun/Rules.cpp @@ -282,7 +282,7 @@ bool SpeedrunRule::TestGeneral(std::optional slot) { auto prereq = SpeedrunTimer::GetRule(*this->onlyAfter); if (!prereq || !prereq->fired) return false; } - if (engine->GetCurrentMapName() != this->map) return false; + if (std::find(this->maps.begin(), this->maps.end(), engine->GetCurrentMapName()) == this->maps.end()) return false; if (this->slot) { if (this->slot != slot) return false; } @@ -311,7 +311,12 @@ static const char *printRuleAction(RuleAction action) { std::string SpeedrunRule::Describe() { std::string s = std::string("action=") + printRuleAction(this->action); - s += " map=" + this->map; + s += " maps="; + for (auto it = this->maps.begin(); it != this->maps.end(); ++it) { + if (it == this->maps.begin()) continue; + s += *it; + if (it + 1 != this->maps.end()) s += ","; + } if (this->cycle) { s += Utils::ssprintf(" cycle=%d,%d", this->cycle->first, this->cycle->second); } diff --git a/src/Features/Speedrun/Rules.hpp b/src/Features/Speedrun/Rules.hpp index abedd04c9..8d3dff11d 100644 --- a/src/Features/Speedrun/Rules.hpp +++ b/src/Features/Speedrun/Rules.hpp @@ -97,7 +97,7 @@ struct SpeedrunRule { RuleAction action; - std::string map; + std::vector maps; std::optional onlyAfter; std::optional slot; std::optional> cycle; @@ -109,7 +109,16 @@ struct SpeedrunRule { SpeedrunRule(RuleAction action, std::string map, _RuleTypes rule) : action(action) - , map(map) + , maps({map}) + , onlyAfter() + , slot() + , rule(rule) + , fired(false) { + } + + SpeedrunRule(RuleAction action, std::vector maps, _RuleTypes rule) + : action(action) + , maps(maps) , onlyAfter() , slot() , rule(rule)