mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-11-22 07:23:46 +01:00
Improvements to Node name/ID mapping code
* Clean m_nameMap between blocks * Warn about invalid node name IDs * Early drop of non-significant blocks
This commit is contained in:
parent
09945caa14
commit
c45965eb8d
@ -441,6 +441,7 @@ void TileGenerator::renderMap()
|
|||||||
|
|
||||||
m_blockAirId = -1;
|
m_blockAirId = -1;
|
||||||
m_blockIgnoreId = -1;
|
m_blockIgnoreId = -1;
|
||||||
|
m_nameMap.clear();
|
||||||
// Read mapping
|
// Read mapping
|
||||||
if (version >= 22) {
|
if (version >= 22) {
|
||||||
dataOffset++; // mapping version
|
dataOffset++; // mapping version
|
||||||
@ -463,6 +464,9 @@ void TileGenerator::renderMap()
|
|||||||
}
|
}
|
||||||
dataOffset += nameLen;
|
dataOffset += nameLen;
|
||||||
}
|
}
|
||||||
|
// Skip block if made of only air or ignore nodes
|
||||||
|
if (m_nameMap.empty())
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Node timers
|
// Node timers
|
||||||
@ -518,12 +522,14 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
|
|||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
int position = x + (y << 4) + (z << 8);
|
int position = x + (y << 4) + (z << 8);
|
||||||
int content = readBlockContent(mapData, version, position);
|
int content = readBlockContent(mapData, version, position);
|
||||||
if (content == m_blockIgnoreId || content == m_blockAirId) {
|
if (content == m_blockAirId || content == m_blockIgnoreId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NameMap::iterator blockName = m_nameMap.find(content);
|
NameMap::iterator blockName = m_nameMap.find(content);
|
||||||
if (blockName == m_nameMap.end())
|
if (blockName == m_nameMap.end()) {
|
||||||
|
std::cerr << "Skipping node with invalid ID." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
const string &name = blockName->second;
|
const string &name = blockName->second;
|
||||||
ColorMap::const_iterator color = m_colorMap.find(name);
|
ColorMap::const_iterator color = m_colorMap.find(name);
|
||||||
if (color != m_colorMap.end()) {
|
if (color != m_colorMap.end()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user