Skip to content

Commit 46d1d70

Browse files
committedJul 20, 2013
Bump protocol version
1 parent 8cae659 commit 46d1d70

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed
 

‎src/clientserver.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
9595
TOCLIENT_HUDRM
9696
TOCLIENT_HUDCHANGE
9797
TOCLIENT_HUD_SET_FLAGS
98+
PROTOCOL_VERSION 21:
99+
TOCLIENT_BREATH
100+
TOSERVER_BREATH
101+
range added to ItemDefinition
102+
drowning, leveled and liquid_range added to ContentFeatures
98103
*/
99104

100-
#define LATEST_PROTOCOL_VERSION 20
105+
#define LATEST_PROTOCOL_VERSION 21
101106

102107
// Server's supported network protocol range
103108
#define SERVER_PROTOCOL_VERSION_MIN 13

‎src/itemdef.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
119119
{
120120
if(protocol_version <= 17)
121121
writeU8(os, 1); // version
122-
else
122+
else if(protocol_version <= 20)
123123
writeU8(os, 2); // version
124+
else
125+
writeU8(os, 3); // version
124126
writeU8(os, type);
125127
os<<serializeString(name);
126128
os<<serializeString(description);
@@ -148,6 +150,8 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
148150
//serializeSimpleSoundSpec(sound_place, os);
149151
os<<serializeString(sound_place.name);
150152
writeF1000(os, sound_place.gain);
153+
}
154+
if(protocol_version > 20){
151155
writeF1000(os, range);
152156
}
153157
}
@@ -159,7 +163,7 @@ void ItemDefinition::deSerialize(std::istream &is)
159163

160164
// Deserialize
161165
int version = readU8(is);
162-
if(version != 1 && version != 2)
166+
if(version < 1 || version > 3)
163167
throw SerializationError("unsupported ItemDefinition version");
164168
type = (enum ItemType)readU8(is);
165169
name = deSerializeString(is);
@@ -192,16 +196,18 @@ void ItemDefinition::deSerialize(std::istream &is)
192196
// Set the old default sound
193197
sound_place.name = "default_place_node";
194198
sound_place.gain = 0.5;
195-
} else if(version == 2) {
199+
} else if(version >= 2) {
196200
node_placement_prediction = deSerializeString(is);
197201
//deserializeSimpleSoundSpec(sound_place, is);
198202
sound_place.name = deSerializeString(is);
199203
sound_place.gain = readF1000(is);
200204
}
205+
if(version == 3) {
206+
range = readF1000(is);
207+
}
201208
// If you add anything here, insert it primarily inside the try-catch
202209
// block to not need to increase the version.
203210
try{
204-
range = readF1000(is);
205211
}catch(SerializationError &e) {};
206212
}
207213

‎src/nodedef.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
281281
serializeSimpleSoundSpec(sound_dig, os);
282282
serializeSimpleSoundSpec(sound_dug, os);
283283
writeU8(os, rightclickable);
284-
// Stuff below should be moved to correct place in a version that otherwise changes
285-
// the protocol version
286284
writeU8(os, drowning);
287285
writeU8(os, leveled);
288286
writeU8(os, liquid_range);
287+
// Stuff below should be moved to correct place in a version that otherwise changes
288+
// the protocol version
289289
}
290290

291291
void ContentFeatures::deSerialize(std::istream &is)
@@ -345,14 +345,14 @@ void ContentFeatures::deSerialize(std::istream &is)
345345
deSerializeSimpleSoundSpec(sound_dig, is);
346346
deSerializeSimpleSoundSpec(sound_dug, is);
347347
rightclickable = readU8(is);
348+
drowning = readU8(is);
349+
leveled = readU8(is);
350+
liquid_range = readU8(is);
348351
// If you add anything here, insert it primarily inside the try-catch
349352
// block to not need to increase the version.
350353
try{
351354
// Stuff below should be moved to correct place in a version that
352355
// otherwise changes the protocol version
353-
drowning = readU8(is);
354-
leveled = readU8(is);
355-
liquid_range = readU8(is);
356356
}catch(SerializationError &e) {};
357357
}
358358

0 commit comments

Comments
 (0)
Please sign in to comment.