diff --git a/include/core/tile.h b/include/core/tile.h index bd673f74..5d85066a 100644 --- a/include/core/tile.h +++ b/include/core/tile.h @@ -8,17 +8,15 @@ class Tile { public: Tile(); - Tile(int tileId, bool xflip, bool yflip, int palette); + Tile(uint16_t tileId, uint16_t xflip, uint16_t yflip, uint16_t palette); Tile(uint16_t raw); public: - int tileId; - bool xflip; - bool yflip; - int palette; - + uint16_t tileId:10; + uint16_t xflip:1; + uint16_t yflip:1; + uint16_t palette:4; uint16_t rawValue() const; - void sanitize(); static int getIndexInTileset(int); }; diff --git a/src/core/tile.cpp b/src/core/tile.cpp index 10baa720..cc89c2a9 100644 --- a/src/core/tile.cpp +++ b/src/core/tile.cpp @@ -8,7 +8,7 @@ palette(0) { } - Tile::Tile(int tileId, bool xflip, bool yflip, int palette) : + Tile::Tile(uint16_t tileId, uint16_t xflip, uint16_t yflip, uint16_t palette) : tileId(tileId), xflip(xflip), yflip(yflip), @@ -30,17 +30,6 @@ uint16_t Tile::rawValue() const { | ((this->palette & 0xF) << 12)); } -void Tile::sanitize() { - if (tileId < 0 || tileId >= Project::getNumTilesTotal()) { - logWarn(QString("Resetting tile's invalid tile id '%1' to 0.").arg(tileId)); - tileId = 0; - } - if (palette < 0 || palette >= Project::getNumPalettesTotal()) { - logWarn(QString("Resetting tile's invalid palette id '%1' to 0.").arg(palette)); - palette = 0; - } -} - int Tile::getIndexInTileset(int tileId) { if (tileId < Project::getNumTilesPrimary()) { return tileId; diff --git a/src/mainwindow_scriptapi.cpp b/src/mainwindow_scriptapi.cpp index 931bc26a..784a0354 100644 --- a/src/mainwindow_scriptapi.cpp +++ b/src/mainwindow_scriptapi.cpp @@ -991,11 +991,8 @@ void MainWindow::setMetatileTiles(int metatileId, QJSValue tilesObj, int tileSta // Write to metatile using as many of the given Tiles as possible int numTileObjs = qMin(tilesObj.property("length").toInt(), numTiles); int i = 0; - for (; i < numTileObjs; i++, tileStart++) { - Tile tile = Scripting::toTile(tilesObj.property(i)); - tile.sanitize(); - metatile->tiles[tileStart] = tile; - } + for (; i < numTileObjs; i++, tileStart++) + metatile->tiles[tileStart] = Scripting::toTile(tilesObj.property(i)); // Fill remainder of specified length with empty Tiles for (; i < numTiles; i++, tileStart++) @@ -1014,7 +1011,6 @@ void MainWindow::setMetatileTiles(int metatileId, int tileId, bool xflip, bool y // Write to metatile using Tiles of the specified value Tile tile = Tile(tileId, xflip, yflip, palette); - tile.sanitize(); for (int i = tileStart; i <= tileEnd; i++) metatile->tiles[i] = tile;