Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 14, 2024
1 parent 3a8a804 commit d0f846d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/client/fm_far_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/server/player_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include <atomic>
#include <set>
#include "constants.h"
#include "irr_v3d.h"
#include "metadata.h"
#include "network/networkprotocol.h"
#include "unit_sao.h"
Expand Down Expand Up @@ -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;


Expand Down
9 changes: 9 additions & 0 deletions src/threading/concurrent_unordered_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class concurrent_unordered_map_ : public std::unordered_map<Key, T, Hash, Pred,
return full_type::operator[](std::forward<Args>(args)...);
}

const mapped_type &at_or(const key_type &k, const mapped_type &nothing = {}) 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 <typename... Args>
decltype(auto) assign(Args &&...args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/threading/concurrent_unordered_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class concurrent_unordered_set_ : public std::unordered_set<Value, Hash, Pred, A
~concurrent_unordered_set_() { clear(); }

template <typename... Args>
Value &at_or(Args &&...args, const Value &nothing = {})
const Value &at_or(Args &&...args, const Value &nothing = {}) const
{
auto lock = LOCKER::lock_shared_rec();
if (const auto it = full_type::find(std::forward<Args>(args)...);
Expand Down

0 comments on commit d0f846d

Please sign in to comment.