Created
July 20, 2013 18:57
-
-
Save PilzAdam/6046081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/clientserver.h b/src/clientserver.h | |
index a84d29a..a6dae33 100644 | |
--- a/src/clientserver.h | |
+++ b/src/clientserver.h | |
@@ -97,7 +97,7 @@ | |
TOCLIENT_HUD_SET_FLAGS | |
*/ | |
-#define LATEST_PROTOCOL_VERSION 20 | |
+#define LATEST_PROTOCOL_VERSION 21 | |
// Server's supported network protocol range | |
#define SERVER_PROTOCOL_VERSION_MIN 13 | |
diff --git a/src/itemdef.cpp b/src/itemdef.cpp | |
index 4ac23d0..3106c34 100644 | |
--- a/src/itemdef.cpp | |
+++ b/src/itemdef.cpp | |
@@ -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); | |
@@ -197,11 +201,12 @@ void ItemDefinition::deSerialize(std::istream &is) | |
//deserializeSimpleSoundSpec(sound_place, is); | |
sound_place.name = deSerializeString(is); | |
sound_place.gain = readF1000(is); | |
+ } else 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) {}; | |
} | |
diff --git a/src/nodedef.cpp b/src/nodedef.cpp | |
index b1ce7bb..a4d0368 100644 | |
--- a/src/nodedef.cpp | |
+++ b/src/nodedef.cpp | |
@@ -281,11 +281,11 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) | |
serializeSimpleSoundSpec(sound_dig, os); | |
serializeSimpleSoundSpec(sound_dug, os); | |
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, leveled); | |
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) | |
@@ -345,14 +345,14 @@ void ContentFeatures::deSerialize(std::istream &is) | |
deSerializeSimpleSoundSpec(sound_dig, is); | |
deSerializeSimpleSoundSpec(sound_dug, 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 | |
// block to not need to increase the version. | |
try{ | |
// Stuff below should be moved to correct place in a version that | |
// otherwise changes the protocol version | |
- drowning = readU8(is); | |
- leveled = readU8(is); | |
- liquid_range = readU8(is); | |
}catch(SerializationError &e) {}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment