Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 14, 2024
1 parent dd1ab8a commit a7a0afd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 16 additions & 3 deletions src/fm_world_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/fm_world_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a7a0afd

Please sign in to comment.