]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Send to clients node metadata that changed to become empty (#11597)
authorJude Melton-Houghton <jwmhjwmh@gmail.com>
Fri, 10 Sep 2021 21:16:34 +0000 (17:16 -0400)
committerGitHub <noreply@github.com>
Fri, 10 Sep 2021 21:16:34 +0000 (23:16 +0200)
src/nodemetadata.cpp
src/nodemetadata.h
src/server.cpp

index f98732385858fed4ea06ee7800b40f7b4caaa54a..b5052c3b8754122460330bd87f17b10661155973 100644 (file)
@@ -113,13 +113,13 @@ int NodeMetadata::countNonPrivate() const
 */
 
 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."
        */
 
-       u16 count = countNonEmpty();
+       u16 count = include_empty ? m_data.size() : countNonEmpty();
        if (count == 0) {
                writeU8(os, 0); // version
                return;
@@ -134,7 +134,7 @@ void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk,
                        i != m_data.end(); ++i) {
                v3s16 p = i->first;
                NodeMetadata *data = i->second;
-               if (data->empty())
+               if (!include_empty && data->empty())
                        continue;
 
                if (absolute_pos) {
index c028caf88666447e9d30fd80e8ea356e4641a26f..4b5b4d887ddfef20927ff2893abcc2d497e5cf7d 100644 (file)
@@ -82,7 +82,7 @@ class NodeMetadataList
        ~NodeMetadataList();
 
        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,
                bool absolute_pos = false);
 
index 1b5cbe395e1b6e9165f133dc417d288f18971d93..46b497d6ef0a8ca11d73b11b214a93b7e90ad332 100644 (file)
@@ -2320,7 +2320,7 @@ void Server::sendMetadataChanged(const std::list<v3s16> &meta_updates, float far
 
                // Send the meta changes
                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);
                compressZlib(os.str(), oss);