diff options
author | proller <proller@github.com> | 2013-08-02 00:50:58 +0400 |
---|---|---|
committer | proller <proller@github.com> | 2013-08-02 00:50:58 +0400 |
commit | 0e89bca173fb000368786e5c9f5614e506737b92 (patch) | |
tree | cea7cf162c46dea554bf266dccf576e356eb1543 | |
parent | c6cb97e693722aee47aef03e4ea0788037a6a633 (diff) | |
download | minetest-0e89bca173fb000368786e5c9f5614e506737b92.tar.gz minetest-0e89bca173fb000368786e5c9f5614e506737b92.tar.bz2 minetest-0e89bca173fb000368786e5c9f5614e506737b92.zip |
Leveled nodebox backward compatibility
-rw-r--r-- | src/nodedef.cpp | 21 | ||||
-rw-r--r-- | src/nodedef.h | 2 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 96dca730b..53e4d63f5 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -46,10 +46,15 @@ void NodeBox::reset() wall_side = aabb3f(-BS/2, -BS/2, -BS/2, -BS/2+BS/16., BS/2, BS/2); } -void NodeBox::serialize(std::ostream &os) const +void NodeBox::serialize(std::ostream &os, u16 protocol_version) const { - writeU8(os, 1); // version - writeU8(os, type); + int version = protocol_version >= 21 ? 2 : 1; + writeU8(os, version); + + if (version == 1 && type == NODEBOX_LEVELED) + writeU8(os, NODEBOX_FIXED); + else + writeU8(os, type); if(type == NODEBOX_FIXED || type == NODEBOX_LEVELED) { @@ -76,7 +81,7 @@ void NodeBox::serialize(std::ostream &os) const void NodeBox::deSerialize(std::istream &is) { int version = readU8(is); - if(version != 1) + if(version < 1 || version > 2) throw SerializationError("unsupported NodeBox version"); reset(); @@ -274,8 +279,8 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) writeU8(os, liquid_renewable); writeU8(os, light_source); writeU32(os, damage_per_second); - node_box.serialize(os); - selection_box.serialize(os); + 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); @@ -918,8 +923,8 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) writeU8(os, liquid_viscosity); writeU8(os, light_source); writeU32(os, damage_per_second); - node_box.serialize(os); - selection_box.serialize(os); + 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); diff --git a/src/nodedef.h b/src/nodedef.h index 067861e62..714e1ba2c 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -90,7 +90,7 @@ struct NodeBox { reset(); } void reset(); - void serialize(std::ostream &os) const; + void serialize(std::ostream &os, u16 protocol_version) const; void deSerialize(std::istream &is); }; |