diff options
Diffstat (limited to 'src/itemdef.cpp')
-rw-r--r-- | src/itemdef.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/itemdef.cpp b/src/itemdef.cpp index d79d6b263..a34805b8e 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -154,8 +154,8 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const os << serializeString16(node_placement_prediction); // Version from ContentFeatures::serialize to keep in sync - sound_place.serialize(os, CONTENTFEATURES_VERSION); - sound_place_failed.serialize(os, CONTENTFEATURES_VERSION); + sound_place.serialize(os, protocol_version); + sound_place_failed.serialize(os, protocol_version); writeF32(os, range); os << serializeString16(palette_image); @@ -168,7 +168,7 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const os << place_param2; } -void ItemDefinition::deSerialize(std::istream &is) +void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version) { // Reset everything reset(); @@ -205,9 +205,8 @@ void ItemDefinition::deSerialize(std::istream &is) node_placement_prediction = deSerializeString16(is); - // Version from ContentFeatures::serialize to keep in sync - sound_place.deSerialize(is, CONTENTFEATURES_VERSION); - sound_place_failed.deSerialize(is, CONTENTFEATURES_VERSION); + sound_place.deSerialize(is, protocol_version); + sound_place_failed.deSerialize(is, protocol_version); range = readF32(is); palette_image = deSerializeString16(is); @@ -538,21 +537,21 @@ public: os << serializeString16(it.second); } } - void deSerialize(std::istream &is) + void deSerialize(std::istream &is, u16 protocol_version) { // Clear everything clear(); - // Deserialize - int version = readU8(is); - if(version != 0) + + if(readU8(is) != 0) throw SerializationError("unsupported ItemDefManager version"); + u16 count = readU16(is); for(u16 i=0; i<count; i++) { // Deserialize a string and grab an ItemDefinition from it std::istringstream tmp_is(deSerializeString16(is), std::ios::binary); ItemDefinition def; - def.deSerialize(tmp_is); + def.deSerialize(tmp_is, protocol_version); // Register registerItem(def); } |