Skip to content

Commit

Permalink
FIX: std algorithms in Fingers (can't use const static member)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Mar 4, 2025
1 parent c9148e3 commit 37dca8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Engine/ac/sys_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ struct Fingers

Fingers()
{
std::fill(_fingers.begin(), _fingers.end(), NO_INDEX);
std::fill(_fingers.begin(), _fingers.end(), NO_INDEX_REF);
}

// store fingerId, return given finger index
Expand All @@ -616,7 +616,7 @@ struct Fingers
if (contains(fingerId))
return NO_INDEX; // invalid, fingerId already present

auto it = std::find(_fingers.begin(), _fingers.end(), NO_ID);
auto it = std::find(_fingers.begin(), _fingers.end(), NO_INDEX_REF);
if (it == _fingers.end())
return NO_INDEX; // no slot for new finger

Expand All @@ -637,13 +637,13 @@ struct Fingers
{
int idx = get_index(fingerId);
assert(idx != NO_INDEX);
if (idx != NO_INDEX) {
_fingers[idx] = NO_ID;
}
if (idx != NO_INDEX)
_fingers[idx] = NO_INDEX;
};

private:
const SDL_FingerID NO_ID = -1; // std::find reads by reference, can't be static
// std algorithms accept args by reference, can't be static
const SDL_FingerID NO_INDEX_REF = NO_INDEX;
std::array<SDL_FingerID, MAX_FINGERS> _fingers {};

bool contains(SDL_FingerID fingerId) const
Expand Down

0 comments on commit 37dca8d

Please sign in to comment.