Skip to content
Permalink
Browse files

Update server min protocol version to v24 (#5411)

* Update server min protocol version to v24

It's based on @sfan5 stats. See https://kitsunemimi.pw/tmp/serverlist_stats_2017-03-17.txt

v24 was bumped 25/08/14 and 0.4.11 was released 25/12/14

* Drop protocol v23 and lesser code
  • Loading branch information...
nerzhul committed Mar 19, 2017
1 parent b8484ef commit f8ad01ab7c4cf012781bd4caa821544e676c9267
Showing with 116 additions and 299 deletions.
  1. +69 −97 src/content_sao.cpp
  2. +13 −22 src/itemdef.cpp
  3. +0 −7 src/map.cpp
  4. +5 −9 src/mapblock.cpp
  5. +4 −4 src/mapblock.h
  6. +2 −2 src/network/networkprotocol.h
  7. +0 −21 src/network/serverpackethandler.cpp
  8. +10 −113 src/nodedef.cpp
  9. +1 −9 src/server.cpp
  10. +12 −15 src/tool.cpp
@@ -470,57 +470,43 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
{
std::ostringstream os(std::ios::binary);

if(protocol_version >= 14)
{
writeU8(os, 1); // version
os<<serializeString(""); // name
writeU8(os, 0); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeS16(os, m_hp);

std::ostringstream msg_os(std::ios::binary);
msg_os << serializeLongString(getPropertyPacket()); // message 1
msg_os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
msg_os << serializeLongString(gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
msg_os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id,
m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
int message_count = 4 + m_bone_position.size();
for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin();
(ii != m_attachment_child_ids.end()); ++ii) {
if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
message_count++;
msg_os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(),
obj->getClientInitializationData(protocol_version)));
}
}

msg_os << serializeLongString(gob_cmd_set_texture_mod(m_current_texture_modifier));
message_count++;
// protocol >= 14
writeU8(os, 1); // version
os << serializeString(""); // name
writeU8(os, 0); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeS16(os, m_hp);

writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size());
std::ostringstream msg_os(std::ios::binary);
msg_os << serializeLongString(getPropertyPacket()); // message 1
msg_os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
msg_os << serializeLongString(gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
else
{
writeU8(os, 0); // version
os<<serializeString(""); // name
writeU8(os, 0); // is_player
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeS16(os, m_hp);
writeU8(os, 2); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id,
m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
int message_count = 4 + m_bone_position.size();
for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin();
(ii != m_attachment_child_ids.end()); ++ii) {
if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
message_count++;
msg_os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(),
obj->getClientInitializationData(protocol_version)));
}
}

msg_os << serializeLongString(gob_cmd_set_texture_mod(m_current_texture_modifier));
message_count++;

writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size());

// return result
return os.str();
}
@@ -877,59 +863,45 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
{
std::ostringstream os(std::ios::binary);

if(protocol_version >= 15)
{
writeU8(os, 1); // version
os<<serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position + v3f(0,BS*1,0));
writeF1000(os, m_yaw);
writeS16(os, getHP());

std::ostringstream msg_os(std::ios::binary);
msg_os << serializeLongString(getPropertyPacket()); // message 1
msg_os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
msg_os << serializeLongString(gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
msg_os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id,
m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
msg_os << serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
m_physics_override_sneak_glitch)); // 5
// (GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) : Deprecated, for backwards compatibility only.
msg_os << serializeLongString(gob_cmd_update_nametag_attributes(m_prop.nametag_color)); // 6
int message_count = 6 + m_bone_position.size();
for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin();
ii != m_attachment_child_ids.end(); ++ii) {
if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
message_count++;
msg_os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(),
obj->getClientInitializationData(protocol_version)));
}
}

writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size());
// Protocol >= 15
writeU8(os, 1); // version
os << serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player
writeS16(os, getId()); //id
writeV3F1000(os, m_base_position + v3f(0,BS*1,0));
writeF1000(os, m_yaw);
writeS16(os, getHP());

std::ostringstream msg_os(std::ios::binary);
msg_os << serializeLongString(getPropertyPacket()); // message 1
msg_os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
msg_os << serializeLongString(gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
else
{
writeU8(os, 0); // version
os<<serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player
writeV3F1000(os, m_base_position + v3f(0,BS*1,0));
writeF1000(os, m_yaw);
writeS16(os, getHP());
writeU8(os, 2); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
msg_os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id,
m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
msg_os << serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
m_physics_override_sneak_glitch)); // 5
// (GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) : Deprecated, for backwards compatibility only.
msg_os << serializeLongString(gob_cmd_update_nametag_attributes(m_prop.nametag_color)); // 6
int message_count = 6 + m_bone_position.size();
for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin();
ii != m_attachment_child_ids.end(); ++ii) {
if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
message_count++;
msg_os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(),
obj->getClientInitializationData(protocol_version)));
}
}

writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size());

// return result
return os.str();
}
@@ -123,17 +123,13 @@ void ItemDefinition::reset()

