1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-15 22:05:07 -05:00

Bump protocol version

This commit is contained in:
PilzAdam 2013-07-20 21:25:21 +02:00
parent 8cae659786
commit 46d1d70e4c
3 changed files with 21 additions and 10 deletions

View File

@ -95,9 +95,14 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
TOCLIENT_HUDRM TOCLIENT_HUDRM
TOCLIENT_HUDCHANGE TOCLIENT_HUDCHANGE
TOCLIENT_HUD_SET_FLAGS TOCLIENT_HUD_SET_FLAGS
PROTOCOL_VERSION 21:
TOCLIENT_BREATH
TOSERVER_BREATH
range added to ItemDefinition
drowning, leveled and liquid_range added to ContentFeatures
*/ */
#define LATEST_PROTOCOL_VERSION 20 #define LATEST_PROTOCOL_VERSION 21
// Server's supported network protocol range // Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 13 #define SERVER_PROTOCOL_VERSION_MIN 13

View File

@ -119,8 +119,10 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
{ {
if(protocol_version <= 17) if(protocol_version <= 17)
writeU8(os, 1); // version writeU8(os, 1); // version
else else if(protocol_version <= 20)
writeU8(os, 2); // version writeU8(os, 2); // version
else
writeU8(os, 3); // version
writeU8(os, type); writeU8(os, type);
os<<serializeString(name); os<<serializeString(name);
os<<serializeString(description); os<<serializeString(description);
@ -148,6 +150,8 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
//serializeSimpleSoundSpec(sound_place, os); //serializeSimpleSoundSpec(sound_place, os);
os<<serializeString(sound_place.name); os<<serializeString(sound_place.name);
writeF1000(os, sound_place.gain); writeF1000(os, sound_place.gain);
}
if(protocol_version > 20){
writeF1000(os, range); writeF1000(os, range);
} }
} }
@ -159,7 +163,7 @@ void ItemDefinition::deSerialize(std::istream &is)
// Deserialize // Deserialize
int version = readU8(is); int version = readU8(is);
if(version != 1 && version != 2) if(version < 1 || version > 3)
throw SerializationError("unsupported ItemDefinition version"); throw SerializationError("unsupported ItemDefinition version");
type = (enum ItemType)readU8(is); type = (enum ItemType)readU8(is);
name = deSerializeString(is); name = deSerializeString(is);
@ -192,16 +196,18 @@ void ItemDefinition::deSerialize(std::istream &is)
// Set the old default sound // Set the old default sound
sound_place.name = "default_place_node"; sound_place.name = "default_place_node";
sound_place.gain = 0.5; sound_place.gain = 0.5;
} else if(version == 2) { } else if(version >= 2) {
node_placement_prediction = deSerializeString(is); node_placement_prediction = deSerializeString(is);
//deserializeSimpleSoundSpec(sound_place, is); //deserializeSimpleSoundSpec(sound_place, is);
sound_place.name = deSerializeString(is); sound_place.name = deSerializeString(is);
sound_place.gain = readF1000(is); sound_place.gain = readF1000(is);
} }
if(version == 3) {
range = readF1000(is);
}
// If you add anything here, insert it primarily inside the try-catch // If you add anything here, insert it primarily inside the try-catch
// block to not need to increase the version. // block to not need to increase the version.
try{ try{
range = readF1000(is);
}catch(SerializationError &e) {}; }catch(SerializationError &e) {};
} }

View File

@ -281,11 +281,11 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
serializeSimpleSoundSpec(sound_dig, os); serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os); serializeSimpleSoundSpec(sound_dug, os);
writeU8(os, rightclickable); writeU8(os, rightclickable);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
writeU8(os, drowning); writeU8(os, drowning);
writeU8(os, leveled); writeU8(os, leveled);
writeU8(os, liquid_range); writeU8(os, liquid_range);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
} }
void ContentFeatures::deSerialize(std::istream &is) void ContentFeatures::deSerialize(std::istream &is)
@ -345,14 +345,14 @@ void ContentFeatures::deSerialize(std::istream &is)
deSerializeSimpleSoundSpec(sound_dig, is); deSerializeSimpleSoundSpec(sound_dig, is);
deSerializeSimpleSoundSpec(sound_dug, is); deSerializeSimpleSoundSpec(sound_dug, is);
rightclickable = readU8(is); rightclickable = readU8(is);
drowning = readU8(is);
leveled = readU8(is);
liquid_range = readU8(is);
// If you add anything here, insert it primarily inside the try-catch // If you add anything here, insert it primarily inside the try-catch
// block to not need to increase the version. // block to not need to increase the version.
try{ try{
// Stuff below should be moved to correct place in a version that // Stuff below should be moved to correct place in a version that
// otherwise changes the protocol version // otherwise changes the protocol version
drowning = readU8(is);
leveled = readU8(is);
liquid_range = readU8(is);
}catch(SerializationError &e) {}; }catch(SerializationError &e) {};
} }