Fix ProtoPalette::compare

The function only stopped at the end of the *arrays*,
not of *their used portions*!
This could cause false negatives one way or the other.

This appears not to affect the palette packing, since the packing algorithm
deals with them efficiently; but it should speed up processing slightly,
and as the test changes show, it also improves the UX of palette packing
error messages!
This commit is contained in:
ISSOtm
2024-08-14 17:30:56 +02:00
parent c42e856efb
commit 68a6abd00e
3 changed files with 5 additions and 12 deletions

View File

@@ -46,7 +46,7 @@ ProtoPalette::ComparisonResult ProtoPalette::compare(ProtoPalette const &other)
auto ours = _colorIndices.begin(), theirs = other._colorIndices.begin(); auto ours = _colorIndices.begin(), theirs = other._colorIndices.begin();
bool weBigger = true, theyBigger = true; bool weBigger = true, theyBigger = true;
while (ours != _colorIndices.end() && theirs != other._colorIndices.end()) { while (ours != end() && theirs != other.end()) {
if (*ours == *theirs) { if (*ours == *theirs) {
++ours; ++ours;
++theirs; ++theirs;
@@ -58,8 +58,8 @@ ProtoPalette::ComparisonResult ProtoPalette::compare(ProtoPalette const &other)
weBigger = false; weBigger = false;
} }
} }
weBigger &= theirs == other._colorIndices.end(); weBigger &= theirs == other.end();
theyBigger &= ours == _colorIndices.end(); theyBigger &= ours == end();
return theyBigger ? THEY_BIGGER : (weBigger ? WE_BIGGER : NEITHER); return theyBigger ? THEY_BIGGER : (weBigger ? WE_BIGGER : NEITHER);
} }

View File

@@ -1,14 +1,8 @@
error: Failed to fit tile colors [$7f55, $7fff] in specified palettes
error: Failed to fit tile colors [$7f55] in specified palettes
error: Failed to fit tile colors [$6c8a, $7f55, $7fff] in specified palettes error: Failed to fit tile colors [$6c8a, $7f55, $7fff] in specified palettes
error: Failed to fit tile colors [$6c8a, $7fff] in specified palettes
error: Failed to fit tile colors [$6c8a, $7f55] in specified palettes
error: Failed to fit tile colors [$6c8a] in specified palettes
error: Failed to fit tile colors [$7fff] in specified palettes
note: The following palettes were specified: note: The following palettes were specified:
[$5f77, $213d, $41a6, $40ee] [$5f77, $213d, $41a6, $40ee]
[$3f65, $36b3, $262a, $50b0] [$3f65, $36b3, $262a, $50b0]
[$53c3, $3f65, $36b3] [$53c3, $3f65, $36b3]
[$5f77, $267c, $41a6] [$5f77, $267c, $41a6]
[$267c, $213d, $40ee] [$267c, $213d, $40ee]
Conversion aborted after 7 errors Conversion aborted after 1 error

View File

@@ -1,6 +1,5 @@
error: Failed to fit tile colors [$6c8a, $7f55, $7fff] in specified palettes error: Failed to fit tile colors [$6c8a, $7f55, $7fff] in specified palettes
error: Failed to fit tile colors [$6c8a, $7f55] in specified palettes
note: The following palettes were specified: note: The following palettes were specified:
[$7fff, $7f55] [$7fff, $7f55]
[$7fff, $6c8a] [$7fff, $6c8a]
Conversion aborted after 2 errors Conversion aborted after 1 error