Check before attempting to generate empty image

This causes a libpng warning then error, but print a better error message
Fixes #1016
This commit is contained in:
ISSOtm
2022-08-04 20:37:36 +02:00
parent 2e0991f32b
commit b02ccf8f4a
2 changed files with 4 additions and 1 deletions

View File

@@ -21,7 +21,7 @@
#include "gfx/rgba.hpp"
struct Options {
uint16_t reversedWidth = 0; // -r, in pixels
uint16_t reversedWidth = 0; // -r, in tiles
bool reverse() const { return reversedWidth != 0; }
bool useColorCurve = false; // -C

View File

@@ -122,6 +122,9 @@ void reverse() {
options.verbosePrint(Options::VERB_INTERM, "Read %zu tilemap entries.\n", nbTileInstances);
}
if (nbTileInstances == 0) {
fatal("Cannot generate empty image");
}
if (nbTileInstances > options.maxNbTiles[0] + options.maxNbTiles[1]) {
warning("Read %zu tiles, more than the limit of %zu + %zu", nbTileInstances,
options.maxNbTiles[0], options.maxNbTiles[1]);