From dd1ab8abf038ab2b2354b7c1904ffe4c159489fa Mon Sep 17 00:00:00 2001 From: proller Date: Mon, 14 Oct 2024 16:14:28 +0200 Subject: [PATCH] fix --- src/client/content_cao.cpp | 6 +++--- src/client/content_cao.h | 2 +- src/client/fm_farmesh.cpp | 3 +-- src/threading/concurrent_unordered_map.h | 23 +++++++++++++---------- src/threading/concurrent_unordered_set.h | 11 ----------- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index d28b32900..4674d4255 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -453,7 +453,7 @@ scene::ISceneNode *GenericCAO::getSceneNode() const } if (m_wield_meshnode) { - return m_wield_meshnode; + return m_wield_meshnode.get(); } if (m_spritenode) { @@ -585,7 +585,7 @@ void GenericCAO::removeFromScene(bool permanent) m_animated_meshnode = nullptr; } else if (m_wield_meshnode) { m_wield_meshnode->remove(); - m_wield_meshnode->drop(); + //m_wield_meshnode->drop(); m_wield_meshnode = nullptr; } else if (m_spritenode) { m_spritenode->remove(); @@ -814,7 +814,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) */ item.deSerialize(m_prop.wield_item, m_client->idef()); } - m_wield_meshnode = new WieldMeshSceneNode(m_smgr, -1); + m_wield_meshnode.reset(new WieldMeshSceneNode(m_smgr, -1)); m_wield_meshnode->setItem(item, m_client, (m_prop.visual == "wielditem")); diff --git a/src/client/content_cao.h b/src/client/content_cao.h index 5d4c3a761..db28b41e6 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -86,7 +86,7 @@ class GenericCAO : public ClientActiveObject aabb3f m_selection_box = aabb3f(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.); scene::IMeshSceneNode *m_meshnode = nullptr; scene::IAnimatedMeshSceneNode *m_animated_meshnode = nullptr; - WieldMeshSceneNode *m_wield_meshnode = nullptr; + std::shared_ptr m_wield_meshnode; scene::IBillboardSceneNode *m_spritenode = nullptr; scene::IDummyTransformationSceneNode *m_matrixnode = nullptr; Nametag *m_nametag = nullptr; diff --git a/src/client/fm_farmesh.cpp b/src/client/fm_farmesh.cpp index aa6ef846e..b71cfcfb7 100644 --- a/src/client/fm_farmesh.cpp +++ b/src/client/fm_farmesh.cpp @@ -93,8 +93,7 @@ void FarMesh::makeFarBlock( blockpos_actual, std::make_pair(step, far_iteration_complete)); new_block = true; - block = std::make_shared( - &client_map, blockpos_actual, m_client); + block.reset(client_map.createBlankBlockNoInsert(blockpos_actual)); block->far_step = step; far_blocks.insert_or_assign(blockpos_actual, block); ++m_client->m_new_meshes; diff --git a/src/threading/concurrent_unordered_map.h b/src/threading/concurrent_unordered_map.h index 131198ac0..f6532d593 100644 --- a/src/threading/concurrent_unordered_map.h +++ b/src/threading/concurrent_unordered_map.h @@ -58,23 +58,26 @@ class concurrent_unordered_map_ : public std::unordered_map(args)...); } - mapped_type nothing = {}; + const mapped_type nothing{}; template - mapped_type &get(Args &&...args) + const mapped_type &get(Args &&...args) const { - auto lock = LOCKER::lock_shared_rec(); - - if (!full_type::contains(std::forward(args)...)) - return nothing; + const auto lock = LOCKER::lock_shared_rec(); - return full_type::operator[](std::forward(args)...); + if (const auto &it = full_type::find(std::forward(args)...); + it != full_type::end()) { + return it->second; + } + return nothing; } - const mapped_type &at_or(const key_type &k, const mapped_type ¬hing = {}) const + template + const mapped_type &at_or(Args &&...args) const { - auto lock = LOCKER::lock_shared_rec(); - if (const auto it = full_type::find(k); it != full_type::end()) { + const auto lock = LOCKER::lock_shared_rec(); + if (const auto &it = full_type::find(std::forward(args)...); + it != full_type::end()) { return it->second; } return nothing; diff --git a/src/threading/concurrent_unordered_set.h b/src/threading/concurrent_unordered_set.h index 040f108ca..0b4fda4d0 100644 --- a/src/threading/concurrent_unordered_set.h +++ b/src/threading/concurrent_unordered_set.h @@ -35,17 +35,6 @@ class concurrent_unordered_set_ : public std::unordered_set - const Value &at_or(Args &&...args, const Value ¬hing = {}) const - { - auto lock = LOCKER::lock_shared_rec(); - if (const auto it = full_type::find(std::forward(args)...); - it != full_type::end()) { - return *it; - } - return nothing; - } - LOCK_UNIQUE_PROXY(full_type, operator=); LOCK_SHARED_PROXY(full_type, empty); LOCK_SHARED_PROXY(full_type, size);