Send to clients node metadata that changed to become empty (#11597)

This commit is contained in:
Jude Melton-Houghton 2021-09-10 17:16:34 -04:00 committed by GitHub
parent 2cefe51d3b
commit 7423c4c11e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

@ -113,13 +113,13 @@ int NodeMetadata::countNonPrivate() const
*/ */
void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk, void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk,
bool absolute_pos) const bool absolute_pos, bool include_empty) const
{ {
/* /*
Version 0 is a placeholder for "nothing to see here; go away." Version 0 is a placeholder for "nothing to see here; go away."
*/ */
u16 count = countNonEmpty(); u16 count = include_empty ? m_data.size() : countNonEmpty();
if (count == 0) { if (count == 0) {
writeU8(os, 0); // version writeU8(os, 0); // version
return; return;
@ -134,7 +134,7 @@ void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk,
i != m_data.end(); ++i) { i != m_data.end(); ++i) {
v3s16 p = i->first; v3s16 p = i->first;
NodeMetadata *data = i->second; NodeMetadata *data = i->second;
if (data->empty()) if (!include_empty && data->empty())
continue; continue;
if (absolute_pos) { if (absolute_pos) {

@ -82,7 +82,7 @@ public:
~NodeMetadataList(); ~NodeMetadataList();
void serialize(std::ostream &os, u8 blockver, bool disk = true, void serialize(std::ostream &os, u8 blockver, bool disk = true,
bool absolute_pos = false) const; bool absolute_pos = false, bool include_empty = false) const;
void deSerialize(std::istream &is, IItemDefManager *item_def_mgr, void deSerialize(std::istream &is, IItemDefManager *item_def_mgr,
bool absolute_pos = false); bool absolute_pos = false);

@ -2320,7 +2320,7 @@ void Server::sendMetadataChanged(const std::list<v3s16> &meta_updates, float far
// Send the meta changes // Send the meta changes
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
meta_updates_list.serialize(os, client->net_proto_version, false, true); meta_updates_list.serialize(os, client->serialization_version, false, true, true);
std::ostringstream oss(std::ios::binary); std::ostringstream oss(std::ios::binary);
compressZlib(os.str(), oss); compressZlib(os.str(), oss);