From 23913f26cd0a075505b7e74df6b93584288afb92 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 26 Nov 2012 23:59:03 +0200 Subject: Support serialization of protocol 13 ContentFeatures --- src/nodedef.cpp | 296 +++++++++++++++++++++++++++++++++++--------------------- src/nodedef.h | 8 +- src/server.cpp | 11 ++- 3 files changed, 195 insertions(+), 120 deletions(-) (limited to 'src') diff --git a/src/nodedef.cpp b/src/nodedef.cpp index c51b3e6ff..c48e2ff97 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -215,8 +215,13 @@ void ContentFeatures::reset() sound_dug = SimpleSoundSpec(); } -void ContentFeatures::serialize(std::ostream &os) +void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) { + if(protocol_version < 14){ + serializeOld(os, protocol_version); + return; + } + writeU8(os, 6); // version os<serialize(wrapper_os); + f->serialize(wrapper_os, protocol_version); os2<first); + writeS16(os, i->second); + } + writeU8(os, drawtype); + writeF1000(os, visual_scale); + writeU8(os, 6); + for(u32 i=0; i<6; i++) + tiledef[i].serialize(os); + writeU8(os, CF_SPECIAL_COUNT); + for(u32 i=0; iserialization_version - = getClient(peer_id)->pending_serialization_version; + RemoteClient *client = getClient(peer_id); + client->serialization_version = + getClient(peer_id)->pending_serialization_version; /* Send some initialization data @@ -2269,7 +2270,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) SendItemDef(m_con, peer_id, m_itemdef); // Send node definitions - SendNodeDef(m_con, peer_id, m_nodedef); + SendNodeDef(m_con, peer_id, m_nodedef, client->net_proto_version); // Send media announcement sendMediaAnnouncement(peer_id); @@ -3521,7 +3522,7 @@ void Server::SendItemDef(con::Connection &con, u16 peer_id, } void Server::SendNodeDef(con::Connection &con, u16 peer_id, - INodeDefManager *nodedef) + INodeDefManager *nodedef, u16 protocol_version) { DSTACK(__FUNCTION_NAME); std::ostringstream os(std::ios_base::binary); @@ -3533,7 +3534,7 @@ void Server::SendNodeDef(con::Connection &con, u16 peer_id, */ writeU16(os, TOCLIENT_NODEDEF); std::ostringstream tmp_os(std::ios::binary); - nodedef->serialize(tmp_os); + nodedef->serialize(tmp_os, protocol_version); std::ostringstream tmp_os2(std::ios::binary); compressZlib(tmp_os.str(), tmp_os2); os<