fix clang

This commit is contained in:
proller committed 2026-02-14 02:45:00 +01:00
1 parent 4ee12d5f66
commit 97fa37731e
2 files changed
+67 -62

No files matched your search

+56 -54
View File
@@ -29,78 +29,80 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos)
const auto tree_result =
farmesh::getFarParams(control, player_block_pos, block_pos, true);
if (tree_result) {
const auto &step = tree_result->step;
const v3bpos_t &bpos_aligned = tree_result->pos;
const auto &step = tree_result->step;
const v3bpos_t &bpos_aligned = tree_result->pos;
MapBlockPtr block;
const auto step_block_pos = std::make_pair(step, bpos_aligned);
if (block_cache && step_block_pos == block_cache_p) {
block = block_cache;
}
MapBlockPtr block;
const auto step_block_pos = std::make_pair(step, bpos_aligned);
if (block_cache && step_block_pos == block_cache_p) {
block = block_cache;
}
if (!block && step < FARMESH_STEP_MAX) {
const auto &storage = client_map.far_blocks_storage[step];
block = storage.get(bpos_aligned).block;
}
if (!block && step < FARMESH_STEP_MAX) {
const auto &storage = client_map.far_blocks_storage[step];
block = storage.get(bpos_aligned).block;
}
const auto loadBlock = [this, &client_map](
const auto &bpos, const auto step) -> MapBlockPtr {
const auto loadBlock = [this, &client_map](
const auto &bpos, const auto step) -> MapBlockPtr {
auto *dbase = GetFarDatabase(
{}, m_client->far_dbases, m_client->m_world_path, step);
if (!dbase) {
return {};
}
MapBlockPtr block = client_map.createBlankBlockNoInsert(bpos);
if (!dbase) {
return {};
}
MapBlockPtr block = client_map.createBlankBlockNoInsert(bpos);
std::string blob;
dbase->loadBlock(bpos, &blob);
if (!blob.length()) {
return {};
}
std::string blob;
dbase->loadBlock(bpos, &blob);
if (!blob.length()) {
return {};
}
std::istringstream is(blob, std::ios_base::binary);
std::istringstream is(blob, std::ios_base::binary);
u8 version = SER_FMT_VER_INVALID;
is.read((char *)&version, 1);
u8 version = SER_FMT_VER_INVALID;
is.read((char *)&version, 1);
if (is.fail()) {
return {};
}
if (is.fail()) {
return {};
}
// Read basic data
if (!block->deSerialize(is, version, true)) {
return {};
}
return block;
};
// Read basic data
if (!block->deSerialize(is, version, true)) {
return {};
}
return block;
};
if (!block && !m_client->m_simple_singleplayer_mode &&
!m_client->far_container.have_params) {
thread_local static std::array<std::unordered_set<v3bpos_t>, FARMESH_STEP_MAX>
miss_cache;
if (!miss_cache[step].contains(bpos_aligned)) {
block = loadBlock(bpos_aligned, step);
if (!block) {
miss_cache[step].emplace(bpos_aligned);
if (!block && !m_client->m_simple_singleplayer_mode &&
!m_client->far_container.have_params) {
thread_local static std::array<std::unordered_set<v3bpos_t>, FARMESH_STEP_MAX>
miss_cache;
if (!miss_cache[step].contains(bpos_aligned)) {
block = loadBlock(bpos_aligned, step);
if (!block) {
miss_cache[step].emplace(bpos_aligned);
}
}
}
}
if (block) {
block_cache_p = step_block_pos;
block_cache = block;
if (block) {
block_cache_p = step_block_pos;
block_cache = block;
const v3pos_t relpos = pos - bpos_aligned * MAP_BLOCKSIZE;
const v3pos_t relpos = pos - bpos_aligned * MAP_BLOCKSIZE;
const auto &relpos_shift = step;
const auto relpos_shifted = v3pos_t{relpos.X >> relpos_shift,
relpos.Y >> relpos_shift, relpos.Z >> relpos_shift};
const auto &n = block->getNodeNoLock(relpos_shifted);
if (n.getContent() != CONTENT_IGNORE) {
return n;
const auto &relpos_shift = step;
const auto relpos_shifted =
v3pos_t{static_cast<pos_t>(relpos.X >> relpos_shift),
static_cast<pos_t>(relpos.Y >> relpos_shift),
static_cast<pos_t>(relpos.Z >> relpos_shift)};
const auto &n = block->getNodeNoLock(relpos_shifted);
if (n.getContent() != CONTENT_IGNORE) {
return n;
}
}
}
}
if (const auto &v = m_mg->visible_content(pos, use_weather); v.getContent()) {
return v;
+11 -8
View File
@@ -97,7 +97,7 @@ void FarMesh::makeFarBlock(const v3bpos_t &blockpos, block_step_t step)
for (pos_t y = 0; y < 1 << draw_control.cell_size_pow; ++y) {
for (pos_t z = 0; z < 1 << draw_control.cell_size_pow; ++z) {
client_map.m_far_blocks_ask.emplace(
blockpos_actual + v3bpos_t{x, y, z} * (1 << step),
blockpos_actual + v3bpos_t{x, y, z} * (1 << step),
std::make_pair(step, far_iteration_complete));
}
}
@@ -358,17 +358,20 @@ int FarMesh::go_flat()
return false;
}
#endif
const auto add_size = 1 << (step + draw_control.cell_size_pow);
const bpos_t add_size = 1 << (step + draw_control.cell_size_pow);
for (const auto &add : {
v3bpos_t{0, 0, 0},
v3bpos_t{0, add_size, 0},
v3bpos_t{0, -add_size, 0},
v3bpos_t{0, static_cast<bpos_t>(-add_size), 0},
}) {
v3bpos_t bpos_new{bpos.X + add.X, add.Y, bpos.Z + add.Z};
bpos_new.Y += mg->getGroundLevelAtPoint(
v2pos_t{(bpos_new.X << MAP_BLOCKP) - 1,
(bpos_new.Z << MAP_BLOCKP) - 1}) >>
MAP_BLOCKP;
v3bpos_t bpos_new{static_cast<bpos_t>(bpos.X + add.X), add.Y,
static_cast<bpos_t>(bpos.Z + add.Z)};
bpos_new.Y +=
mg->getGroundLevelAtPoint(v2pos_t{
static_cast<pos_t>((bpos_new.X << MAP_BLOCKP) - 1),
static_cast<pos_t>(
(bpos_new.Z << MAP_BLOCKP) - 1)}) >>
MAP_BLOCKP;
const auto res = farmesh::getFarParams(
draw_control, player_block_pos, bpos_new);
if (!res)