Warn if only unknown nodes seen

suggested by @Calinou
This commit is contained in:
sfan5 2022-02-09 23:06:29 +01:00
parent e4bf375ac7
commit 31b0d09a19
2 changed files with 16 additions and 6 deletions

View File

@ -140,6 +140,7 @@ TileGenerator::TileGenerator():
m_geomX2(2048), m_geomX2(2048),
m_geomY2(2048), m_geomY2(2048),
m_exhaustiveSearch(EXH_AUTO), m_exhaustiveSearch(EXH_AUTO),
m_renderedAny(false),
m_zoom(1), m_zoom(1),
m_scales(SCALE_LEFT | SCALE_TOP), m_scales(SCALE_LEFT | SCALE_TOP),
m_progressMax(0), m_progressMax(0),
@ -542,6 +543,7 @@ void TileGenerator::renderMap()
} }
if (!m_readPixels.full()) if (!m_readPixels.full())
renderMapBlockBottom(blockStack.begin()->first); renderMapBlockBottom(blockStack.begin()->first);
m_renderedAny |= m_readInfo.any();
}; };
auto postRenderRow = [&] (int16_t zPos) { auto postRenderRow = [&] (int16_t zPos) {
if (m_shading) if (m_shading)
@ -847,6 +849,11 @@ void TileGenerator::printUnknown()
std::cerr << "Unknown nodes:" << std::endl; std::cerr << "Unknown nodes:" << std::endl;
for (const auto &node : m_unknownNodes) for (const auto &node : m_unknownNodes)
std::cerr << "\t" << node << std::endl; std::cerr << "\t" << node << std::endl;
if (!m_renderedAny) {
std::cerr << "The map was read successfully and not empty, but none of the "
"encountered nodes had a color associated.\nCheck that you're using "
"the right colors.txt. It should match the game you have installed." << std::endl;
}
} }
void TileGenerator::reportProgress(size_t count) void TileGenerator::reportProgress(size_t count)

View File

@ -43,17 +43,19 @@ struct BitmapThing { // 16x16 bitmap
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
val[i] = 0; val[i] = 0;
} }
inline bool full() const { inline bool any_neq(uint16_t v) const {
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i) {
if (val[i] != 0xffff) if (val[i] != v)
return false; return true;
} }
return true; return false;
} }
inline bool any() const { return any_neq(0); }
inline bool full() const { return !any_neq(0xffff); }
inline void set(unsigned int x, unsigned int z) { inline void set(unsigned int x, unsigned int z) {
val[z] |= (1 << x); val[z] |= (1 << x);
} }
inline bool get(unsigned int x, unsigned int z) { inline bool get(unsigned int x, unsigned int z) const {
return !!(val[z] & (1 << x)); return !!(val[z] & (1 << x));
} }
@ -148,11 +150,12 @@ private:
int m_mapWidth; int m_mapWidth;
int m_mapHeight; int m_mapHeight;
int m_exhaustiveSearch; int m_exhaustiveSearch;
std::set<std::string> m_unknownNodes;
bool m_renderedAny;
std::map<int16_t, std::set<int16_t>> m_positions; /* indexed by Z, contains X coords */ std::map<int16_t, std::set<int16_t>> m_positions; /* indexed by Z, contains X coords */
ColorMap m_colorMap; ColorMap m_colorMap;
BitmapThing m_readPixels; BitmapThing m_readPixels;
BitmapThing m_readInfo; BitmapThing m_readInfo;
std::set<std::string> m_unknownNodes;
Color m_color[16][16]; Color m_color[16][16];
uint8_t m_thickness[16][16]; uint8_t m_thickness[16][16];