Skip to content
Permalink
Browse files

Bump minimal protocol version to 36 (#6319)

* 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 b7ee608e70f8e031e3e01c9672bedb16efa648b8
Showing with 136 additions and 503 deletions.
  1. +0 −5 src/content_cao.cpp
  2. +28 −39 src/itemdef.cpp
  3. +5 −3 src/network/networkprotocol.h
  4. +43 −369 src/nodedef.cpp
  5. +2 −1 src/nodedef.h
  6. +42 −48 src/object_properties.cpp
  7. +2 −23 src/tileanimation.cpp
  8. +2 −2 src/tileanimation.h
  9. +12 −13 src/tool.cpp
@@ -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);
}
}

@@ -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);
}

@@ -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);
@@ -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)
@@ -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);
@@ -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) {};
}

/*
@@ -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

Oops, something went wrong.

0 comments on commit b7ee608

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