Handle empty world (don't generate map & improve --verbose output)

This commit is contained in:
Rogier 2015-03-10 15:37:30 +01:00
parent dd0ff68c12
commit 8349d41283

View File

@ -524,6 +524,10 @@ void TileGenerator::generate(const std::string &input, const std::string &output
openDb(input_path); openDb(input_path);
sanitizeParameters(); sanitizeParameters();
loadBlocks(); loadBlocks();
if (m_xMin > m_xMax || m_yMin > m_yMax || m_zMin > m_zMax) {
std::cout << "World is empty: no map generated" << std::endl;
return;
}
computeMapParameters(input); computeMapParameters(input);
createImage(); createImage();
renderMap(); renderMap();
@ -1031,26 +1035,50 @@ void TileGenerator::loadBlocks()
m_positions.push_back(pos); m_positions.push_back(pos);
} }
if (verboseCoordinates >= 1) { if (verboseCoordinates >= 1) {
cout if (mapXMin <= mapXMax || mapYMin <= mapYMax || mapZMin <= mapZMax) {
<< std::setw(MESSAGE_WIDTH) << std::left cout
<< "World Geometry:" << std::right << std::setw(MESSAGE_WIDTH) << std::left
<< std::setw(7) << mapXMin*16 << "," << "World Geometry:" << std::right
<< std::setw(7) << mapYMin*16 << "," << std::setw(7) << mapXMin*16 << ","
<< std::setw(7) << mapZMin*16 << std::setw(7) << mapYMin*16 << ","
<< " .. " << std::setw(7) << mapZMin*16
<< std::setw(7) << mapXMax*16+15 << "," << " .. "
<< std::setw(7) << mapYMax*16+15 << "," << std::setw(7) << mapXMax*16+15 << ","
<< std::setw(7) << mapZMax*16+15 << std::setw(7) << mapYMax*16+15 << ","
<< " (" << std::setw(7) << mapZMax*16+15
<< std::setw(6) << mapXMin << "," << " ("
<< std::setw(6) << mapYMin << "," << std::setw(6) << mapXMin << ","
<< std::setw(6) << mapZMin << std::setw(6) << mapYMin << ","
<< " .. " << std::setw(6) << mapZMin
<< std::setw(6) << mapXMax << "," << " .. "
<< std::setw(6) << mapYMax << "," << std::setw(6) << mapXMax << ","
<< std::setw(6) << mapZMax << std::setw(6) << mapYMax << ","
<< ") blocks: " << std::setw(6) << mapZMax
<< std::setw(10) << m_worldBlocks << "\n"; << ") blocks: "
<< std::setw(10) << m_worldBlocks << "\n";
}
else {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "World Geometry:" << std::right
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " .. "
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " ("
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< " .. "
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< ") blocks: "
<< std::setw(10) << m_worldBlocks << "\n";
}
} }
if (m_shrinkGeometry) { if (m_shrinkGeometry) {
if (m_xMin != m_reqXMin) m_mapXStartNodeOffset = 0; if (m_xMin != m_reqXMin) m_mapXStartNodeOffset = 0;
@ -1060,25 +1088,48 @@ void TileGenerator::loadBlocks()
} }
else { else {
if (verboseCoordinates >= 2) { if (verboseCoordinates >= 2) {
cout if (m_xMin <= m_xMax || m_yMin <= m_yMax || m_zMin <= m_zMax) {
<< std::setw(MESSAGE_WIDTH) << std::left cout
<< "Minimal Map Geometry:" << std::right << std::setw(MESSAGE_WIDTH) << std::left
<< std::setw(7) << m_xMin*16 << "," << "Minimal Map Geometry:" << std::right
<< std::setw(7) << m_yMin*16+m_reqYMinNode << "," << std::setw(7) << m_xMin*16 << ","
<< std::setw(7) << m_zMin*16 << std::setw(7) << m_yMin*16+m_reqYMinNode << ","
<< " .. " << std::setw(7) << m_zMin*16
<< std::setw(7) << m_xMax*16+15 << "," << " .. "
<< std::setw(7) << m_yMax*16+m_reqYMaxNode << "," << std::setw(7) << m_xMax*16+15 << ","
<< std::setw(7) << m_zMax*16+15 << std::setw(7) << m_yMax*16+m_reqYMaxNode << ","
<< " (" << std::setw(7) << m_zMax*16+15
<< std::setw(6) << m_xMin << "," << " ("
<< std::setw(6) << m_yMin << "," << std::setw(6) << m_xMin << ","
<< std::setw(6) << m_zMin << std::setw(6) << m_yMin << ","
<< " .. " << std::setw(6) << m_zMin
<< std::setw(6) << m_xMax << "," << " .. "
<< std::setw(6) << m_yMax << "," << std::setw(6) << m_xMax << ","
<< std::setw(6) << m_zMax << std::setw(6) << m_yMax << ","
<< ")\n"; << std::setw(6) << m_zMax
<< ")\n";
}
else {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Minimal Map Geometry:" << std::right
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " .. "
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " ("
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< " .. "
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< ")\n";
}
} }
m_xMin = m_reqXMin; m_xMin = m_reqXMin;
m_xMax = m_reqXMax; m_xMax = m_reqXMax;
@ -1086,49 +1137,100 @@ void TileGenerator::loadBlocks()
m_zMax = m_reqZMax; m_zMax = m_reqZMax;
} }
if (verboseCoordinates >= 2) { if (verboseCoordinates >= 2) {
cout if (geomYMin <= geomYMax) {
<< std::setw(MESSAGE_WIDTH) << std::left cout
<< "Map Vertical Limits:" << std::right << std::setw(MESSAGE_WIDTH) << std::left
<< std::setw(7) << "x" << "," << "Map Vertical Limits:" << std::right
<< std::setw(7) << geomYMin*16 << "," << std::setw(7) << "x" << ","
<< std::setw(7) << "z" << std::setw(7) << geomYMin*16 << ","
<< " .. " << std::setw(7) << "z"
<< std::setw(7) << "x" << "," << " .. "
<< std::setw(7) << geomYMax*16+15 << "," << std::setw(7) << "x" << ","
<< std::setw(7) << "z" << std::setw(7) << geomYMax*16+15 << ","
<< " (" << std::setw(7) << "z"
<< std::setw(6) << "x" << "," << " ("
<< std::setw(6) << geomYMin << "," << std::setw(6) << "x" << ","
<< std::setw(6) << "z" << std::setw(6) << geomYMin << ","
<< " .. " << std::setw(6) << "z"
<< std::setw(6) << "x" << "," << " .. "
<< std::setw(6) << geomYMax << "," << std::setw(6) << "x" << ","
<< std::setw(6) << "z" << std::setw(6) << geomYMax << ","
<< ")\n"; << std::setw(6) << "z"
<< ")\n";
}
else {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Map Vertical Limits:" << std::right
<< std::setw(7) << "x" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "z"
<< " .. "
<< std::setw(7) << "x" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "z"
<< " ("
<< std::setw(6) << "x" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "z"
<< " .. "
<< std::setw(6) << "x" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "z"
<< ")\n";
}
} }
m_positions.sort(); m_positions.sort();
} }
if ((m_xMin <= m_xMax || m_zMin <= m_zMax) && m_yMin > m_yMax) {
m_yMin = MAPBLOCK_MIN;
m_yMax = MAPBLOCK_MAX;
}
if (verboseCoordinates >= 1) { if (verboseCoordinates >= 1) {
cout if (m_xMin <= m_xMax || m_zMin <= m_zMax) {
<< std::setw(MESSAGE_WIDTH) << std::left cout
<< "Map Output Geometry:" << std::right << std::setw(MESSAGE_WIDTH) << std::left
<< std::setw(7) << m_xMin*16+m_mapXStartNodeOffset << "," << "Map Output Geometry:" << std::right
<< std::setw(7) << m_yMin*16+m_reqYMinNode << "," << std::setw(7) << m_xMin*16+m_mapXStartNodeOffset << ","
<< std::setw(7) << m_zMin*16-m_mapYEndNodeOffset << std::setw(7) << m_yMin*16+m_reqYMinNode << ","
<< " .. " << std::setw(7) << m_zMin*16-m_mapYEndNodeOffset
<< std::setw(7) << m_xMax*16+15+m_mapXEndNodeOffset << "," << " .. "
<< std::setw(7) << m_yMax*16+m_reqYMaxNode << "," << std::setw(7) << m_xMax*16+15+m_mapXEndNodeOffset << ","
<< std::setw(7) << m_zMax*16+15-m_mapYStartNodeOffset << std::setw(7) << m_yMax*16+m_reqYMaxNode << ","
<< " (" << std::setw(7) << m_zMax*16+15-m_mapYStartNodeOffset
<< std::setw(6) << m_xMin << "," << " ("
<< std::setw(6) << m_yMin << "," << std::setw(6) << m_xMin << ","
<< std::setw(6) << m_zMin << std::setw(6) << m_yMin << ","
<< " .. " << std::setw(6) << m_zMin
<< std::setw(6) << m_xMax << "," << " .. "
<< std::setw(6) << m_yMax << "," << std::setw(6) << m_xMax << ","
<< std::setw(6) << m_zMax << std::setw(6) << m_yMax << ","
<< ") blocks: " << std::setw(6) << m_zMax
<< std::setw(10) << map_blocks << "\n"; << ") blocks: "
<< std::setw(10) << map_blocks << "\n";
}
else {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Map Output Geometry:" << std::right
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " .. "
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "-"
<< " ("
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< " .. "
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "-"
<< ") blocks: "
<< std::setw(10) << map_blocks << "\n";
}
} }
if (m_backend == "leveldb" && !m_generateNoPrefetch) { if (m_backend == "leveldb" && !m_generateNoPrefetch) {
if (m_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64]) if (m_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64])
@ -1733,25 +1835,48 @@ void TileGenerator::renderMap()
bool eraseProgress = true; bool eraseProgress = true;
if (verboseCoordinates >= 1) { if (verboseCoordinates >= 1) {
eraseProgress = false; eraseProgress = false;
cout if (m_YMinMapped <= m_YMaxMapped) {
<< std::setw(MESSAGE_WIDTH) << std::left cout
<< "Mapped Vertical Range:" << std::right << std::setw(MESSAGE_WIDTH) << std::left
<< std::setw(7) << "x" << "," << "Mapped Vertical Range:" << std::right
<< std::setw(7) << m_YMinMapped*16 << "," << std::setw(7) << "x" << ","
<< std::setw(7) << "z" << std::setw(7) << m_YMinMapped*16 << ","
<< " .. " << std::setw(7) << "z"
<< std::setw(7) << "x" << "," << " .. "
<< std::setw(7) << m_YMaxMapped*16+15 << "," << std::setw(7) << "x" << ","
<< std::setw(7) << "z" << std::setw(7) << m_YMaxMapped*16+15 << ","
<< " (" << std::setw(7) << "z"
<< std::setw(6) << "x" << "," << " ("
<< std::setw(6) << m_YMinMapped << "," << std::setw(6) << "x" << ","
<< std::setw(6) << "z" << std::setw(6) << m_YMinMapped << ","
<< " .. " << std::setw(6) << "z"
<< std::setw(6) << "x" << "," << " .. "
<< std::setw(6) << m_YMaxMapped << "," << std::setw(6) << "x" << ","
<< std::setw(6) << "z" << std::setw(6) << m_YMaxMapped << ","
<< ")\n"; << std::setw(6) << "z"
<< ")\n";
}
else {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Mapped Vertical Range:" << std::right
<< std::setw(7) << "x" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "z"
<< " .. "
<< std::setw(7) << "x" << ","
<< std::setw(7) << "-" << ","
<< std::setw(7) << "z"
<< " ("
<< std::setw(6) << "x" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "z"
<< " .. "
<< std::setw(6) << "x" << ","
<< std::setw(6) << "-" << ","
<< std::setw(6) << "z"
<< ")\n";
}
} }
if (!m_generateNoPrefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) { if (!m_generateNoPrefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) {
cout cout