Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Sep 11, 2024
1 parent 997ec65 commit f3369dc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/clientiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<v3bpos_t, double, v3posHash, v3posEqual> m_blocks_sent;
concurrent_unordered_map<v3bpos_t, double, v3posHash, v3posEqual> m_blocks_sent;

//std::unordered_set<v3s16> m_blocks_sent;

Expand Down
2 changes: 1 addition & 1 deletion src/fm_clientiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
41 changes: 20 additions & 21 deletions src/fm_liquid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ You should have received a copy of the GNU General Public License
along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstddef>
#include <cstdint>
#include <unordered_set>
#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 <cstddef>
#include <cstdint>
#include <unordered_set>

#define LIQUID_DEBUG 0

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Map::Map(IGameDef *gamedef):
m_gamedef(gamedef),
m_nodedef(gamedef->ndef())
{
m_liquid_step_flow = 1000;
time_life = 0;
getBlockCacheFlush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f3369dc

Please sign in to comment.