aboutsummaryrefslogtreecommitdiff
path: root/src/itemdef.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-06-20 21:56:12 +0200
committerGitHub <noreply@github.com>2022-06-20 21:56:12 +0200
commita463620edbe57071a7101297d33226507567ca73 (patch)
tree342d433ca55f4e3d1826508c303f2e6229d503f1 /src/itemdef.cpp
parent0b41533763bc9f104a2da2e4191f4654b8d8dab4 (diff)
downloadminetest-a463620edbe57071a7101297d33226507567ca73.tar.gz
minetest-a463620edbe57071a7101297d33226507567ca73.tar.bz2
minetest-a463620edbe57071a7101297d33226507567ca73.zip
Re-order sound-related code (#12382)
Dropped ServerSoundParams -> moved to ServerPlayingSound. This gets rid of the duplicated 'fade' and 'pitch' values on server-side where only one was used anyway. SimpleSoundSpec is the basic sound without positional information, hence 'loop' is included. Recursively added PROTOCOL_VERSION to most functions to reduce the versioning mess in the future. Per-type version numbers are kept for now as a safety rope in a special case.
Diffstat (limited to 'src/itemdef.cpp')
-rw-r--r--src/itemdef.cpp21
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);
}