Make --noemptyimage more fine-grained

This commit is contained in:
sfan5 2025-02-18 19:02:45 +01:00
parent 6947c5c4e4
commit b4d4632212

View File

@ -153,6 +153,8 @@ TileGenerator::TileGenerator():
TileGenerator::~TileGenerator() TileGenerator::~TileGenerator()
{ {
closeDatabase(); closeDatabase();
delete m_image;
m_image = nullptr;
} }
void TileGenerator::setBgColor(const std::string &bgColor) void TileGenerator::setBgColor(const std::string &bgColor)
@ -293,19 +295,24 @@ void TileGenerator::dumpBlock(const std::string &input_path, BlockPos pos)
void TileGenerator::generate(const std::string &input_path, const std::string &output) void TileGenerator::generate(const std::string &input_path, const std::string &output)
{ {
if (m_dontWriteEmpty) // FIXME: possible too, just needs to be done differently
setExhaustiveSearch(EXH_NEVER);
openDb(input_path); openDb(input_path);
loadBlocks(); loadBlocks();
if (m_dontWriteEmpty && m_positions.empty()) // If we needed to load positions and there are none, that means the
{ // result will be empty.
closeDatabase(); if (m_dontWriteEmpty && (m_exhaustiveSearch == EXH_NEVER ||
m_exhaustiveSearch == EXH_Y) && m_positions.empty()) {
return; return;
} }
createImage(); createImage();
renderMap(); renderMap();
if (m_dontWriteEmpty && !m_renderedAny) {
printUnknown();
return;
}
closeDatabase(); closeDatabase();
if (m_drawScale) { if (m_drawScale) {
renderScale(); renderScale();