Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Sep 29, 2024
1 parent 8574297 commit 8363353
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/client/fm_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()};
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
3 changes: 1 addition & 2 deletions src/fm_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()};
Expand Down
5 changes: 5 additions & 0 deletions src/mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MapBlockMesh>;
using block_step_t = uint8_t;

Expand Down

0 comments on commit 8363353

Please sign in to comment.