summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorproller <proller@github.com>2013-08-02 00:51:36 +0400
committerproller <proller@github.com>2013-08-02 00:51:36 +0400
commit06cdce1e1231fb5946ac9750f9b53b53c6f7e5f8 (patch)
tree09af2d05170bf088f4560778517b72fad0983914 /src/mapblock.cpp
parent0e89bca173fb000368786e5c9f5614e506737b92 (diff)
downloadminetest-06cdce1e1231fb5946ac9750f9b53b53c6f7e5f8.tar.gz
minetest-06cdce1e1231fb5946ac9750f9b53b53c6f7e5f8.tar.bz2
minetest-06cdce1e1231fb5946ac9750f9b53b53c6f7e5f8.zip
Weather backward compatibility
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index bd2e19b41..617ba6584 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -636,11 +636,21 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
// Node timers
m_node_timers.serialize(os, version);
}
- } else {
- if(version >= 26){
- writeF1000(os, heat);
- writeF1000(os, humidity);
- }
+ }
+}
+
+void MapBlock::serializeNetworkSpecific(std::ostream &os, u16 net_proto_version)
+{
+ if(data == NULL)
+ {
+ throw SerializationError("ERROR: Not writing dummy block.");
+ }
+
+ if(net_proto_version >= 21){
+ int version = 1;
+ writeU8(os, version);
+ writeF1000(os, heat);
+ writeF1000(os, humidity);
}
}
@@ -743,17 +753,30 @@ void MapBlock::deSerialize(std::istream &is, u8 version, bool disk)
<<": Node timers (ver>=25)"<<std::endl);
m_node_timers.deSerialize(is, version);
}
- } else {
- if(version >= 26){
- heat = readF1000(is);
- humidity = readF1000(is);
- }
}
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
<<": Done."<<std::endl);
}
+void MapBlock::deSerializeNetworkSpecific(std::istream &is)
+{
+ try {
+ int version = readU8(is);
+ //if(version != 1)
+ // throw SerializationError("unsupported MapBlock version");
+ if(version >= 1) {
+ heat = readF1000(is);
+ humidity = readF1000(is);
+ }
+ }
+ catch(SerializationError &e)
+ {
+ errorstream<<"WARNING: MapBlock::deSerializeNetworkSpecific(): Ignoring an error"
+ <<": "<<e.what()<<std::endl;
+ }
+}
+
/*
Legacy serialization
*/