You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// by caching the full tile data anyway, so we might as well.)
954
966
UniqueTiles tiles;
955
967
968
+
if (!options.inputTileset.empty()) {
969
+
File inputTileset;
970
+
if (!inputTileset.open(options.inputTileset, std::ios::in | std::ios::binary)) {
971
+
fatal("Failed to open \"%s\": %s", options.inputTileset.c_str(), strerror(errno));
972
+
}
973
+
974
+
std::array<uint8_t, 16> tile;
975
+
size_tconst tileSize = options.bitDepth * 8;
976
+
for (;;) {
977
+
// It's okay to cast between character types.
978
+
size_t len = inputTileset->sgetn(reinterpret_cast<char *>(tile.data()), tileSize);
979
+
if (len == 0) { // EOF!
980
+
break;
981
+
} elseif (len != tileSize) {
982
+
fatal(
983
+
"\"%s\" does not contain a multiple of %zu bytes; is it actually tile data?",
984
+
options.inputTileset.c_str(),
985
+
tileSize
986
+
);
987
+
} elseif (len == 8) {
988
+
// Expand the tile data to 2bpp.
989
+
for (size_t i = 8; i--;) {
990
+
tile[i * 2 + 1] = 0;
991
+
tile[i * 2] = tile[i];
992
+
}
993
+
}
994
+
995
+
auto [tileID, matchType] = tiles.addTile(std::move(tile));
996
+
switch (matchType) {
997
+
case TileData::NOPE:
998
+
break;
999
+
case TileData::HFLIP:
1000
+
case TileData::VFLIP:
1001
+
case TileData::VHFLIP:
1002
+
if (!options.allowMirroring) {
1003
+
break;
1004
+
}
1005
+
[[fallthrough]];
1006
+
case TileData::EXACT:
1007
+
error("The input tileset contains tiles that were deduplicated; please check that your deduplication flags (`-u`, `-m`) are consistent with what was used to generate the input tileset");
1008
+
}
1009
+
}
1010
+
}
1011
+
956
1012
for (auto [tile, attr] : zip(png.visitAsTiles(), attrmap)) {
957
-
auto [tileID, matchType] = tiles.addTile(tile, palettes[mappings[attr.protoPaletteID]]);
1013
+
auto [tileID, matchType] = tiles.addTile({tile, palettes[mappings[attr.protoPaletteID]]});
1014
+
1015
+
if (matchType == TileData::NOPE && options.output.empty()) {
1016
+
error("Tile at (%" PRIu32 ", %" PRIu32 ") is not within the input tileset, and `-o` was not given!", tile.x, tile.y);
0 commit comments