Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Aug 22, 2024
1 parent 71996ff commit e6a25ba
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 28 deletions.
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ if(NOT MSVC)
message(STATUS "Build with tcmalloc ${TCMALLOC_LIBRARY} ${PROFILER_LIBRARY}")
endif()


option(ENABLE_UNWIND "Enable unwind" 1)
if(ENABLE_UNWIND)

if(USE_STATIC_LIBRARIES)
list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
endif()
Expand All @@ -157,6 +161,13 @@ if(NOT MSVC)
message(STATUS "Build with unwind ${UNWIND_LIBRARY}")
endif()


if(USE_STATIC_LIBRARIES)
list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
endif()

endif()

if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
SET(PLATFORM_LIBS ${PLATFORM_LIBS} execinfo)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/client/fm_farmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int FarMesh::go_direction(const size_t dir_n)
#if FARMESH_FAST
makeFarBlock(blockpos, block_step);
#else
// less holes, more unused meshes:
// less holes, more unused meshes:
makeFarBlock7(blockpos, block_step);
#endif
break;
Expand Down Expand Up @@ -328,7 +328,7 @@ void FarMesh::update(v3opos_t camera_pos,
const auto far_fast =
!m_control->farmesh_stable &&
(
//m_client->getEnv().getClientMap().m_far_fast &&
//m_client->getEnv().getClientMap().m_far_fast &&
m_speed > 200 * BS ||
m_camera_pos_aligned.getDistanceFrom(camera_pos_aligned_int) > 1000);

Expand Down
2 changes: 1 addition & 1 deletion src/client/fm_farmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FarMesh
int processed = -1;
};
std::array<plane_cache, 6> plane_processed;
std::atomic_uint last_distance_max = 0;
std::atomic_uint last_distance_max = 0;
int go_direction(const size_t dir_n);
std::array<async_step_runner, 6> async;
int timestamp_complete = 0;
Expand Down
7 changes: 5 additions & 2 deletions src/clientiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ void RemoteClient::SentBlock(v3s16 p)

void RemoteClient::SetBlockNotSent(v3s16 p)
{
++m_nearest_unsent_reset;
/*
++m_nearest_unsent_reset;
m_nothing_to_send_pause_timer = 0;
// remove the block from sending and sent sets,
Expand All @@ -522,13 +522,16 @@ void RemoteClient::SetBlockNotSent(v3s16 p)

void RemoteClient::SetBlocksNotSent()
{
/*
++m_nearest_unsent_reset;
*/
}

