Skip to content

Commit f7e68b2

Browse files
committed
fix: case-insensitive speedrun trigger map
1 parent a8d51d8 commit f7e68b2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Features/Speedrun/Categories.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <optional>
1616
#include <variant>
1717

18+
#ifdef _WIN32
19+
# define strcasecmp _stricmp
20+
#endif
21+
1822
Variable sar_speedrun_draw_triggers("sar_speedrun_draw_triggers", "0", "Draw the triggers associated with speedrun rules in the world.\n");
1923

2024
static std::optional<std::vector<std::string>> extractPartialArgs(const char *str, const char *cmd) {
@@ -256,8 +260,9 @@ ON_EVENT(RENDER) {
256260
for (std::string ruleName : g_categories[g_currentCategory].rules) {
257261
auto rule = SpeedrunTimer::GetRule(ruleName);
258262
if (!rule) continue;
259-
if (std::find(rule->maps.begin(), rule->maps.end(), "*") == rule->maps.end() &&
260-
std::find(rule->maps.begin(), rule->maps.end(), engine->GetCurrentMapName()) == rule->maps.end()) continue;
263+
if (std::find_if(rule->maps.begin(), rule->maps.end(), [](std::string map) {
264+
return map == "*" || !strcasecmp(map.c_str(), engine->GetCurrentMapName().c_str());
265+
}) == rule->maps.end()) continue;
261266
if (std::holds_alternative<ZoneTriggerRule>(rule->rule)) {
262267
std::get<ZoneTriggerRule>(rule->rule).DrawInWorld();
263268
std::get<ZoneTriggerRule>(rule->rule).OverlayInfo(rule);

src/Features/Speedrun/Rules.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#define TAU 6.28318530718
1515

16+
#ifdef _WIN32
17+
# define strcasecmp _stricmp
18+
#endif
19+
1620
template <typename V>
1721
static inline V *lookupMap(std::map<std::string, V> &m, std::string k) {
1822
auto search = m.find(k);
@@ -343,8 +347,9 @@ bool SpeedrunRule::TestGeneral(std::optional<int> slot) {
343347
auto prereq = SpeedrunTimer::GetRule(*this->onlyAfter);
344348
if (!prereq || !prereq->fired) return false;
345349
}
346-
if (std::find(this->maps.begin(), this->maps.end(), "*") == this->maps.end() &&
347-
std::find(this->maps.begin(), this->maps.end(), engine->GetCurrentMapName()) == this->maps.end()) return false;
350+
if (std::find_if(this->maps.begin(), this->maps.end(), [](std::string map) {
351+
return map == "*" || !strcasecmp(map.c_str(), engine->GetCurrentMapName().c_str());
352+
}) == this->maps.end()) return false;
348353
if (this->slot) {
349354
if (this->slot != slot) return false;
350355
}

0 commit comments

Comments
 (0)