Skip to content

Commit 7423c4c

Browse files
authoredSep 10, 2021
Send to clients node metadata that changed to become empty (#11597)
1 parent 2cefe51 commit 7423c4c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed
 

‎src/nodemetadata.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ int NodeMetadata::countNonPrivate() const
113113
*/
114114

115115
void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk,
116-
bool absolute_pos) const
116+
bool absolute_pos, bool include_empty) const
117117
{
118118
/*
119119
Version 0 is a placeholder for "nothing to see here; go away."
120120
*/
121121

122-
u16 count = countNonEmpty();
122+
u16 count = include_empty ? m_data.size() : countNonEmpty();
123123
if (count == 0) {
124124
writeU8(os, 0); // version
125125
return;
@@ -134,7 +134,7 @@ void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk,
134134
i != m_data.end(); ++i) {
135135
v3s16 p = i->first;
136136
NodeMetadata *data = i->second;
137-
if (data->empty())
137+
if (!include_empty && data->empty())
138138
continue;
139139

140140
if (absolute_pos) {

‎src/nodemetadata.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class NodeMetadataList
8282
~NodeMetadataList();
8383

8484
void serialize(std::ostream &os, u8 blockver, bool disk = true,
85-
bool absolute_pos = false) const;
85+
bool absolute_pos = false, bool include_empty = false) const;
8686
void deSerialize(std::istream &is, IItemDefManager *item_def_mgr,
8787
bool absolute_pos = false);
8888

‎src/server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ void Server::sendMetadataChanged(const std::list<v3s16> &meta_updates, float far
23202320

23212321
// Send the meta changes
23222322
std::ostringstream os(std::ios::binary);
2323-
meta_updates_list.serialize(os, client->net_proto_version, false, true);
2323+
meta_updates_list.serialize(os, client->serialization_version, false, true, true);
23242324
std::ostringstream oss(std::ios::binary);
23252325
compressZlib(os.str(), oss);
23262326

0 commit comments

Comments
 (0)
Please sign in to comment.