aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-03-07 06:41:21 +0000
committerrubenwardy <rw@rubenwardy.com>2019-03-11 22:07:19 +0000
commitda4739a26cb8327d1e6c5d8642692e5fbb0ad4a0 (patch)
treea0f40c9994043bd23330b9dc47bac90213152b08 /src
parentfc24bf09153f17bec023cde164a039202102a66c (diff)
downloadminetest-da4739a26cb8327d1e6c5d8642692e5fbb0ad4a0.tar.gz
minetest-da4739a26cb8327d1e6c5d8642692e5fbb0ad4a0.tar.bz2
minetest-da4739a26cb8327d1e6c5d8642692e5fbb0ad4a0.zip
Fix detach inventory serialisation (#8331)
Diffstat (limited to 'src')
-rw-r--r--src/network/clientpackethandler.cpp6
-rw-r--r--src/server.cpp5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 3e50173a6..889002a82 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -895,8 +895,10 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt)
inv = inv_it->second;
}
- std::string contents;
- *pkt >> contents;
+ u16 ignore;
+ *pkt >> ignore; // this used to be the length of the following string, ignore it
+
+ std::string contents = pkt->getRemainingString();
std::istringstream is(contents, std::ios::binary);
inv->deSerialize(is);
}
diff --git a/src/server.cpp b/src/server.cpp
index ad469d655..701339ad8 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2576,7 +2576,10 @@ void Server::sendDetachedInventory(const std::string &name, session_t peer_id)
// Serialization & NetworkPacket isn't a love story
std::ostringstream os(std::ios_base::binary);
inv_it->second->serialize(os);
- pkt << os.str();
+
+ std::string os_str = os.str();
+ pkt << static_cast<u16>(os_str.size()); // HACK: to keep compatibility with 5.0.0 clients
+ pkt.putRawString(os_str);
}
if (peer_id == PEER_ID_INEXISTENT)