Skip to content

Commit

Permalink
DebugMenu: fixed comparator (#3695)
Browse files Browse the repository at this point in the history
Used to cause crashes on debug builds
Also:
[In C++, comparator should return false if its arguments are
equal.](https://codeforces.com/blog/entry/70237)

Co-authored-by: Reguas <64607261+Reguas@users.noreply.github.com>
  • Loading branch information
Regynate and Regynate authored Jan 21, 2025
1 parent 042513f commit f4ac8b1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ChaosMod/Components/DebugMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ DebugMenu::DebugMenu() : Component()
[](const DebugEffect &a, const DebugEffect &b)
{
for (int idx = 0;; idx++)
if (idx >= a.EffectName.size()
|| std::toupper(a.EffectName[idx]) < std::toupper(b.EffectName[idx]))
return true;
else if (idx >= b.EffectName.size()
|| std::toupper(b.EffectName[idx]) < std::toupper(a.EffectName[idx]))
{
if (idx >= a.EffectName.size())
return false;
else if (idx >= b.EffectName.size())
return true;

auto ai = std::toupper(a.EffectName[idx]);
auto bi = std::toupper(b.EffectName[idx]);
if (ai != bi)
return ai < bi;
}
});
}

Expand Down

0 comments on commit f4ac8b1

Please sign in to comment.