Properly detect tiles with more than 4 colours

Fixes #1127, which was caused by a dumb logic error. Duh me.
This commit is contained in:
ISSOtm
2023-02-08 00:20:55 +01:00
parent 4e712807d7
commit 33a0857b8d
3 changed files with 28 additions and 14 deletions

View File

@@ -15,15 +15,20 @@
#include <stdint.h>
class ProtoPalette {
public:
static constexpr size_t capacity = 4;
private:
// Up to 4 colors, sorted, and where SIZE_MAX means the slot is empty
// (OK because it's not a valid color index)
// Sorting is done on the raw numerical values to lessen `compare`'s complexity
std::array<uint16_t, 4> _colorIndices{UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX};
std::array<uint16_t, capacity> _colorIndices{UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX};
public:
/*
* Adds the specified color to the set
* Returns false if the set is full
* Adds the specified color to the set, or **silently drops it** if the set is full.
*
* Returns whether the color was unique.
*/
bool add(uint16_t color);