From 7b6d6423004343c73fd37726fbbb9f981a50f271 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 27 Nov 2012 00:47:03 +0200 Subject: [PATCH] Full protocol 13 compatibility on server side --- src/content_sao.cpp | 96 ++++++++++++++++++++++++++++++--------------- src/content_sao.h | 4 +- src/server.cpp | 8 ++-- src/serverobject.h | 2 +- 4 files changed, 72 insertions(+), 38 deletions(-) diff --git a/src/content_sao.cpp b/src/content_sao.cpp index efc14570..8916b492 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -245,7 +245,7 @@ public: } } - std::string getClientInitializationData() + std::string getClientInitializationData(u16 protocol_version) { std::ostringstream os(std::ios::binary); // version @@ -564,25 +564,41 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) } } -std::string LuaEntitySAO::getClientInitializationData() +std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version) { std::ostringstream os(std::ios::binary); - writeU8(os, 1); // version - os< >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ - os<= 14) + { + writeU8(os, 1); // version + os< >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ + os<getBool("unlimited_player_transfer_distance"); } -std::string PlayerSAO::getClientInitializationData() +std::string PlayerSAO::getClientInitializationData(u16 protocol_version) { std::ostringstream os(std::ios::binary); - writeU8(os, 1); // version - os<getName()); // name - writeU8(os, 1); // is_player - writeS16(os, getId()); //id - writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0)); - writeF1000(os, m_player->getYaw()); - writeS16(os, getHP()); - - writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here - os< >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ - os<= 15) + { + writeU8(os, 1); // version + os<getName()); // name + writeU8(os, 1); // is_player + writeS16(os, getId()); //id + writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0)); + writeF1000(os, m_player->getYaw()); + writeS16(os, getHP()); + + writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here + os< >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ + os<getName()); // name + writeU8(os, 1); // is_player + writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0)); + writeF1000(os, m_player->getYaw()); + writeS16(os, getHP()); + writeU8(os, 2); // number of messages stuffed in here + os<getClientInitializationData())); + obj->getClientInitializationData(client->net_proto_version))); else data_buffer.append(serializeLongString("")); @@ -2407,7 +2407,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(command == TOSERVER_PLAYERPOS) { - if(datasize < 2+12+12+4+4+4) + if(datasize < 2+12+12+4+4) return; u32 start = 0; @@ -2415,7 +2415,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) v3s32 ss = readV3S32(&data[start+2+12]); f32 pitch = (f32)readS32(&data[2+12+12]) / 100.0; f32 yaw = (f32)readS32(&data[2+12+12+4]) / 100.0; - u32 keyPressed = (u32)readU32(&data[2+12+12+4+4]); + u32 keyPressed = 0; + if(datasize >= 2+12+12+4+4+4) + keyPressed = (u32)readU32(&data[2+12+12+4+4]); v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.); v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.); pitch = wrapDegrees(pitch); diff --git a/src/serverobject.h b/src/serverobject.h index 1bbd3e4e..14752878 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -118,7 +118,7 @@ public: The return value of this is passed to the client-side object when it is created */ - virtual std::string getClientInitializationData(){return "";} + virtual std::string getClientInitializationData(u16 protocol_version){return "";} /* The return value of this is passed to the server-side object -- 2.30.2