mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Bump protocol version
This commit is contained in:
parent
8cae659786
commit
46d1d70e4c
3 changed files with 21 additions and 10 deletions
|
@ -119,8 +119,10 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
|||
{
|
||||
if(protocol_version <= 17)
|
||||
writeU8(os, 1); // version
|
||||
else
|
||||
else if(protocol_version <= 20)
|
||||
writeU8(os, 2); // version
|
||||
else
|
||||
writeU8(os, 3); // version
|
||||
writeU8(os, type);
|
||||
os<<serializeString(name);
|
||||
os<<serializeString(description);
|
||||
|
@ -148,6 +150,8 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
|||
//serializeSimpleSoundSpec(sound_place, os);
|
||||
os<<serializeString(sound_place.name);
|
||||
writeF1000(os, sound_place.gain);
|
||||
}
|
||||
if(protocol_version > 20){
|
||||
writeF1000(os, range);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +163,7 @@ void ItemDefinition::deSerialize(std::istream &is)
|
|||
|
||||
// Deserialize
|
||||
int version = readU8(is);
|
||||
if(version != 1 && version != 2)
|
||||
if(version < 1 || version > 3)
|
||||
throw SerializationError("unsupported ItemDefinition version");
|
||||
type = (enum ItemType)readU8(is);
|
||||
name = deSerializeString(is);
|
||||
|
@ -192,16 +196,18 @@ void ItemDefinition::deSerialize(std::istream &is)
|
|||
// Set the old default sound
|
||||
sound_place.name = "default_place_node";
|
||||
sound_place.gain = 0.5;
|
||||
} else if(version == 2) {
|
||||
} else if(version >= 2) {
|
||||
node_placement_prediction = deSerializeString(is);
|
||||
//deserializeSimpleSoundSpec(sound_place, is);
|
||||
sound_place.name = deSerializeString(is);
|
||||
sound_place.gain = readF1000(is);
|
||||
}
|
||||
if(version == 3) {
|
||||
range = readF1000(is);
|
||||
}
|
||||
// If you add anything here, insert it primarily inside the try-catch
|
||||
// block to not need to increase the version.
|
||||
try{
|
||||
range = readF1000(is);
|
||||
}catch(SerializationError &e) {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue