From 28f9dea0cbac46aa484c6bf5d565eefd5afcd350 Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 15 Oct 2024 01:22:16 +0200 Subject: [PATCH 1/2] fix --- src/server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server.cpp b/src/server.cpp index 375cf5a1d..5f64f86e8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -393,6 +393,7 @@ Server::~Server() // Stop threads if (m_thread) { + if (m_env) m_env->getServerMap().save(MOD_STATE_WRITE_AT_UNLOAD); // save before merge thread exit stop(); delete m_thread; } From f8f43aa16523a000f38a94c6be5a912285d6245b Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 15 Oct 2024 01:45:45 +0200 Subject: [PATCH 2/2] fix --- src/client/fm_client.cpp | 2 +- src/client/hud.cpp | 32 ++++++++++++++++---------------- src/server.cpp | 2 ++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/client/fm_client.cpp b/src/client/fm_client.cpp index 47d9ba4e8..142a83c49 100644 --- a/src/client/fm_client.cpp +++ b/src/client/fm_client.cpp @@ -156,7 +156,7 @@ void Client::createFarMesh(MapBlockP &block) const auto &step = block->far_step; MeshMakeData mdat(m_client, false, 0, step, &m_client->far_container); mdat.m_blockpos = blockpos_actual; - auto mbmsh = std::make_shared(&mdat, m_camera_offset); + const auto mbmsh = std::make_shared(&mdat, m_camera_offset); block->setFarMesh(mbmsh, step); block->creating_far_mesh = false; } diff --git a/src/client/hud.cpp b/src/client/hud.cpp index c7c8ac5ee..d85112f09 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -910,11 +910,11 @@ void Hud::drawBlockBounds() v3s16 pos = player->getStandingNodePos(); if (m_block_bounds_mode == BLOCK_BOUNDS_FAR_DRAWN) { - v3f offset = intToFloat(client->getCamera()->getOffset(), BS); + const auto offset = posToOpos(client->getCamera()->getOffset(), BS); //s8 radius = m_block_bounds_mode == BLOCK_BOUNDS_NEAR ? 2 : 0; - v3f halfNode = v3f(BS, BS, BS) / 2.0f; + const auto halfNode = v3opos_t(BS, BS, BS) / 2.0f; const auto &client_map = client->getEnv().getClientMap(); const auto & far_blocks = client_map.m_far_blocks; @@ -961,19 +961,19 @@ void Hud::drawBlockBounds() lod_step = mesh->lod_step; far_step = mesh->far_step; } - aabb3f box( - intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1, - intToFloat( + const aabb3f box( + oposToV3f(intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1), + oposToV3f(intToFloat( ((blockPos)*MAP_BLOCKSIZE) + (MAP_BLOCKSIZE * fscale - fscale), BS) - - offset + halfNode - 1); + offset + halfNode - 1)); driver->draw3DBox(box, video::SColor(200 + b, 255 - lod_step * 10 + b, 255 -g - far_step * 10, fscale * 20)); } } } else if (m_block_bounds_mode == BLOCK_BOUNDS_FAR_REQUEST) { const auto offset = intToFloat(client->getCamera()->getOffset(), BS); - const auto halfNode = v3f(BS, BS, BS) / 2.0f; + const auto halfNode = v3opos_t(BS, BS, BS) / 2.0f; const auto &far_blocks = client->getEnv().getClientMap().m_far_blocks_ask; { for (const auto &[blockPos, step_ts] : far_blocks) { @@ -982,19 +982,19 @@ void Hud::drawBlockBounds() int lod_step = 0; int far_step = 0; int b = 0; - aabb3f box( - intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1, - intToFloat( + const aabb3f box( + oposToV3f(intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1), + oposToV3f(intToFloat( ((blockPos)*MAP_BLOCKSIZE) + (MAP_BLOCKSIZE << mesh_step ) - (1 << mesh_step), // - 1 BS) - - offset + halfNode - 1); + offset + halfNode - 1)); driver->draw3DBox(box, video::SColor(200 + b, 255 - lod_step * 10 + b, 255 - far_step * 10, fscale * 20)); } } } else if (m_block_bounds_mode == Hud::BLOCK_BOUNDS_FAR_STORAGE) { const auto offset = intToFloat(client->getCamera()->getOffset(), BS); - const auto halfNode = v3f(BS, BS, BS) / 2.0f; + const auto halfNode = v3opos_t(BS, BS, BS) / 2.0f; const auto &far_blocks = client->getEnv().getClientMap().far_blocks_storage; for (size_t step = 0; step < far_blocks.size(); ++step) { @@ -1006,12 +1006,12 @@ void Hud::drawBlockBounds() int lod_step = 0; int far_step = 0; int b = 0; - aabb3f box( - intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1, - intToFloat( + const aabb3f box( + oposToV3f(intToFloat((blockPos)*MAP_BLOCKSIZE, BS) - offset - halfNode + 1), + oposToV3f(intToFloat( ((blockPos)*MAP_BLOCKSIZE) + (MAP_BLOCKSIZE << (mesh_step) ) - (1 << mesh_step), ///// -1 ? BS) - - offset + (halfNode - 1)); + offset + (halfNode - 1))); driver->draw3DBox(box, video::SColor(200 + b, 255 - lod_step * 10 + b, 255 - far_step * 10, fscale * 20 + 20*has_mesh)); } diff --git a/src/server.cpp b/src/server.cpp index 5f64f86e8..ca2eea471 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -712,6 +712,8 @@ void Server::stop() { infostream<<"Server: Stopping and waiting threads"<getServerMap().save(MOD_STATE_WRITE_AT_UNLOAD); + // Stop threads (set run=false first so both start stopping) m_thread->stop();