Fix unchecked narrowing conversion of tile IDs

The conversion is OK because of the tile amount cap
This commit is contained in:
ISSOtm
2022-03-05 02:13:27 +01:00
committed by Eldred Habert
parent 38e8024ffa
commit bde380f38b

View File

@@ -634,7 +634,7 @@ class TileData {
// non-pathological cases. // non-pathological cases.
uint16_t _hash; uint16_t _hash;
public: public:
mutable size_t tileID; mutable uint16_t tileID;
TileData(Png::TilesVisitor::Tile const &tile, Palette const &palette) : _hash(0) { TileData(Png::TilesVisitor::Tile const &tile, Palette const &palette) : _hash(0) {
size_t writeIndex = 0; size_t writeIndex = 0;
@@ -719,7 +719,7 @@ struct UniqueTiles {
TileData::MatchType matchType = TileData::EXACT; TileData::MatchType matchType = TileData::EXACT;
if (inserted) { if (inserted) {
// Give the new tile the next available unique ID // Give the new tile the next available unique ID
tileData->tileID = tiles.size(); tileData->tileID = static_cast<uint16_t>(tiles.size());
// Pointers are never invalidated! // Pointers are never invalidated!
tiles.emplace_back(&*tileData); tiles.emplace_back(&*tileData);
} else { } else {