Skip to content

Commit

Permalink
fix: case-insensitive speedrun trigger map
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Nov 27, 2024
1 parent a8d51d8 commit f7e68b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Features/Speedrun/Categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <optional>
#include <variant>

#ifdef _WIN32
# define strcasecmp _stricmp
#endif

Variable sar_speedrun_draw_triggers("sar_speedrun_draw_triggers", "0", "Draw the triggers associated with speedrun rules in the world.\n");

static std::optional<std::vector<std::string>> extractPartialArgs(const char *str, const char *cmd) {
Expand Down Expand Up @@ -256,8 +260,9 @@ ON_EVENT(RENDER) {
for (std::string ruleName : g_categories[g_currentCategory].rules) {
auto rule = SpeedrunTimer::GetRule(ruleName);
if (!rule) continue;
if (std::find(rule->maps.begin(), rule->maps.end(), "*") == rule->maps.end() &&
std::find(rule->maps.begin(), rule->maps.end(), engine->GetCurrentMapName()) == rule->maps.end()) continue;
if (std::find_if(rule->maps.begin(), rule->maps.end(), [](std::string map) {
return map == "*" || !strcasecmp(map.c_str(), engine->GetCurrentMapName().c_str());
}) == rule->maps.end()) continue;
if (std::holds_alternative<ZoneTriggerRule>(rule->rule)) {
std::get<ZoneTriggerRule>(rule->rule).DrawInWorld();
std::get<ZoneTriggerRule>(rule->rule).OverlayInfo(rule);
Expand Down
9 changes: 7 additions & 2 deletions src/Features/Speedrun/Rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

#define TAU 6.28318530718

#ifdef _WIN32
# define strcasecmp _stricmp
#endif

template <typename V>
static inline V *lookupMap(std::map<std::string, V> &m, std::string k) {
auto search = m.find(k);
Expand Down Expand Up @@ -343,8 +347,9 @@ bool SpeedrunRule::TestGeneral(std::optional<int> slot) {
auto prereq = SpeedrunTimer::GetRule(*this->onlyAfter);
if (!prereq || !prereq->fired) return false;
}
if (std::find(this->maps.begin(), this->maps.end(), "*") == this->maps.end() &&
std::find(this->maps.begin(), this->maps.end(), engine->GetCurrentMapName()) == this->maps.end()) return false;
if (std::find_if(this->maps.begin(), this->maps.end(), [](std::string map) {
return map == "*" || !strcasecmp(map.c_str(), engine->GetCurrentMapName().c_str());
}) == this->maps.end()) return false;
if (this->slot) {
if (this->slot != slot) return false;
}
Expand Down

0 comments on commit f7e68b2

Please sign in to comment.