diff --git a/src/clientiface.h b/src/clientiface.h index 4d0bbb786..55edc7cf7 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -311,6 +311,7 @@ class RemoteClient bool isBlockSent(v3s16 p) const { + const auto lock = m_blocks_sent.lock_shared_rec(); return m_blocks_sent.find(p) != m_blocks_sent.end(); } @@ -408,7 +409,7 @@ class RemoteClient No MapBlock* is stored here because the blocks can get deleted. */ unsigned int m_nearest_unsent_reset_want = 0; - concurrent_shared_unordered_map m_blocks_sent; + concurrent_unordered_map m_blocks_sent; //std::unordered_set m_blocks_sent; diff --git a/src/fm_clientiface.cpp b/src/fm_clientiface.cpp index f1a966dfd..ae62d1dd5 100644 --- a/src/fm_clientiface.cpp +++ b/src/fm_clientiface.cpp @@ -326,7 +326,7 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge, */ double block_sent = 0; { - auto lock = m_blocks_sent.lock_shared_rec(); + const auto lock = m_blocks_sent.lock_shared_rec(); block_sent = m_blocks_sent.contains(p) ? m_blocks_sent.get(p) : 0; } diff --git a/src/fm_liquid.cpp b/src/fm_liquid.cpp index aa0bca78f..b40a4003b 100644 --- a/src/fm_liquid.cpp +++ b/src/fm_liquid.cpp @@ -19,21 +19,20 @@ You should have received a copy of the GNU General Public License along with Freeminer. If not, see . */ -#include -#include -#include +#include "emerge.h" +#include "gamedef.h" #include "irr_v3d.h" +#include "log_types.h" #include "map.h" -#include "gamedef.h" -#include "scripting_server.h" -#include "settings.h" #include "nodedef.h" -#include "log_types.h" -#include "server.h" -// #include "scripting_game.h" #include "profiler.h" -#include "emerge.h" +#include "scripting_server.h" +#include "server.h" +#include "settings.h" #include "util/unordered_map_hash.h" +#include +#include +#include #define LIQUID_DEBUG 0 @@ -190,9 +189,8 @@ NEXT_LIQUID:; nb.drop = 0; if (!nb.node) { - // if (i == D_SELF && (loopcount % 2) && initial_size < m_liquid_step_flow - // * 3) must_reflow_third[nb.pos] = 1; - // must_reflow_third.push_back(nb.pos); + //if (i == D_SELF && (loopcount % 8) && initial_size < m_liquid_step_flow * 3) // must_reflow_third[nb.pos] = 1; + // must_reflow_third.emplace_back(nb.pos); continue; } @@ -296,8 +294,8 @@ NEXT_LIQUID:; setNode(neighbors[D_BOTTOM].pos, neighbors[D_SELF].node); // must_reflow_second[neighbors[D_SELF].pos] = 1; // must_reflow_second[neighbors[D_BOTTOM].pos] = 1; - must_reflow_second.push_back(neighbors[D_SELF].pos); - must_reflow_second.push_back(neighbors[D_BOTTOM].pos); + must_reflow_second.emplace_back(neighbors[D_SELF].pos); + must_reflow_second.emplace_back(neighbors[D_BOTTOM].pos); #if LIQUID_DEBUG infostream << "Liquid swap1" << neighbors[D_SELF].pos << nodemgr->get(neighbors[D_SELF].node).name @@ -316,8 +314,8 @@ NEXT_LIQUID:; setNode(neighbors[D_TOP].pos, neighbors[D_SELF].node); // must_reflow_second[neighbors[D_SELF].pos] = 1; // must_reflow_second[neighbors[D_TOP].pos] = 1; - must_reflow_second.push_back(neighbors[D_SELF].pos); - must_reflow_second.push_back(neighbors[D_TOP].pos); + must_reflow_second.emplace_back(neighbors[D_SELF].pos); + must_reflow_second.emplace_back(neighbors[D_TOP].pos); #if LIQUID_DEBUG infostream << "Liquid swap2" << neighbors[D_TOP].pos << nodemgr->get(neighbors[D_TOP].node).name @@ -740,7 +738,7 @@ NEXT_LIQUID:; for (uint8_t ir = D_SELF + 1; ir < D_TOP; ++ir) { // only same level uint8_t ii = liquid_random_map[(loopcount + loop_rand + 5) % 4][ir]; if (neighbors[ii].liquid) - must_reflow_second.push_back( + must_reflow_second.emplace_back( neighbors[i].pos + liquid_flow_dirs[ii]); // must_reflow_second[neighbors[i].pos + liquid_flow_dirs[ii]] = 1; } @@ -775,8 +773,9 @@ NEXT_LIQUID:; blocks_lighting_update.emplace(blockpos); } // fmtodo: make here random %2 or.. - if (total_level < level_max * can_liquid) - must_reflow.push_back(neighbors[i].pos); + if (total_level < level_max * can_liquid) { + must_reflow.emplace_back(neighbors[i].pos); + } } if (fall_down) { @@ -842,7 +841,7 @@ NEXT_LIQUID:; } for (const auto &blockpos : blocks_lighting_update) { - MapBlock *block = + auto block = getBlockNoCreateNoEx(blockpos, true); // remove true if light bugs if (!block) continue; diff --git a/src/map.cpp b/src/map.cpp index 7334a9048..822e31ce1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -73,7 +73,6 @@ Map::Map(IGameDef *gamedef): m_gamedef(gamedef), m_nodedef(gamedef->ndef()) { - m_liquid_step_flow = 1000; time_life = 0; getBlockCacheFlush(); } diff --git a/src/map.h b/src/map.h index 595b46f58..db8c7d337 100644 --- a/src/map.h +++ b/src/map.h @@ -282,7 +282,7 @@ class Map : public NodeContainer MapNode getNodeTry(const v3pos_t &p); //MapNode getNodeNoLock(v3s16 p); // dont use - std::atomic_uint m_liquid_step_flow{0}; + std::atomic_uint m_liquid_step_flow{1000}; virtual s16 getHeat(const v3pos_t &p, bool no_random = 0); virtual s16 getHumidity(const v3pos_t &p, bool no_random = 0);