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);
sanitizeParameters();
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);
createImage();
renderMap();
@ -1031,6 +1035,7 @@ void TileGenerator::loadBlocks()
m_positions.push_back(pos);
}
if (verboseCoordinates >= 1) {
if (mapXMin <= mapXMax || mapYMin <= mapYMax || mapZMin <= mapZMax) {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "World Geometry:" << std::right
@ -1052,6 +1057,29 @@ void TileGenerator::loadBlocks()
<< ") 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_xMin != m_reqXMin) m_mapXStartNodeOffset = 0;
if (m_xMax != m_reqXMax) m_mapXEndNodeOffset = 0;
@ -1060,6 +1088,7 @@ void TileGenerator::loadBlocks()
}
else {
if (verboseCoordinates >= 2) {
if (m_xMin <= m_xMax || m_yMin <= m_yMax || m_zMin <= m_zMax) {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Minimal Map Geometry:" << std::right
@ -1080,12 +1109,35 @@ void TileGenerator::loadBlocks()
<< 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_xMax = m_reqXMax;
m_zMin = m_reqZMin;
m_zMax = m_reqZMax;
}
if (verboseCoordinates >= 2) {
if (geomYMin <= geomYMax) {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Map Vertical Limits:" << std::right
@ -1106,9 +1158,36 @@ void TileGenerator::loadBlocks()
<< 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();
}
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 (m_xMin <= m_xMax || m_zMin <= m_zMax) {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Map Output Geometry:" << std::right
@ -1130,6 +1209,29 @@ void TileGenerator::loadBlocks()
<< ") 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_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64])
m_recommendedDatabaseFormat = "mixed";
@ -1733,6 +1835,7 @@ void TileGenerator::renderMap()
bool eraseProgress = true;
if (verboseCoordinates >= 1) {
eraseProgress = false;
if (m_YMinMapped <= m_YMaxMapped) {
cout
<< std::setw(MESSAGE_WIDTH) << std::left
<< "Mapped Vertical Range:" << std::right
@ -1753,6 +1856,28 @@ void TileGenerator::renderMap()
<< 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)) {
cout
<< "Database format setting when using --disable-blocklist-prefetch: ";