diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-08-29 19:26:55 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-29 19:26:55 +0200 |
commit | b7ee608e70f8e031e3e01c9672bedb16efa648b8 (patch) | |
tree | d4aa75bc30fa45cb3ec024e92aeff3e605cc8cc0 /src/tool.cpp | |
parent | 1b3e4e173624bb2523d4386aeef6987709d9b022 (diff) | |
download | minetest-b7ee608e70f8e031e3e01c9672bedb16efa648b8.tar.gz minetest-b7ee608e70f8e031e3e01c9672bedb16efa648b8.tar.bz2 minetest-b7ee608e70f8e031e3e01c9672bedb16efa648b8.zip |
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
Diffstat (limited to 'src/tool.cpp')
-rw-r--r-- | src/tool.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/tool.cpp b/src/tool.cpp index 38508c5fe..839b1e387 100644 --- a/src/tool.cpp +++ b/src/tool.cpp @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const { - writeU8(os, 2); // version (protocol >= 18) + writeU8(os, 3); // protocol_version >= 36 writeF1000(os, full_punch_interval); writeS16(os, max_drop_level); writeU32(os, groupcaps.size()); @@ -55,33 +55,32 @@ void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const void ToolCapabilities::deSerialize(std::istream &is) { int version = readU8(is); - if(version != 1 && version != 2) throw SerializationError( - "unsupported ToolCapabilities version"); + if (version < 3) + throw SerializationError("unsupported ToolCapabilities version"); + full_punch_interval = readF1000(is); max_drop_level = readS16(is); groupcaps.clear(); u32 groupcaps_size = readU32(is); - for(u32 i=0; i<groupcaps_size; i++){ + for (u32 i = 0; i < groupcaps_size; i++) { std::string name = deSerializeString(is); ToolGroupCap cap; cap.uses = readS16(is); cap.maxlevel = readS16(is); u32 times_size = readU32(is); - for(u32 i=0; i<times_size; i++){ + for(u32 i = 0; i < times_size; i++) { int level = readS16(is); float time = readF1000(is); cap.times[level] = time; } groupcaps[name] = cap; } - if(version == 2) - { - u32 damage_groups_size = readU32(is); - for(u32 i=0; i<damage_groups_size; i++){ - std::string name = deSerializeString(is); - s16 rating = readS16(is); - damageGroups[name] = rating; - } + + u32 damage_groups_size = readU32(is); + for (u32 i = 0; i < damage_groups_size; i++) { + std::string name = deSerializeString(is); + s16 rating = readS16(is); + damageGroups[name] = rating; } } |