-
- is.read((char*)buf, 2);
- u16 count = readU16(buf);
-
- for(u16 i=0; i<count; i++)
- {
- is.read((char*)buf, 2);
- u16 p16 = readU16(buf);
-
- v3s16 p(0,0,0);
- p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
- p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
- p.Y += p16 / MAP_BLOCKSIZE;
- p16 -= p.Y * MAP_BLOCKSIZE;
- p.X += p16;
-
- NodeMetadata *data = NodeMetadata::deSerialize(is, gamedef);
-
- if(data == NULL)
- continue;
-
- if(m_data.find(p))
- {
- infostream<<"WARNING: NodeMetadataList::deSerialize(): "
- <<"already set data at position"
- <<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
- <<std::endl;
- delete data;
+
+ if (version > 2) {
+ std::string err_str = std::string(FUNCTION_NAME)
+ + ": version " + itos(version) + " not supported";
+ infostream << err_str << std::endl;
+ throw SerializationError(err_str);
+ }
+
+ u16 count = readU16(is);
+
+ for (u16 i = 0; i < count; i++) {
+ u16 p16 = readU16(is);
+
+ v3s16 p;
+ p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
+ p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
+ p.Y = p16 / MAP_BLOCKSIZE;
+ p16 &= MAP_BLOCKSIZE - 1;
+ p.X = p16;
+
+ if (m_data.find(p) != m_data.end()) {
+ warningstream << "NodeMetadataList::deSerialize(): "
+ << "already set data at position " << PP(p)
+ << ": Ignoring." << std::endl;