Avoid sorting proto-palettes breaking mappings

The sorting was performed without updating the mappings, which broke the world.
We can instead sort the IDs as they are inserted into the packing queue,
which should also be faster than moving the actual proto-pal objects around.
This commit is contained in:
ISSOtm
2022-04-24 15:03:27 +02:00
committed by Eldred Habert
parent ed104a9f70
commit fcce42d3d2
3 changed files with 17 additions and 31 deletions

View File

@@ -736,6 +736,9 @@ void Palette::addColor(uint16_t color) {
}
}
/**
* Returns the ID of the color in the palette, or `size()` if the color is not in
*/
uint8_t Palette::indexOf(uint16_t color) const {
return std::find(colors.begin(), colors.end(), color) - colors.begin();
}