aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/server.cpp b/src/server.cpp
index c29ec3d83..f0de54f66 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1582,16 +1582,16 @@ void Server::AsyncRunStep()
// for them.
std::list<u16> far_players;
- if(event->type == MEET_ADDNODE)
+ if(event->type == MEET_ADDNODE || event->type == MEET_SWAPNODE)
{
//infostream<<"Server: MEET_ADDNODE"<<std::endl;
prof.add("MEET_ADDNODE", 1);
if(disable_single_change_sending)
sendAddNode(event->p, event->n, event->already_known_by_peer,
- &far_players, 5);
+ &far_players, 5, event->type == MEET_ADDNODE);
else
sendAddNode(event->p, event->n, event->already_known_by_peer,
- &far_players, 30);
+ &far_players, 30, event->type == MEET_ADDNODE);
}
else if(event->type == MEET_REMOVENODE)
{
@@ -4070,7 +4070,8 @@ void Server::sendRemoveNode(v3s16 p, u16 ignore_id,
}
void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
- std::list<u16> *far_players, float far_d_nodes)
+ std::list<u16> *far_players, float far_d_nodes,
+ bool remove_metadata)
{
float maxd = far_d_nodes*BS;
v3f p_f = intToFloat(p, BS);
@@ -4106,13 +4107,23 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
}
// Create packet
- u32 replysize = 8 + MapNode::serializedLength(client->serialization_version);
+ u32 replysize = 9 + MapNode::serializedLength(client->serialization_version);
SharedBuffer<u8> reply(replysize);
writeU16(&reply[0], TOCLIENT_ADDNODE);
writeS16(&reply[2], p.X);
writeS16(&reply[4], p.Y);
writeS16(&reply[6], p.Z);
n.serialize(&reply[8], client->serialization_version);
+ u32 index = 8 + MapNode::serializedLength(client->serialization_version);
+ writeU8(&reply[index], remove_metadata ? 0 : 1);
+
+ if (!remove_metadata) {
+ if (client->net_proto_version <= 21) {
+ // Old clients always clear metadata; fix it
+ // by sending the full block again.
+ client->SetBlockNotSent(p);
+ }
+ }
// Send as reliable
m_con.Send(client->peer_id, 0, reply, true);