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.)
964
976
UniqueTiles tiles;
965
977
978
+
if (!options.inputTileset.empty()) {
979
+
File inputTileset;
980
+
if (!inputTileset.open(options.inputTileset, std::ios::in | std::ios::binary)) {
981
+
fatal("Failed to open \"%s\": %s", options.inputTileset.c_str(), strerror(errno));
982
+
}
983
+
984
+
std::array<uint8_t, 16> tile;
985
+
size_tconst tileSize = options.bitDepth * 8;
986
+
for (;;) {
987
+
// It's okay to cast between character types.
988
+
size_t len = inputTileset->sgetn(reinterpret_cast<char *>(tile.data()), tileSize);
989
+
if (len == 0) { // EOF!
990
+
break;
991
+
} elseif (len != tileSize) {
992
+
fatal(
993
+
"\"%s\" does not contain a multiple of %zu bytes; is it actually tile data?",
994
+
options.inputTileset.c_str(),
995
+
tileSize
996
+
);
997
+
} elseif (len == 8) {
998
+
// Expand the tile data to 2bpp.
999
+
for (size_t i = 8; i--;) {
1000
+
tile[i * 2 + 1] = 0;
1001
+
tile[i * 2] = tile[i];
1002
+
}
1003
+
}
1004
+
1005
+
auto [tileID, matchType] = tiles.addTile(std::move(tile));
1006
+
switch (matchType) {
1007
+
case TileData::NOPE:
1008
+
break;
1009
+
case TileData::HFLIP:
1010
+
case TileData::VFLIP:
1011
+
case TileData::VHFLIP:
1012
+
if (!options.allowMirroring) {
1013
+
break;
1014
+
}
1015
+
[[fallthrough]];
1016
+
case TileData::EXACT:
1017
+
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");
1018
+
}
1019
+
}
1020
+
}
1021
+
966
1022
for (auto [tile, attr] : zip(png.visitAsTiles(), attrmap)) {
967
-
auto [tileID, matchType] = tiles.addTile(tile, palettes[mappings[attr.protoPaletteID]]);
1023
+
auto [tileID, matchType] = tiles.addTile({tile, palettes[mappings[attr.protoPaletteID]]});
1024
+
1025
+
if (matchType == TileData::NOPE && options.output.empty()) {
1026
+
error("Tile at (%" PRIu32 ", %" PRIu32 ") is not within the input tileset, and `-o` was not given!", tile.x, tile.y);
0 commit comments