mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
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.
This commit is contained in:
parent
0b41533763
commit
a463620edb
20 changed files with 140 additions and 188 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue