mirror of
https://github.com/bdnugget/freeminer.git
synced 2026-11-07 06:57:27 +00:00
Merge remote-tracking branch 'origin/wip5.14.0' into wip5.14.0
This commit is contained in:
commit
41dc60f964
7 files changed
+63
-38
No files matched your search
+17
-12
@@ -216,15 +216,20 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
|
||||
{
|
||||
const auto lock = block->lock_unique_rec();
|
||||
block->far_step = step;
|
||||
content_t content_only{};
|
||||
packet.convert_safe(TOCLIENT_BLOCKDATA_CONTENT_ONLY, content_only);
|
||||
block->content_only = content_only;
|
||||
packet.convert_safe(
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1, block->content_only_param1);
|
||||
packet.convert_safe(
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->content_only_param2);
|
||||
|
||||
if (block->content_only == CONTENT_IGNORE) {
|
||||
content_t content_only{CONTENT_IGNORE};
|
||||
packet.convert_safe(TOCLIENT_BLOCKDATA_CONTENT_ONLY, content_only);
|
||||
/*
|
||||
if (content_only != CONTENT_IGNORE) {
|
||||
block->data[0].param0 = content_only;
|
||||
packet.convert_safe(
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1, block->data[0].param1);
|
||||
packet.convert_safe(
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->data[0].param2);
|
||||
}
|
||||
*/
|
||||
if (content_only == CONTENT_IGNORE) {
|
||||
//block->m_is_mono_block = false;
|
||||
try {
|
||||
block->deSerialize(istr, m_server_ser_ver, false);
|
||||
} catch (const std::exception &ex) {
|
||||
@@ -239,8 +244,9 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
block->fill({block->content_only, block->content_only_param1,
|
||||
block->content_only_param2});
|
||||
//block->m_is_mono_block = true;
|
||||
//block->fill(block->data[0]);
|
||||
block->fill(content_only);
|
||||
}
|
||||
weather::heat_t heat = 0; // for convert to atomic
|
||||
packet[TOCLIENT_BLOCKDATA_HEAT].convert(heat);
|
||||
@@ -262,8 +268,7 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
|
||||
|
||||
if (!step) {
|
||||
updateMeshTimestampWithEdge(bpos);
|
||||
if (!overload && block->content_only != CONTENT_IGNORE &&
|
||||
block->content_only != CONTENT_AIR) {
|
||||
if (!overload && block->m_is_mono_block && block->data[0].param0 != CONTENT_AIR) {
|
||||
if (getNodeBlockPos(floatToInt(m_env.getLocalPlayer()->getPosition(), BS))
|
||||
.getDistanceFrom(bpos) <= 1)
|
||||
addUpdateMeshTaskWithEdge(bpos);
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ void ABMHandler::apply(MapBlock *block, int &blocks_scanned, int &abms_run,
|
||||
}
|
||||
|
||||
if (!m_aabms[c]) {
|
||||
if (block->content_only != CONTENT_IGNORE)
|
||||
if (block->m_is_mono_block)
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
+10
-6
@@ -391,13 +391,14 @@ int RemoteClient::GetNextBlocksFm(ServerEnvironment *env, EmergeManager *emerge,
|
||||
// bool surely_not_found_on_disk = false;
|
||||
// bool block_is_invalid = false;
|
||||
if (block) {
|
||||
if (d >= 2 && block->content_only == CONTENT_AIR) {
|
||||
if (d >= 2 && block->m_is_mono_block &&
|
||||
block->data[0].param0 == CONTENT_AIR) {
|
||||
uint8_t not_air = 0;
|
||||
for (const auto &dir : g_6dirs) {
|
||||
if (const auto *block_near =
|
||||
env->getMap().getBlockNoCreateNoEx(p + dir)) {
|
||||
if (block_near->content_only &&
|
||||
block_near->content_only != CONTENT_AIR) {
|
||||
if (block_near->m_is_mono_block &&
|
||||
block_near->data[0].param0 != CONTENT_AIR) {
|
||||
++not_air;
|
||||
break;
|
||||
}
|
||||
@@ -507,7 +508,7 @@ int RemoteClient::GetNextBlocksFm(ServerEnvironment *env, EmergeManager *emerge,
|
||||
|
||||
dest.push_back(q);
|
||||
|
||||
if (block->content_only == CONTENT_AIR)
|
||||
if (block->m_is_mono_block && block->data[0].param0 == CONTENT_AIR)
|
||||
++num_blocks_air;
|
||||
else
|
||||
num_blocks_selected += 1;
|
||||
@@ -567,7 +568,8 @@ queue_full_break:
|
||||
|
||||
uint32_t RemoteClient::SendFarBlocks(const int32_t uptime)
|
||||
{
|
||||
const static thread_local auto client_unload_unused_data_timeout = g_settings->getFloat("client_unload_unused_data_timeout");
|
||||
const static thread_local auto client_unload_unused_data_timeout =
|
||||
g_settings->getFloat("client_unload_unused_data_timeout");
|
||||
uint16_t sent_cnt{};
|
||||
TRY_UNIQUE_LOCK(far_blocks_requested_mutex)
|
||||
{
|
||||
@@ -576,7 +578,9 @@ uint32_t RemoteClient::SendFarBlocks(const int32_t uptime)
|
||||
for (auto &far_blocks : far_blocks_requested) {
|
||||
for (auto &[bpos, step_sent] : far_blocks) {
|
||||
auto &[step, sent_ts] = step_sent;
|
||||
if (sent_ts < 0 || (sent_ts && sent_ts + client_unload_unused_data_timeout > uptime)) {
|
||||
if (sent_ts < 0 ||
|
||||
(sent_ts &&
|
||||
sent_ts + client_unload_unused_data_timeout > uptime)) {
|
||||
continue;
|
||||
}
|
||||
if (step >= FARMESH_STEP_MAX - 1) {
|
||||
|
||||
+5
-5
@@ -700,13 +700,13 @@ void Server::SendBlockFm(session_t peer_id, MapBlockPtr block, u8 ver,
|
||||
|
||||
PACK(TOCLIENT_BLOCKDATA_DATA, os.str());
|
||||
PACK(TOCLIENT_BLOCKDATA_HEAT, (weather::heat_t)(block->heat + block->heat_add));
|
||||
PACK(TOCLIENT_BLOCKDATA_HUMIDITY, (weather::humidity_t)(block->humidity + block->humidity_add));
|
||||
PACK(TOCLIENT_BLOCKDATA_HUMIDITY,
|
||||
(weather::humidity_t)(block->humidity + block->humidity_add));
|
||||
PACK(TOCLIENT_BLOCKDATA_STEP, block->far_step);
|
||||
PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY,
|
||||
block->content_only.load(std::memory_order_relaxed));
|
||||
|
||||
PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1, block->content_only_param1);
|
||||
PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->content_only_param2);
|
||||
block->m_is_mono_block ? block->data[0].param0 : CONTENT_IGNORE);
|
||||
PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1, block->data[0].param1);
|
||||
PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->data[0].param2);
|
||||
|
||||
NetworkPacket pkt(TOCLIENT_BLOCKDATA_FM, buffer.size(), peer_id);
|
||||
pkt.putLongString({buffer.data(), buffer.size()});
|
||||
|
||||
+22
-11
@@ -163,6 +163,9 @@ void MapBlock::pushElementsToCircuit(Circuit *circuit)
|
||||
|
||||
bool MapBlock::analyzeContent()
|
||||
{
|
||||
/*
|
||||
// TODO: really need here?
|
||||
|
||||
const auto lock = try_lock_shared_rec();
|
||||
if (!lock->owns_lock())
|
||||
return false;
|
||||
@@ -179,7 +182,9 @@ bool MapBlock::analyzeContent()
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
const MapBlock::mesh_type empty_mesh;
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
@@ -642,8 +647,8 @@ void MapBlock::serialize(std::ostream &os_compressed, u8 version, bool disk, int
|
||||
}
|
||||
|
||||
// fmtodo: check version and dont pack data if more than 20150427 or 0.4.12.7+
|
||||
if (!disk && use_content_only && content_only != CONTENT_IGNORE)
|
||||
return;
|
||||
// if (!disk && use_content_only && m_is_mono_block)
|
||||
// return;
|
||||
|
||||
/*
|
||||
Bulk node data
|
||||
@@ -794,22 +799,28 @@ bool MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
|
||||
}
|
||||
|
||||
if (!m_generated) {
|
||||
static thread_local const auto fix_not_generated = g_settings->getBool("fix_not_generated");
|
||||
if (!fix_not_generated)
|
||||
static thread_local const auto fix_not_generated =
|
||||
g_settings->getBool("fix_not_generated");
|
||||
if (!fix_not_generated) {
|
||||
errorstream << "MapBlock::deSerialize(): deserialize not generated block "
|
||||
<< getPos() << std::endl;
|
||||
}
|
||||
|
||||
errorstream<<"MapBlock::deSerialize(): deserialize not generated block "<<getPos()<<std::endl;
|
||||
|
||||
if (disk && fix_not_generated) m_generated = true; else
|
||||
|
||||
return false;
|
||||
if (disk && fix_not_generated) {
|
||||
m_generated = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!disk && content_only != CONTENT_IGNORE) {
|
||||
/*
|
||||
if (!disk && m_is_mono_block) {
|
||||
auto n = MapNode(content_only, content_only_param1, content_only_param2);
|
||||
for (u32 i = 0; i < MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++)
|
||||
data[i] = n;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
|
||||
<<": Bulk node data"<<std::endl);
|
||||
|
||||
+5
-2
@@ -537,8 +537,8 @@ public:
|
||||
}
|
||||
|
||||
// Set to content type of a node if the block consists solely of nodes of one type, otherwise set to CONTENT_IGNORE
|
||||
std::atomic<content_t> content_only{CONTENT_IGNORE};
|
||||
u8 content_only_param1{}, content_only_param2{};
|
||||
//std::atomic<content_t> content_only{CONTENT_IGNORE};
|
||||
//u8 content_only_param1{}, content_only_param2{};
|
||||
bool analyzeContent();
|
||||
std::mutex m_usage_timer_mutex;
|
||||
|
||||
@@ -635,7 +635,9 @@ private:
|
||||
* fragmentation (the array is exactly 16K, or exactly 4 bytes for a "monoblock"),
|
||||
* CPU caches and/or optimizability of algorithms working on this array.
|
||||
*/
|
||||
public:
|
||||
MapNode *data = nullptr;
|
||||
private:
|
||||
|
||||
// provides the item and node definitions
|
||||
IGameDef *m_gamedef;
|
||||
@@ -650,6 +652,7 @@ private:
|
||||
* For "monoblocks", the whole block is filled with the same node, only this node is stored.
|
||||
* (For reduced memory usage)
|
||||
*/
|
||||
public:
|
||||
bool m_is_mono_block;
|
||||
public:
|
||||
//// ABM optimizations ////
|
||||
|
||||
@@ -37,7 +37,9 @@ IConnection *createMTP(float timeout, bool ipv6, PeerHandler *handler, bool simp
|
||||
#elif USE_ENET
|
||||
return new con::ConnectionEnet(MAX_PACKET_SIZE, timeout, ipv6, handler);
|
||||
#elif USE_SCTP
|
||||
return new con::ConnectionSctp(MAX_PACKET_SIZE, timeout, ipv6, handler);
|
||||
return new con::ConnectionSctp(
|
||||
MAX_PACKET_SIZE, timeout, ipv6,
|
||||
handler);
|
||||
#elif MINETEST_TRANSPORT
|
||||
return new con::Connection(
|
||||
MAX_PACKET_SIZE, timeout, ipv6,
|
||||
|
||||
Reference in new issue
Block a user