void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
{
if(protocol_version <= 17)
writeU8(os, 1); // version
else if(protocol_version <= 20)
writeU8(os, 2); // version
else
writeU8(os, 3); // version

writeU8(os, 3); // version (proto > 20)
writeU8(os, type);
os<<serializeString(name);
os<<serializeString(description);
os<<serializeString(inventory_image);
os<<serializeString(wield_image);
os << serializeString(name);
os << serializeString(description);
os << serializeString(inventory_image);
os << serializeString(wield_image);
writeV3F1000(os, wield_scale);
writeS16(os, stack_max);
writeU8(os, usable);
@@ -144,24 +140,19 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
tool_capabilities->serialize(tmp_os, protocol_version);
tool_capabilities_s = tmp_os.str();
}
os<<serializeString(tool_capabilities_s);
os << serializeString(tool_capabilities_s);
writeU16(os, groups.size());
for (ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); ++i){
os << serializeString(i->first);
writeS16(os, i->second);
}
os<<serializeString(node_placement_prediction);
if(protocol_version > 17){
//serializeSimpleSoundSpec(sound_place, os);
os<<serializeString(sound_place.name);
writeF1000(os, sound_place.gain);
}
if (protocol_version > 20) {
writeF1000(os, range);
os << serializeString(sound_place_failed.name);
writeF1000(os, sound_place_failed.gain);
}
os << serializeString(node_placement_prediction);
os << serializeString(sound_place.name);
writeF1000(os, sound_place.gain);
writeF1000(os, range);
os << serializeString(sound_place_failed.name);
writeF1000(os, sound_place_failed.gain);
}

void ItemDefinition::deSerialize(std::istream &is)
@@ -2438,13 +2438,6 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
throw SerializationError("ServerMap::loadBlock(): Failed"
" to read MapBlock version");

/*u32 block_size = MapBlock::serializedLength(version);
SharedBuffer<u8> data(block_size);
is.read((char*)*data, block_size);*/

// This will always return a sector because we're the server
//MapSector *sector = emergeSector(p2d);

MapBlock *block = NULL;
bool created_new = false;
block = sector->getBlockNoCreateNoEx(p3d.Y);
@@ -640,19 +640,15 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
}
}

void MapBlock::serializeNetworkSpecific(std::ostream &os, u16 net_proto_version)
void MapBlock::serializeNetworkSpecific(std::ostream &os)
{
if(data == NULL)
{
if (!data) {
throw SerializationError("ERROR: Not writing dummy block.");
}

if(net_proto_version >= 21){
int version = 1;
writeU8(os, version);
writeF1000(os, 0); // deprecated heat
writeF1000(os, 0); // deprecated humidity
}
writeU8(os, 1); // version
writeF1000(os, 0); // deprecated heat
writeF1000(os, 0); // deprecated humidity
}

void MapBlock::deSerialize(std::istream &is, u8 version, bool disk)
@@ -541,7 +541,7 @@ class MapBlock /*: public NodeContainer*/
// unknown blocks from id-name mapping to wndef
void deSerialize(std::istream &is, u8 version, bool disk);

void serializeNetworkSpecific(std::ostream &os, u16 net_proto_version);
void serializeNetworkSpecific(std::ostream &os);
void deSerializeNetworkSpecific(std::istream &is);
private:
/*
@@ -698,11 +698,11 @@ inline bool blockpos_over_limit(v3s16 p)
{
const u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT,
g_settings->getU16("map_generation_limit"));
return (p.X * MAP_BLOCKSIZE < -map_gen_limit
return (p.X * MAP_BLOCKSIZE < -map_gen_limit
|| (p.X + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit
|| p.Y * MAP_BLOCKSIZE < -map_gen_limit
|| p.Y * MAP_BLOCKSIZE < -map_gen_limit
|| (p.Y + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit
|| p.Z * MAP_BLOCKSIZE < -map_gen_limit
|| p.Z * MAP_BLOCKSIZE < -map_gen_limit
|| (p.Z + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit);
}

@@ -153,14 +153,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define LATEST_PROTOCOL_VERSION 30

// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 13
#define SERVER_PROTOCOL_VERSION_MIN 24
#define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION

// Client's supported network protocol range
// The minimal version depends on whether
// send_pre_v25_init is enabled or not
#define CLIENT_PROTOCOL_VERSION_MIN 25
#define CLIENT_PROTOCOL_VERSION_MIN_LEGACY 13
#define CLIENT_PROTOCOL_VERSION_MIN_LEGACY 24
#define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION

// Constant that differentiates the protocol from random data and other protocols
@@ -614,20 +614,6 @@ void Server::handleCommand_Init2(NetworkPacket* pkt)
u16 protocol_version = m_clients.getProtocolVersion(pkt->getPeerId());


///// begin compatibility code
PlayerSAO* playersao = NULL;
if (protocol_version <= 22) {
playersao = StageTwoClientInit(pkt->getPeerId());

if (playersao == NULL) {
actionstream
<< "TOSERVER_INIT2 stage 2 client init failed for peer "
<< pkt->getPeerId() << std::endl;
return;
}
}
///// end compatibility code

/*
Send some initialization data
*/
@@ -657,13 +643,6 @@ void Server::handleCommand_Init2(NetworkPacket* pkt)
float time_speed = g_settings->getFloat("time_speed");
SendTimeOfDay(pkt->getPeerId(), time, time_speed);

///// begin compatibility code
if (protocol_version <= 22) {
m_clients.event(pkt->getPeerId(), CSE_SetClientReady);
m_script->on_joinplayer(playersao);
}
///// end compatibility code

// Warnings about protocol version can be issued here
if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) {
SendChatMessage(pkt->getPeerId(), L"# Server: WARNING: YOUR CLIENT'S "

0 comments on commit f8ad01a

Please sign in to comment.
You can’t perform that action at this time.