From 790b86782aac35c312f83e3ecd0879ddef773734 Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Sun, 5 Nov 2023 17:41:19 -0300 Subject: [PATCH] fix smell --- src/map/mapcache.cpp | 2 +- src/map/mapcache.hpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/map/mapcache.cpp b/src/map/mapcache.cpp index c8ffc96e70f..e0e58e5f099 100644 --- a/src/map/mapcache.cpp +++ b/src/map/mapcache.cpp @@ -107,7 +107,7 @@ std::shared_ptr MapCache::getOrCreateTileFromCache(const std::unique_ptrgetTile(x, y); } - std::unique_lock l(floor->mutex); + std::unique_lock l(floor->getMutex()); const uint8_t z = floor->getZ(); diff --git a/src/map/mapcache.hpp b/src/map/mapcache.hpp index 00e4a8cca2f..6265e979fa4 100644 --- a/src/map/mapcache.hpp +++ b/src/map/mapcache.hpp @@ -107,10 +107,13 @@ struct Floor { return z; } - mutable std::shared_mutex mutex; + auto &getMutex() const { + return mutex; + } private: std::pair, std::shared_ptr> tiles[FLOOR_SIZE][FLOOR_SIZE] = {}; + mutable std::shared_mutex mutex; uint8_t z { 0 }; };