#include <sstream>
#include "map.h"
-// For g_settings
-#include "main.h"
#include "light.h"
#include "nodedef.h"
#include "nodemetadata.h"
#include "nameidmapping.h"
#include "content_mapnode.h" // For legacy name-id mapping
#include "content_nodemeta.h" // For legacy deserialization
+#include "serialization.h"
#ifndef SERVER
#include "mapblock_mesh.h"
#endif
MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
heat(0),
- heat_time(0),
humidity(0),
- humidity_time(0),
+ weather_update_time(0),
m_parent(parent),
m_pos(pos),
m_gamedef(gamedef),
// 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);
}
}
<<": 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
*/