From 8363353a31b0eb8db0912de470c27d775053b8ce Mon Sep 17 00:00:00 2001 From: proller Date: Sun, 29 Sep 2024 20:21:02 +0200 Subject: [PATCH] fix --- src/client/fm_client.cpp | 17 ++++++++++++++++- src/defaultsettings.cpp | 1 - src/fm_server.cpp | 3 +-- src/mapblock.h | 5 +++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/client/fm_client.cpp b/src/client/fm_client.cpp index 8a98aa6e7..20de86b1b 100644 --- a/src/client/fm_client.cpp +++ b/src/client/fm_client.cpp @@ -139,7 +139,6 @@ void Client::handleCommand_FreeminerInit(NetworkPacket *pkt) // packet[TOCLIENT_INIT_PROTOCOL_VERSION_FM].convert( not used ); } - void Client::handleCommand_BlockDatas(NetworkPacket *pkt) { const auto str = std::string{pkt->getString(0), pkt->getSize()}; @@ -171,7 +170,23 @@ void Client::handleCommand_BlockDatas(NetworkPacket *pkt) packet.convert_safe( TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->content_only_param2); + if (block->content_only == CONTENT_IGNORE) { + try { block->deSerialize(istr, m_server_ser_ver, false); + } catch (const std::exception &ex) { + errorstream << "fm block deSerialize fail " << bpos << " " << block->far_step + << " : " << ex.what() << " : " << pkt->getSize() << " " + << packet.size() << " v=" << (short)m_server_ser_ver << "\n"; +#if !NDEBUG + errorstream << "bad data " << istr.str().size() << " : " << istr.str() + << "\n"; +#endif + return; + } + } else { + block->fill({block->content_only, block->content_only_param1, + block->content_only_param2}); + } s32 h = 0; // for convert to atomic packet[TOCLIENT_BLOCKDATA_HEAT].convert(h); block->heat = h; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index c3f9732fd..26855133c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -386,7 +386,6 @@ void fm_set_default_settings(Settings *settings) { #ifdef HAVE_TOUCHSCREENGUI settings->setDefault("touchscreen", android ? "true" : "false"); settings->setDefault("touchtarget", "true"); - settings->setDefault("touchscreen_threshold","20"); #endif #ifdef __EMSCRIPTEN__ diff --git a/src/fm_server.cpp b/src/fm_server.cpp index 318eaf573..f68f7eec4 100644 --- a/src/fm_server.cpp +++ b/src/fm_server.cpp @@ -590,8 +590,6 @@ void Server::SendBlockFm(session_t peer_id, MapBlockP block, u8 ver, thread_local const int net_compression_level = rangelim(g_settings->getS16("map_compression_level_net"), -1, 9); - bool reliable = 1; - g_profiler->add("Connection: blocks sent", 1); MSGPACK_PACKET_INIT((int)TOCLIENT_BLOCKDATAS, 8); @@ -610,6 +608,7 @@ void Server::SendBlockFm(session_t peer_id, MapBlockP block, u8 ver, PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1, block->content_only_param1); PACK(TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2, block->content_only_param2); + NetworkPacket pkt(TOCLIENT_BLOCKDATAS, buffer.size(), peer_id); pkt.putLongString({buffer.data(), buffer.size()}); auto s = std::string{pkt.getString(0), pkt.getSize()}; diff --git a/src/mapblock.h b/src/mapblock.h index 8732be7fe..9538f45c1 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -518,6 +518,11 @@ class MapBlock void pushElementsToCircuit(Circuit* circuit); + void fill(const MapNode & n) { + for (u32 i = 0; i < nodecount; ++i) + data[i] = n; + } + using mesh_type = std::shared_ptr; using block_step_t = uint8_t;