Skip to content

Commit

Permalink
Bump minimal protocol version to 36 (#6319)
Browse files Browse the repository at this point in the history
* Bump minimal protocol version to 36
Item/Node/TileDef, NodeBox, TileAnimation: Remove old compat code

* Accept future serialisation versions
  • Loading branch information
SmallJoker authored and nerzhul committed Aug 29, 2017
1 parent 1b3e4e1 commit b7ee608
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 503 deletions.
5 changes: 0 additions & 5 deletions src/content_cao.cpp
Expand Up @@ -300,8 +300,6 @@ void GenericCAO::initialize(const std::string &data)
m_is_visible = false;
player->setCAO(this);
}
if (m_client->getProtoVersion() < 33)
m_env->addPlayerName(m_name);
}
}

Expand Down Expand Up @@ -337,9 +335,6 @@ void GenericCAO::processInitData(const std::string &data)

GenericCAO::~GenericCAO()
{
if (m_is_player && m_client->getProtoVersion() < 33) {
m_env->removePlayerName(m_name);
}
removeFromScene(true);
}

Expand Down
67 changes: 28 additions & 39 deletions src/itemdef.cpp
Expand Up @@ -128,7 +128,8 @@ void ItemDefinition::reset()

void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
{
u8 version = (protocol_version >= 34) ? 4 : 3;
// protocol_version >= 36
u8 version = 5;
writeU8(os, version);
writeU8(os, type);
os << serializeString(name);
Expand Down Expand Up @@ -158,14 +159,12 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
os << serializeString(sound_place_failed.name);
writeF1000(os, sound_place_failed.gain);
os << serializeString(palette_image);
writeU32(os, color.color);
writeARGB8(os, color);

if (version >= 4) {
writeF1000(os, sound_place.pitch);
writeF1000(os, sound_place_failed.pitch);
os << serializeString(inventory_overlay);
os << serializeString(wield_overlay);
}
writeF1000(os, sound_place.pitch);
writeF1000(os, sound_place_failed.pitch);
os << serializeString(inventory_overlay);
os << serializeString(wield_overlay);
}

void ItemDefinition::deSerialize(std::istream &is)
Expand All @@ -175,8 +174,9 @@ void ItemDefinition::deSerialize(std::istream &is)

// Deserialize
int version = readU8(is);
if (version < 1 || version > 4)
if (version < 5)
throw SerializationError("unsupported ItemDefinition version");

type = (enum ItemType)readU8(is);
name = deSerializeString(is);
description = deSerializeString(is);
Expand All @@ -200,38 +200,27 @@ void ItemDefinition::deSerialize(std::istream &is)
int value = readS16(is);
groups[name] = value;
}
if(version == 1){
// We cant be sure that node_placement_prediction is send in version 1
try{
node_placement_prediction = deSerializeString(is);
}catch(SerializationError &e) {};
// Set the old default sound
sound_place.name = "default_place_node";
sound_place.gain = 0.5;
} else if(version >= 2) {
node_placement_prediction = deSerializeString(is);
//deserializeSimpleSoundSpec(sound_place, is);
sound_place.name = deSerializeString(is);
sound_place.gain = readF1000(is);
}
if(version >= 3) {
range = readF1000(is);
}

node_placement_prediction = deSerializeString(is);
//deserializeSimpleSoundSpec(sound_place, is);
sound_place.name = deSerializeString(is);
sound_place.gain = readF1000(is);
range = readF1000(is);

sound_place_failed.name = deSerializeString(is);
sound_place_failed.gain = readF1000(is);
palette_image = deSerializeString(is);
color = readARGB8(is);

sound_place.pitch = readF1000(is);
sound_place_failed.pitch = readF1000(is);
inventory_overlay = deSerializeString(is);
wield_overlay = deSerializeString(is);

// If you add anything here, insert it primarily inside the try-catch
// block to not need to increase the version.
try {
sound_place_failed.name = deSerializeString(is);
sound_place_failed.gain = readF1000(is);
palette_image = deSerializeString(is);
color.set(readU32(is));

if (version >= 4) {
sound_place.pitch = readF1000(is);
sound_place_failed.pitch = readF1000(is);
inventory_overlay = deSerializeString(is);
wield_overlay = deSerializeString(is);
}
} catch(SerializationError &e) {};
//try {
//} catch(SerializationError &e) {};
}

/*
Expand Down
8 changes: 5 additions & 3 deletions src/network/networkprotocol.h
Expand Up @@ -176,18 +176,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
position
Add settable player stepheight using existing object property.
Breaks compatibility with older clients.
PROTOCOL VERSION 36:
Backwards compatibility drop
*/

#define LATEST_PROTOCOL_VERSION 35
#define LATEST_PROTOCOL_VERSION 36

// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 24
#define SERVER_PROTOCOL_VERSION_MIN 36
#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 36
#define CLIENT_PROTOCOL_VERSION_MIN_LEGACY 24
#define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION

Expand Down

0 comments on commit b7ee608

Please sign in to comment.