1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Send only changed node metadata to clients instead of whole mapblock (#5268)

Includes newer style changes and fixes by est31

Improve the block position de-serialization
Add type NodeMetadataMap
This commit is contained in:
SmallJoker 2018-12-04 20:37:48 +01:00 committed by GitHub
parent ae8d14b009
commit 3d66622772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 202 additions and 70 deletions

View file

@ -243,6 +243,33 @@ void Client::handleCommand_AddNode(NetworkPacket* pkt)
addNode(p, n, remove_metadata);
}
void Client::handleCommand_NodemetaChanged(NetworkPacket *pkt)
{
if (pkt->getSize() < 1)
return;
std::istringstream is(pkt->readLongString(), std::ios::binary);
std::stringstream sstr;
decompressZlib(is, sstr);
NodeMetadataList meta_updates_list(false);
meta_updates_list.deSerialize(sstr, m_itemdef, true);
Map &map = m_env.getMap();
for (NodeMetadataMap::const_iterator i = meta_updates_list.begin();
i != meta_updates_list.end(); ++i) {
v3s16 pos = i->first;
if (map.isValidPosition(pos) &&
map.setNodeMetadata(pos, i->second))
continue; // Prevent from deleting metadata
// Meta couldn't be set, unused metadata
delete i->second;
}
}
void Client::handleCommand_BlockData(NetworkPacket* pkt)
{
// Ignore too small packet