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
This commit is contained in:
Loïc Blot 2017-03-19 08:44:29 +01:00 committed by GitHub
parent b8484ef24e
commit f8ad01ab7c
10 changed files with 115 additions and 298 deletions

@ -470,8 +470,7 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
{ {
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
if(protocol_version >= 14) // protocol >= 14
{
writeU8(os, 1); // version writeU8(os, 1); // version
os << serializeString(""); // name os << serializeString(""); // name
writeU8(os, 0); // is_player writeU8(os, 0); // is_player
@ -507,19 +506,6 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
writeU8(os, message_count); writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size()); os.write(msg_os.str().c_str(), msg_os.str().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
}
// return result // return result
return os.str(); return os.str();
@ -877,8 +863,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
{ {
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
if(protocol_version >= 15) // Protocol >= 15
{
writeU8(os, 1); // version writeU8(os, 1); // version
os << serializeString(m_player->getName()); // name os << serializeString(m_player->getName()); // name
writeU8(os, 1); // is_player writeU8(os, 1); // is_player
@ -916,19 +901,6 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
writeU8(os, message_count); writeU8(os, message_count);
os.write(msg_os.str().c_str(), msg_os.str().size()); os.write(msg_os.str().c_str(), msg_os.str().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
}
// return result // return result
return os.str(); return os.str();

@ -123,12 +123,8 @@ void ItemDefinition::reset()
void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
{ {
if(protocol_version <= 17)
writeU8(os, 1); // version writeU8(os, 3); // version (proto > 20)
else if(protocol_version <= 20)
writeU8(os, 2); // version
else
writeU8(os, 3); // version
writeU8(os, type); writeU8(os, type);
os << serializeString(name); os << serializeString(name);
os << serializeString(description); os << serializeString(description);
@ -152,17 +148,12 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
writeS16(os, i->second); writeS16(os, i->second);
} }
os << serializeString(node_placement_prediction); os << serializeString(node_placement_prediction);
if(protocol_version > 17){
//serializeSimpleSoundSpec(sound_place, os);
os << serializeString(sound_place.name); os << serializeString(sound_place.name);
writeF1000(os, sound_place.gain); writeF1000(os, sound_place.gain);
}
if (protocol_version > 20) {
writeF1000(os, range); writeF1000(os, range);
os << serializeString(sound_place_failed.name); os << serializeString(sound_place_failed.name);
writeF1000(os, sound_place_failed.gain); writeF1000(os, sound_place_failed.gain);
} }
}
void ItemDefinition::deSerialize(std::istream &is) 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" throw SerializationError("ServerMap::loadBlock(): Failed"
" to read MapBlock version"); " 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; MapBlock *block = NULL;
bool created_new = false; bool created_new = false;
block = sector->getBlockNoCreateNoEx(p3d.Y); block = sector->getBlockNoCreateNoEx(p3d.Y);

@ -640,20 +640,16 @@ 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."); throw SerializationError("ERROR: Not writing dummy block.");
} }
if(net_proto_version >= 21){ writeU8(os, 1); // version
int version = 1;
writeU8(os, version);
writeF1000(os, 0); // deprecated heat writeF1000(os, 0); // deprecated heat
writeF1000(os, 0); // deprecated humidity writeF1000(os, 0); // deprecated humidity
} }
}
void MapBlock::deSerialize(std::istream &is, u8 version, bool disk) void MapBlock::deSerialize(std::istream &is, u8 version, bool disk)
{ {

@ -541,7 +541,7 @@ public:
// unknown blocks from id-name mapping to wndef // unknown blocks from id-name mapping to wndef
void deSerialize(std::istream &is, u8 version, bool disk); 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); void deSerializeNetworkSpecific(std::istream &is);
private: private:
/* /*

@ -153,14 +153,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define LATEST_PROTOCOL_VERSION 30 #define LATEST_PROTOCOL_VERSION 30
// Server's supported network protocol range // 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 #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
// Client's supported network protocol range // Client's supported network protocol range
// The minimal version depends on whether // The minimal version depends on whether
// send_pre_v25_init is enabled or not // send_pre_v25_init is enabled or not
#define CLIENT_PROTOCOL_VERSION_MIN 25 #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 #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
// Constant that differentiates the protocol from random data and other protocols // 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()); 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 Send some initialization data
*/ */
@ -657,13 +643,6 @@ void Server::handleCommand_Init2(NetworkPacket* pkt)
float time_speed = g_settings->getFloat("time_speed"); float time_speed = g_settings->getFloat("time_speed");
SendTimeOfDay(pkt->getPeerId(), time, 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 // Warnings about protocol version can be issued here
if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) { if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) {
SendChatMessage(pkt->getPeerId(), L"# Server: WARNING: YOUR CLIENT'S " SendChatMessage(pkt->getPeerId(), L"# Server: WARNING: YOUR CLIENT'S "

@ -61,11 +61,10 @@ void NodeBox::reset()
void NodeBox::serialize(std::ostream &os, u16 protocol_version) const void NodeBox::serialize(std::ostream &os, u16 protocol_version) const
{ {
int version = 1; // Protocol >= 21
int version = 2;
if (protocol_version >= 27) if (protocol_version >= 27)
version = 3; version = 3;
else if (protocol_version >= 21)
version = 2;
writeU8(os, version); writeU8(os, version);
switch (type) { switch (type) {
@ -195,13 +194,11 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
writeU8(os, 3); writeU8(os, 3);
else if (protocol_version >= 26) else if (protocol_version >= 26)
writeU8(os, 2); writeU8(os, 2);
else if (protocol_version >= 17)
writeU8(os, 1);
else else
writeU8(os, 0); writeU8(os, 1);
os << serializeString(name); os << serializeString(name);
animation.serialize(os, protocol_version); animation.serialize(os, protocol_version);
if (protocol_version >= 17)
writeU8(os, backface_culling); writeU8(os, backface_culling);
if (protocol_version >= 26) { if (protocol_version >= 26) {
writeU8(os, tileable_horizontal); writeU8(os, tileable_horizontal);
@ -1615,109 +1612,8 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
if (protocol_version < 30 && drawtype == NDT_PLANTLIKE) if (protocol_version < 30 && drawtype == NDT_PLANTLIKE)
compatible_visual_scale = sqrt(visual_scale); compatible_visual_scale = sqrt(visual_scale);
if (protocol_version == 13) // Protocol >= 24
{ if (protocol_version < 30) {
writeU8(os, 5); // version
os<<serializeString(name);
writeU16(os, groups.size());
for (ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); ++i) {
os<<serializeString(i->first);
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, compatible_visual_scale);
writeU8(os, 6);
for (u32 i = 0; i < 6; i++)
tiledef[i].serialize(os, protocol_version);
//CF_SPECIAL_COUNT = 2 before cf ver. 7 and protocol ver. 24
writeU8(os, 2);
for (u32 i = 0; i < 2; i++)
tiledef_special[i].serialize(os, protocol_version);
writeU8(os, alpha);
writeU8(os, post_effect_color.getAlpha());
writeU8(os, post_effect_color.getRed());
writeU8(os, post_effect_color.getGreen());
writeU8(os, post_effect_color.getBlue());
writeU8(os, param_type);
writeU8(os, compatible_param_type_2);
writeU8(os, is_ground_content);
writeU8(os, light_propagates);
writeU8(os, sunlight_propagates);
writeU8(os, walkable);
writeU8(os, pointable);
writeU8(os, diggable);
writeU8(os, climbable);
writeU8(os, buildable_to);
os<<serializeString(""); // legacy: used to be metadata_name
writeU8(os, liquid_type);
os<<serializeString(liquid_alternative_flowing);
os<<serializeString(liquid_alternative_source);
writeU8(os, liquid_viscosity);
writeU8(os, light_source);
writeU32(os, damage_per_second);
node_box.serialize(os, protocol_version);
selection_box.serialize(os, protocol_version);
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
serializeSimpleSoundSpec(sound_footstep, os);
serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os);
}
else if (protocol_version > 13 && protocol_version < 24) {
writeU8(os, 6); // version
os<<serializeString(name);
writeU16(os, groups.size());
for (ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); ++i) {
os<<serializeString(i->first);
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, compatible_visual_scale);
writeU8(os, 6);
for (u32 i = 0; i < 6; i++)
tiledef[i].serialize(os, protocol_version);
//CF_SPECIAL_COUNT = 2 before cf ver. 7 and protocol ver. 24
writeU8(os, 2);
for (u32 i = 0; i < 2; i++)
tiledef_special[i].serialize(os, protocol_version);
writeU8(os, alpha);
writeU8(os, post_effect_color.getAlpha());
writeU8(os, post_effect_color.getRed());
writeU8(os, post_effect_color.getGreen());
writeU8(os, post_effect_color.getBlue());
writeU8(os, param_type);
writeU8(os, compatible_param_type_2);
writeU8(os, is_ground_content);
writeU8(os, light_propagates);
writeU8(os, sunlight_propagates);
writeU8(os, walkable);
writeU8(os, pointable);
writeU8(os, diggable);
writeU8(os, climbable);
writeU8(os, buildable_to);
os<<serializeString(""); // legacy: used to be metadata_name
writeU8(os, liquid_type);
os<<serializeString(liquid_alternative_flowing);
os<<serializeString(liquid_alternative_source);
writeU8(os, liquid_viscosity);
writeU8(os, liquid_renewable);
writeU8(os, light_source);
writeU32(os, damage_per_second);
node_box.serialize(os, protocol_version);
selection_box.serialize(os, protocol_version);
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
serializeSimpleSoundSpec(sound_footstep, os);
serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os);
writeU8(os, rightclickable);
writeU8(os, drowning);
writeU8(os, leveled);
writeU8(os, liquid_range);
}
else if(protocol_version >= 24 && protocol_version < 30) {
writeU8(os, protocol_version < 27 ? 7 : 8); writeU8(os, protocol_version < 27 ? 7 : 8);
os << serializeString(name); os << serializeString(name);
@ -1778,10 +1674,11 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
i != connects_to_ids.end(); ++i) i != connects_to_ids.end(); ++i)
writeU16(os, *i); writeU16(os, *i);
writeU8(os, connect_sides); writeU8(os, connect_sides);
} else } else {
throw SerializationError("ContentFeatures::serialize(): " throw SerializationError("ContentFeatures::serialize(): "
"Unsupported version requested"); "Unsupported version requested");
} }
}
void ContentFeatures::deSerializeOld(std::istream &is, int version) void ContentFeatures::deSerializeOld(std::istream &is, int version)
{ {

@ -2147,14 +2147,6 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
if (client != 0) { if (client != 0) {
pkt << p << n.param0 << n.param1 << n.param2 pkt << p << n.param0 << n.param1 << n.param2
<< (u8) (remove_metadata ? 0 : 1); << (u8) (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(getNodeBlockPos(p));
}
}
} }
m_clients.unlock(); m_clients.unlock();
@ -2188,7 +2180,7 @@ void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto
std::ostringstream os(std::ios_base::binary); std::ostringstream os(std::ios_base::binary);
block->serialize(os, ver, false); block->serialize(os, ver, false);
block->serializeNetworkSpecific(os, net_proto_version); block->serializeNetworkSpecific(os);
std::string s = os.str(); std::string s = os.str();
NetworkPacket pkt(TOCLIENT_BLOCKDATA, 2 + 2 + 2 + 2 + s.size(), peer_id); NetworkPacket pkt(TOCLIENT_BLOCKDATA, 2 + 2 + 2 + 2 + s.size(), peer_id);

@ -27,10 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
{ {
if(protocol_version <= 17) writeU8(os, 2); // version (protocol >= 18)
writeU8(os, 1); // version
else
writeU8(os, 2); // version
writeF1000(os, full_punch_interval); writeF1000(os, full_punch_interval);
writeS16(os, max_drop_level); writeS16(os, max_drop_level);
writeU32(os, groupcaps.size()); writeU32(os, groupcaps.size());
@ -42,20 +39,20 @@ void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
writeS16(os, cap->maxlevel); writeS16(os, cap->maxlevel);
writeU32(os, cap->times.size()); writeU32(os, cap->times.size());
for (UNORDERED_MAP<int, float>::const_iterator for (UNORDERED_MAP<int, float>::const_iterator
i = cap->times.begin(); i != cap->times.end(); ++i) { j = cap->times.begin(); j != cap->times.end(); ++j) {
writeS16(os, i->first); writeS16(os, j->first);
writeF1000(os, i->second); writeF1000(os, j->second);
} }
} }
if(protocol_version > 17){
writeU32(os, damageGroups.size()); writeU32(os, damageGroups.size());
for (DamageGroup::const_iterator i = damageGroups.begin(); for (DamageGroup::const_iterator i = damageGroups.begin();
i != damageGroups.end(); ++i) { i != damageGroups.end(); ++i) {
os << serializeString(i->first); os << serializeString(i->first);
writeS16(os, i->second); writeS16(os, i->second);
} }
} }
}
void ToolCapabilities::deSerialize(std::istream &is) void ToolCapabilities::deSerialize(std::istream &is)
{ {