diff --git a/src/client/fm_far_container.cpp b/src/client/fm_far_container.cpp index 2bf9df40a..fa35fddd9 100644 --- a/src/client/fm_far_container.cpp +++ b/src/client/fm_far_container.cpp @@ -24,8 +24,7 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos) const auto &storage = m_client->getEnv().getClientMap().far_blocks_storage[fmesh_step]; - if (const auto &it = storage.find(bpos_aligned); it != storage.end()) { - const auto &block = it->second; + if (const auto &block = storage.at_or(bpos_aligned)) { v3pos_t relpos = pos - bpos_aligned * MAP_BLOCKSIZE; const auto &relpos_shift = fmesh_step; // + 1; diff --git a/src/server/player_sao.h b/src/server/player_sao.h index 710f83b45..ba707632d 100644 --- a/src/server/player_sao.h +++ b/src/server/player_sao.h @@ -24,6 +24,7 @@ along with Freeminer. If not, see . #include #include #include "constants.h" +#include "irr_v3d.h" #include "metadata.h" #include "network/networkprotocol.h" #include "unit_sao.h" @@ -88,7 +89,7 @@ class PlayerSAO : public UnitSAO //fm: void addSpeed(v3f); std::atomic_uint m_ms_from_last_respawn {10000}; //more than ignore move time (1) - v3f m_last_stat_position {}; + v3opos_t m_last_stat_position {}; double last_time_online = 0; diff --git a/src/threading/concurrent_unordered_map.h b/src/threading/concurrent_unordered_map.h index a21b8316b..131198ac0 100644 --- a/src/threading/concurrent_unordered_map.h +++ b/src/threading/concurrent_unordered_map.h @@ -71,6 +71,15 @@ class concurrent_unordered_map_ : public std::unordered_map(args)...); } + const mapped_type &at_or(const key_type &k, const mapped_type ¬hing = {}) const + { + auto lock = LOCKER::lock_shared_rec(); + if (const auto it = full_type::find(k); it != full_type::end()) { + return it->second; + } + return nothing; + } + template decltype(auto) assign(Args &&...args) { diff --git a/src/threading/concurrent_unordered_set.h b/src/threading/concurrent_unordered_set.h index 2e94348e5..040f108ca 100644 --- a/src/threading/concurrent_unordered_set.h +++ b/src/threading/concurrent_unordered_set.h @@ -36,7 +36,7 @@ class concurrent_unordered_set_ : public std::unordered_set - Value &at_or(Args &&...args, const Value ¬hing = {}) + 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)...);