void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
{
++m_nearest_unsent_reset;
/*
++m_nearest_unsent_reset;
m_nothing_to_send_pause_timer = 0;
for (auto &block : blocks) {
Expand Down
4 changes: 2 additions & 2 deletions src/clientiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class RemoteClient

//fm:
u16 net_proto_version_fm = 0;
std::atomic_int m_nearest_unsent_reset {0};
//std::atomic_int m_nearest_unsent_reset {0};
std::atomic_uint wanted_range {10 };
std::atomic_int range_all {0};
std::atomic_int farmesh = {0};
Expand Down Expand Up @@ -408,7 +408,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<v3pos_t, double, v3posHash, v3posEqual> m_blocks_sent;
concurrent_shared_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/content_abm_grow_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ class GrowLeaves : public ActiveBlockModifier
(activate || !myrand_range(0, 10)))) {
//if (grow_debug) DUMP("lv die", p.X, p.Y, p.Z, have_tree_or_soil, n_water_level, l, heat);
//if (!grow_debug_no_die)
map->removeNodeWithEvent(pos, false);
map->removeNodeWithEvent(pos, true, false);
} else if (n_water_level != n_water_level_orig) {
// save if self level changed
set_leaves_water_level(n, n_water_level);
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ size_t ServerEnvironment::nodeUpdate(const v3pos_t pos, u16 recursion_limit, int
n_bottom.getLevel(ndef) < n_bottom.getMaxLevel(ndef))) &&
(!f_under.walkable || f_under.buildable_to)) {
if (spawnFallingActiveObject(f.name, intToFloat(v3pos_t(x,y,z),BS), n, fast)) {
removeNode(n_pos, fast);
removeNode(n_pos, fast, false);
ret += 1 + nodeUpdate(n_pos, recursion_limit, fast, destroy);
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/fm_clientiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge,
if (m_nearest_unsent_reset_timer > 120.0) {
m_nearest_unsent_reset_timer = 0;
m_nearest_unsent_d = 0;
m_nearest_unsent_reset = 0;
//m_nearest_unsent_reset = 0;
m_nothing_to_send_pause_timer = -1;
// infostream<<"Resetting m_nearest_unsent_d for "<<peer_id<<std::endl;
}
Expand Down Expand Up @@ -366,11 +366,11 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge,
FOV setting. The default of 72 degrees is fine.
*/
/*
if (can_skip && isBlockInSight(p, camera_pos, camera_dir, camera_fov,
d_blocks_in_sight) == false) {
// DUMP(p, can_skip, "nosight");
continue;
}
if (can_skip && isBlockInSight(p, camera_pos, camera_dir, camera_fov,
d_blocks_in_sight) == false) {
// DUMP(p, can_skip, "nosight");
continue;
}
*/
/*
Don't send already sent blocks
Expand Down Expand Up @@ -597,10 +597,10 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge,
m_nothing_to_send_pause_timer = 1;
}
} else {
if (!num_blocks_selected && !num_blocks_air && d_start <= d) {
// new_nearest_unsent_d = 0;
m_nothing_to_send_pause_timer = 1.0;
}
if (!num_blocks_selected && !num_blocks_air && d_start <= d) {
// new_nearest_unsent_d = 0;
m_nothing_to_send_pause_timer = 1.0;
}

// If nothing was found for sending and nothing was queued for
// emerging, continue next time browsing from here
Expand All @@ -620,8 +620,8 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge,
}
}

if (new_nearest_unsent_d != -1) {
m_nearest_unsent_d = new_nearest_unsent_d;
if (new_nearest_unsent_d != -1) {
m_nearest_unsent_d = new_nearest_unsent_d;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
if (remove_metadata)
removeNodeMetadata(p);
setNode(p, n, important);
modified_blocks[getNodeBlockPos(p)] = nullptr;
return;
}

Expand Down Expand Up @@ -327,7 +328,7 @@ bool Map::addNodeWithEvent(v3pos_t p, MapNode n, bool remove_metadata, bool impo
return succeeded;
}

bool Map::removeNodeWithEvent(v3pos_t p, bool important)
bool Map::removeNodeWithEvent(v3pos_t p, int fast, bool important)
{
MapEditEvent event;
event.type = MEET_REMOVENODE;
Expand All @@ -336,7 +337,7 @@ bool Map::removeNodeWithEvent(v3pos_t p, bool important)
bool succeeded = true;
try{
std::map<v3s16, MapBlock*> modified_blocks;
removeNodeAndUpdate(p, modified_blocks, 0, important);
removeNodeAndUpdate(p, modified_blocks, fast, important);

event.setModifiedBlocks(modified_blocks);
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class Map : public NodeContainer
Return true if succeeded, false if not.
*/
bool addNodeWithEvent(v3pos_t p, MapNode n, bool remove_metadata = true, bool important = false);
bool removeNodeWithEvent(v3pos_t p, bool important);
bool removeNodeWithEvent(v3pos_t p, int fast, bool important);

// Call these before and after saving of many blocks
virtual void beginSave() {}
Expand Down
3 changes: 1 addition & 2 deletions src/mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,16 @@ void MapBlock::deSerializeNetworkSpecific(std::istream &is)
void MapBlock::raiseModified(u32 mod, modified_light light, bool important)
{
static const thread_local auto save_changed_block = g_settings->getBool("save_changed_block");
if (save_changed_block || important || m_disk_timestamp != BLOCK_TIMESTAMP_UNDEFINED ) {

if(mod >= MOD_STATE_WRITE_NEEDED /*&& m_timestamp != BLOCK_TIMESTAMP_UNDEFINED*/) {
m_changed_timestamp = (unsigned int)m_parent->time_life;
}
if(mod > m_modified){
if (save_changed_block || important) // || m_disk_timestamp != BLOCK_TIMESTAMP_UNDEFINED )
m_modified = mod;
if(m_modified >= MOD_STATE_WRITE_AT_UNLOAD)
m_disk_timestamp.store(m_timestamp);
}
}
if (light == modified_light_yes) {
setLightingComplete(0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,11 +1217,11 @@ bool ServerEnvironment::removeNode(v3pos_t p, s16 fast, bool important)
try {
if (fast == 2)
n.param1 = n_old.param1;
m_map->setNode(p, n);
m_map->setNode(p, n, important);
} catch(const InvalidPositionException &e) { }
} else

if (!m_map->removeNodeWithEvent(p, important))
if (!m_map->removeNodeWithEvent(p, fast, important))
return false;

m_circuit.removeNode(p, n_old);
Expand Down

0 comments on commit e6a25ba

Please sign in to comment.