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 75d531203..be4ba8fde 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 e9f8947b1..b9b5ad0bb 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; } @@ -719,6 +720,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();