Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.8.0' into wip5.8.0webport
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Jan 6, 2025
2 parents 9602a13 + 9f14a7c commit f334186
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 54 deletions.
2 changes: 1 addition & 1 deletion games/default
4 changes: 2 additions & 2 deletions src/client/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,9 @@ void Camera::updateViewingRange()

m_cameranode->setNearValue(0.1f * BS);

m_draw_control.wanted_range = std::fmin(adjustDist(viewing_range, getFovMax()), FARMESH_LIMIT * 2);
m_draw_control.wanted_range = std::fmin(adjustDist(viewing_range, getFovMax()), FARMESH_LIMIT * 4);
if (m_draw_control.range_all) {
m_cameranode->setFarValue(FARMESH_LIMIT * 2 * BS);
m_cameranode->setFarValue(FARMESH_LIMIT * 4 * BS);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/fm_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
} else {
static thread_local const auto farmesh_server =
g_settings->getU16("farmesh_server");
if (!farmesh_server) {
static thread_local const auto farmesh = g_settings->getU16("farmesh");
if (!farmesh_server || !farmesh) {
return;
}

Expand Down
11 changes: 9 additions & 2 deletions src/client/fm_farmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void FarMesh::makeFarBlocks(const v3bpos_t &blockpos, block_step_t step)
const auto &control = m_client->getEnv().getClientMap().getControl();
const auto bpos = getFarActual(
bpos_dir, getNodeBlockPos(m_camera_pos_aligned), step, control);
auto block_step_correct =
const auto block_step_correct =
getFarStep(control, getNodeBlockPos(m_camera_pos_aligned), bpos);
makeFarBlock(bpos, block_step_correct);
}
Expand Down Expand Up @@ -278,6 +278,10 @@ int FarMesh::go_container()
[this, &cbpos](const v3bpos_t &bpos, const bpos_t &size) -> bool {
const block_step_t step = log(size) / log(2);

if (step >= FARMESH_STEP_MAX) {
return false;
}

// TODO: use block center
const auto bdist = radius_box(cbpos, bpos);
if ((bdist << MAP_BLOCKP) > farmesh_all_changed) {
Expand Down Expand Up @@ -328,8 +332,11 @@ int FarMesh::go_flat()
(bpos_new.Z << MAP_BLOCKP) - 1)) >>
MAP_BLOCKP;

auto step_new = getFarStep(draw_control,
const auto step_new = getFarStep(draw_control,
getNodeBlockPos(m_camera_pos_aligned), bpos_new);

if (step_new >= FARMESH_STEP_MAX)
continue;
blocks[step_new].emplace(bpos_new);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/client/renderingengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Minimap;
class RenderingCore;

// Instead of a mechanism to disable fog we just set it to be really far away
#define FOG_RANGE_ALL (FARMESH_LIMIT*3 * BS)
#define FOG_RANGE_ALL (FARMESH_LIMIT*4 * BS)

class RenderingEngine
{
Expand Down
5 changes: 5 additions & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
// I really don't want to make every algorithm to check if it's going near
// the limit or not, so this is lower.
// This is the maximum value the setting map_generation_limit can be
#if USE_POS32
#define MAX_MAP_GENERATION_LIMIT (2147483008)
#define FARMESH_LIMIT (100000)
#else
#define MAX_MAP_GENERATION_LIMIT (31007)
#define FARMESH_LIMIT (31007)
#endif

// fm 32bit prepare (keep 31k)
#define WEATHER_LIMIT (31007)
Expand Down
2 changes: 1 addition & 1 deletion src/content/subgames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
backend = "dummy";
}
conf.set("backend", backend);
conf.set("player_backend", "leveldb");
conf.set("player_backend", "leveldbfm");
conf.set("auth_backend", "leveldb");
conf.set("mod_storage_backend", "files");
#elif USE_SQLITE3
Expand Down
2 changes: 1 addition & 1 deletion src/debug/iostream_debug_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ std::enable_if_t<priority == 1
return out;
}
if constexpr (std::is_pointer_v<T>) {
out << "*" << (long) x << " ";
out << "*" << (long long) x << " ";
}
return dumpValue(out, *x);
}
Expand Down
6 changes: 3 additions & 3 deletions src/fm_clientiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int RemoteClient::GetNextBlocksFm(ServerEnvironment *env, EmergeManager *emerge,

v3pos_t center_nodepos = floatToInt(playerpos_predicted, BS);

v3pos_t center = getNodeBlockPos(center_nodepos);
auto center = getNodeBlockPos(center_nodepos);

// Camera position and direction
auto camera_pos = sao->getEyePosition();
Expand Down Expand Up @@ -284,7 +284,7 @@ int RemoteClient::GetNextBlocksFm(ServerEnvironment *env, EmergeManager *emerge,
}

for (auto li = list.begin(); li != list.end(); ++li) {
const v3pos_t p = *li + center;
const auto p = *li + center;

/*
Send throttling
Expand Down Expand Up @@ -607,7 +607,7 @@ uint32_t RemoteClient::SendFarBlocks()
}

// TODO: why not have?
if (have_farmesh_quality) {
if (farmesh && have_farmesh_quality && farmesh_all_changed) {
auto *player = m_env->getPlayer(peer_id);
if (!player)
return 0;
Expand Down
10 changes: 8 additions & 2 deletions src/fm_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ void *WorldMergeThread::run()
.dbase{m_server->getEnv().m_map->dbase},
.save_dir{m_server->getEnv().m_map->m_savedir},
};

{
g_settings->getU32NoEx("world_merge_throttle", merger.world_merge_throttle);
merger.world_merge_max_clients = m_server->isSingleplayer() ? 1 : 0;
Expand All @@ -763,7 +764,7 @@ void *WorldMergeThread::run()
merger.world_merge_load_all = -1;
g_settings->getS16NoEx("world_merge_load_all", merger.world_merge_load_all);
merger.world_merge_throttle = m_server->isSingleplayer() ? 10 : 0;
u64 world_merge_all = 0;
uint64_t world_merge_all = 0;
g_settings->getU64NoEx("world_merge_all", world_merge_all);
if (world_merge_all) {
merger.merge_all();
Expand All @@ -773,14 +774,19 @@ void *WorldMergeThread::run()
merger.world_merge_load_all = 0;
merger.partial = true;

// Minimum blocks changed for periodic merge
uint64_t world_merge_min = 100;
g_settings->getU64NoEx("world_merge_min", world_merge_min);

while (!stopRequested()) {
if (merger.throttle()) {
tracestream << "World merge wait" << '\n';
sleep(10);
continue;
}
if (merger.merge_server_diff(
m_server->getEnv().getServerMap().changed_blocks_for_merge)) {
m_server->getEnv().getServerMap().changed_blocks_for_merge,
world_merge_min)) {
break;
}

Expand Down
9 changes: 7 additions & 2 deletions src/fm_world_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bool WorldMerger::merge_one_step(

printstat();

return false;
return !processed;
}

bool WorldMerger::merge_list(std::unordered_set<v3bpos_t> &blocks_todo)
Expand Down Expand Up @@ -358,10 +358,15 @@ bool WorldMerger::merge_changed()
}

bool WorldMerger::merge_server_diff(
concurrent_unordered_set<v3bpos_t> &smap_changed_blocks_for_merge)
concurrent_unordered_set<v3bpos_t> &smap_changed_blocks_for_merge,
size_t min_blocks)
{
{
const auto lock = smap_changed_blocks_for_merge.try_lock_unique_rec();
if (smap_changed_blocks_for_merge.size() < min_blocks) {
return false;
}

changed_blocks_for_merge = smap_changed_blocks_for_merge;
smap_changed_blocks_for_merge.clear();
}
Expand Down
3 changes: 2 additions & 1 deletion src/fm_world_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class WorldMerger
bool merge_all();
bool merge_changed();
bool merge_server_diff(
concurrent_unordered_set<v3bpos_t> &smap_changed_blocks_for_merge);
concurrent_unordered_set<v3bpos_t> &smap_changed_blocks_for_merge,
size_t min_blocks = 1);
bool add_changed(const v3bpos_t &bpos);
};
Loading

0 comments on commit f334186

Please sign in to comment.