diff --git a/src/fm_world_merge.cpp b/src/fm_world_merge.cpp index 6ce0407fc..d62bed2b3 100644 --- a/src/fm_world_merge.cpp +++ b/src/fm_world_merge.cpp @@ -82,19 +82,31 @@ void WorldMerger::merge_one_block(MapDatabase *dbase, MapDatabase *dbase_up, blocks[rpos] = nblock; } } - if (!timestamp) + + if (!timestamp) { timestamp = m_server->getEnv().getGameTime(); + } MapBlockP block_up; if (partial) { block_up = load_block(m_server, dbase_up, bpos_aligned); + if (block_up && lazy_up) { + // actionstream << "s=" << step <<" at=" << block_up->getActualTimestamp() << " t=" << block_up->getTimestamp() << " myts=" << timestamp << "\n"; + const auto up_ts = block_up->getActualTimestamp(); + if (timestamp < up_ts + lazy_up) { + return; + } + } } + if (!block_up) { block_up.reset( m_server->getEnv().getServerMap().createBlankBlockNoInsert(bpos_aligned)); } + block_up->setTimestampNoChangedFlag(timestamp); + size_t not_empty_nodes{}; { const auto block_size = MAP_BLOCKSIZE; @@ -371,9 +383,10 @@ void *WorldMergeThread::run() }}, }; { - g_settings->getU64NoEx("world_merge_throttle", merger.world_merge_throttle); + g_settings->getU32NoEx("world_merge_throttle", merger.world_merge_throttle); merger.world_merge_max_clients = m_server->isSingleplayer() ? 1 : 0; - g_settings->getU64NoEx("world_merge_max_clients", merger.world_merge_max_clients); + g_settings->getU32NoEx("world_merge_max_clients", merger.world_merge_max_clients); + g_settings->getU32NoEx("world_merge_lazy_up", merger.lazy_up); { merger.world_merge_load_all = -1; diff --git a/src/fm_world_merge.h b/src/fm_world_merge.h index af62ae51f..8bc41b1da 100644 --- a/src/fm_world_merge.h +++ b/src/fm_world_merge.h @@ -48,10 +48,11 @@ struct WorldMerger return false; } - u64 world_merge_throttle{}; - u64 world_merge_max_clients{}; + uint32_t world_merge_throttle{}; + uint32_t world_merge_max_clients{}; int16_t world_merge_load_all{}; // -1 : auto; 0 : disable; 1 : force bool partial{}; + uint32_t lazy_up{}; void merge_one_block(MapDatabase *dbase, MapDatabase *dbase_up, const v3bpos_t &bpos_aligned, MapBlock::block_step_t step);