Use strong enum for blocklist prefetch state
This commit is contained in:
parent
cc3ef4cbca
commit
face7c0b0f
@ -72,9 +72,9 @@ void TileGenerator::setSilenceSuggestion(unsigned flags)
|
||||
m_silenceSuggestions |= flags;
|
||||
}
|
||||
|
||||
void TileGenerator::setGenerateNoPrefetch(int enable)
|
||||
void TileGenerator::setGenerateNoPrefetch(BlockListPrefetch enable)
|
||||
{
|
||||
m_generateNoPrefetch = enable;
|
||||
m_generatePrefetch = enable;
|
||||
}
|
||||
|
||||
void TileGenerator::setDBFormat(BlockPos::StrFormat format, bool query)
|
||||
@ -614,15 +614,15 @@ void TileGenerator::loadBlocks()
|
||||
std::cerr << "WARNING: querying database format is only sensible when using the leveldb backend - querying disabled" << std::endl;
|
||||
m_reportDatabaseFormat = false;
|
||||
}
|
||||
if (m_reportDatabaseFormat && m_generateNoPrefetch) {
|
||||
if (m_reportDatabaseFormat && m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||
std::cerr << "WARNING: querying database format: ignoring '--disable-blocklist-prefetch' and/or '--prescan-world=disabled'." << std::endl;
|
||||
m_generateNoPrefetch = 0;
|
||||
m_generatePrefetch = BlockListPrefetch::Prefetch;
|
||||
}
|
||||
if (m_generateNoPrefetch && !m_databaseFormatSet && m_backend == "leveldb") {
|
||||
if (m_generatePrefetch != BlockListPrefetch::Prefetch && !m_databaseFormatSet && m_backend == "leveldb") {
|
||||
throw(std::runtime_error("When using --disable-blocklist-prefetch with a leveldb backend, database format must be set (--database-format)"));
|
||||
}
|
||||
if (m_generateNoPrefetch) {
|
||||
if (m_generateNoPrefetch == 1) {
|
||||
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||
if (m_generatePrefetch == BlockListPrefetch::NoPrefetch) {
|
||||
long long volume = (long long)(m_reqXMax - m_reqXMin + 1) * (m_reqYMax - m_reqYMin + 1) * (m_reqZMax - m_reqZMin + 1);
|
||||
if (volume > MAX_NOPREFETCH_VOLUME) {
|
||||
std::ostringstream oss;
|
||||
@ -914,7 +914,7 @@ void TileGenerator::loadBlocks()
|
||||
<< std::setw(10) << map_blocks << "\n";
|
||||
}
|
||||
}
|
||||
if (m_backend == "leveldb" && !m_generateNoPrefetch) {
|
||||
if (m_backend == "leveldb" && m_generatePrefetch == BlockListPrefetch::Prefetch) {
|
||||
if (m_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64])
|
||||
m_recommendedDatabaseFormat = "mixed";
|
||||
else if (m_databaseFormatFound[BlockPos::AXYZ])
|
||||
@ -1366,7 +1366,7 @@ void TileGenerator::renderMap()
|
||||
MapBlockIterator *position;
|
||||
MapBlockIterator *begin;
|
||||
MapBlockIterator *end;
|
||||
if (m_generateNoPrefetch) {
|
||||
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||
position = new MapBlockIteratorBlockPos();
|
||||
begin = new MapBlockIteratorBlockPos(BlockPosIterator(
|
||||
BlockPos(m_xMin, m_yMax, m_zMax, m_databaseFormat),
|
||||
@ -1511,7 +1511,7 @@ void TileGenerator::renderMap()
|
||||
<< ")\n";
|
||||
}
|
||||
}
|
||||
if (!m_generateNoPrefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) {
|
||||
if (m_generatePrefetch == BlockListPrefetch::Prefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) {
|
||||
cout
|
||||
<< "Database format setting when using --disable-blocklist-prefetch: ";
|
||||
if (!m_recommendedDatabaseFormat.empty())
|
||||
@ -1536,7 +1536,7 @@ void TileGenerator::renderMap()
|
||||
if (progressIndicator && eraseProgress)
|
||||
cout << std::setw(50) << "" << "\r";
|
||||
|
||||
if (m_generateNoPrefetch) {
|
||||
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||
double queryFactor = 1.0 * m_db->getBlocksQueriedCount() / m_db->getBlocksReadCount();
|
||||
if (verboseStatistics >= 4) {
|
||||
std::cout << std::fixed << std::setprecision(2);
|
||||
|
@ -96,10 +96,16 @@ public:
|
||||
UnpackError(const char *t, size_t o, size_t l, size_t dl) : type(t), offset(o), length(l), dataLength(dl) {}
|
||||
};
|
||||
|
||||
enum class BlockListPrefetch {
|
||||
Prefetch,
|
||||
NoPrefetch,
|
||||
NoPrefetchForced
|
||||
};
|
||||
|
||||
TileGenerator();
|
||||
~TileGenerator();
|
||||
void setSilenceSuggestion(unsigned flags);
|
||||
void setGenerateNoPrefetch(int enable);
|
||||
void setGenerateNoPrefetch(BlockListPrefetch enable);
|
||||
void setDBFormat(BlockPos::StrFormat format, bool query);
|
||||
void setHeightMap(bool enable);
|
||||
void setHeightMapYScale(float scale);
|
||||
@ -230,7 +236,7 @@ private:
|
||||
int m_heightScaleMinor{ 0 };
|
||||
|
||||
DB *m_db = nullptr;
|
||||
int m_generateNoPrefetch{ 0 };
|
||||
BlockListPrefetch m_generatePrefetch{ BlockListPrefetch::Prefetch };
|
||||
bool m_databaseFormatSet{ false };
|
||||
BlockPos::StrFormat m_databaseFormat{ BlockPos::Unknown };
|
||||
std::string m_recommendedDatabaseFormat;
|
||||
|
@ -162,7 +162,7 @@ int Mapper::start(int argc, char *argv[]) {
|
||||
case OPT_NO_BLOCKLIST_PREFETCH:
|
||||
if (optarg && *optarg) {
|
||||
if (strlower(optarg) == "force")
|
||||
generator.setGenerateNoPrefetch(2);
|
||||
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetchForced);
|
||||
else {
|
||||
std::cerr << "Invalid parameter to '" << long_options[option_index].name << "'; expected 'force' or nothing." << std::endl;
|
||||
usage();
|
||||
@ -170,7 +170,7 @@ int Mapper::start(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
generator.setGenerateNoPrefetch(1);
|
||||
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetch);
|
||||
}
|
||||
break;
|
||||
case OPT_DATABASE_FORMAT: {
|
||||
@ -192,11 +192,11 @@ int Mapper::start(int argc, char *argv[]) {
|
||||
break;
|
||||
case OPT_PRESCAN_WORLD: {
|
||||
std::string opt = strlower(optarg);
|
||||
generator.setGenerateNoPrefetch(0);
|
||||
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::Prefetch);
|
||||
if (opt == "disabled-force")
|
||||
generator.setGenerateNoPrefetch(2);
|
||||
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetchForced);
|
||||
else if (opt == "disabled")
|
||||
generator.setGenerateNoPrefetch(1);
|
||||
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetch);
|
||||
else if (opt == "auto")
|
||||
generator.setScanEntireWorld(false);
|
||||
else if (opt == "full")
|
||||
|
Loading…
x
Reference in New Issue
Block a user