@@ -139,7 +139,7 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
139139 }
140140}
141141
142- void TileDef::deSerialize (std::istream &is, bool culling_ignore )
142+ void TileDef::deSerialize (std::istream &is, const u8 contenfeatures_version, const NodeDrawType drawtype )
143143{
144144 int version = readU8 (is);
145145 name = deSerializeString (is);
@@ -153,10 +153,12 @@ void TileDef::deSerialize(std::istream &is, bool culling_ignore)
153153 tileable_horizontal = readU8 (is);
154154 tileable_vertical = readU8 (is);
155155 }
156- // when connecting to old servers - do not use
157- // provided values here since culling needs to be
158- // disabled by default for these drawtypes
159- if (culling_ignore)
156+
157+ if ((contenfeatures_version < 8 ) &&
158+ ((drawtype == NDT_MESH) ||
159+ (drawtype == NDT_FIRELIKE) ||
160+ (drawtype == NDT_LIQUID) ||
161+ (drawtype == NDT_PLANTLIKE)))
160162 backface_culling = false ;
161163}
162164
@@ -268,7 +270,8 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
268270 return ;
269271 }
270272
271- writeU8 (os, 7 ); // version
273+ writeU8 (os, protocol_version < 27 ? 7 : 8 );
274+
272275 os<<serializeString (name);
273276 writeU16 (os, groups.size ());
274277 for (ItemGroupList::const_iterator
@@ -330,9 +333,11 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
330333void ContentFeatures::deSerialize (std::istream &is)
331334{
332335 int version = readU8 (is);
333- if (version != 7 ){
336+ if (version < 7 ) {
334337 deSerializeOld (is, version);
335338 return ;
339+ } else if (version > 8 ) {
340+ throw SerializationError (" unsupported ContentFeatures version" );
336341 }
337342
338343 name = deSerializeString (is);
@@ -345,21 +350,15 @@ void ContentFeatures::deSerialize(std::istream &is)
345350 }
346351 drawtype = (enum NodeDrawType)readU8 (is);
347352
348- bool ignore_culling = ((version <= 26 ) &&
349- ((drawtype == NDT_MESH) ||
350- (drawtype == NDT_PLANTLIKE) ||
351- (drawtype == NDT_FIRELIKE) ||
352- (drawtype == NDT_LIQUID)));
353-
354353 visual_scale = readF1000 (is);
355354 if (readU8 (is) != 6 )
356355 throw SerializationError (" unsupported tile count" );
357356 for (u32 i = 0 ; i < 6 ; i++)
358- tiledef[i].deSerialize (is, ignore_culling );
357+ tiledef[i].deSerialize (is, version, drawtype );
359358 if (readU8 (is) != CF_SPECIAL_COUNT)
360359 throw SerializationError (" unsupported CF_SPECIAL_COUNT" );
361360 for (u32 i = 0 ; i < CF_SPECIAL_COUNT; i++)
362- tiledef_special[i].deSerialize (is, ignore_culling );
361+ tiledef_special[i].deSerialize (is, version, drawtype );
363362 alpha = readU8 (is);
364363 post_effect_color.setAlpha (readU8 (is));
365364 post_effect_color.setRed (readU8 (is));
@@ -1284,21 +1283,15 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
12841283 }
12851284 drawtype = (enum NodeDrawType)readU8 (is);
12861285
1287- bool ignore_culling = ((version <= 26 ) &&
1288- ((drawtype == NDT_MESH) ||
1289- (drawtype == NDT_PLANTLIKE) ||
1290- (drawtype == NDT_FIRELIKE) ||
1291- (drawtype == NDT_LIQUID)));
1292-
12931286 visual_scale = readF1000 (is);
12941287 if (readU8 (is) != 6 )
12951288 throw SerializationError (" unsupported tile count" );
12961289 for (u32 i = 0 ; i < 6 ; i++)
1297- tiledef[i].deSerialize (is, ignore_culling );
1290+ tiledef[i].deSerialize (is, version, drawtype );
12981291 if (readU8 (is) != CF_SPECIAL_COUNT)
12991292 throw SerializationError (" unsupported CF_SPECIAL_COUNT" );
13001293 for (u32 i = 0 ; i < CF_SPECIAL_COUNT; i++)
1301- tiledef_special[i].deSerialize (is, ignore_culling );
1294+ tiledef_special[i].deSerialize (is, version, drawtype );
13021295 alpha = readU8 (is);
13031296 post_effect_color.setAlpha (readU8 (is));
13041297 post_effect_color.setRed (readU8 (is));
@@ -1342,12 +1335,12 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
13421335 if (readU8 (is) != 6 )
13431336 throw SerializationError (" unsupported tile count" );
13441337 for (u32 i = 0 ; i < 6 ; i++)
1345- tiledef[i].deSerialize (is, drawtype);
1338+ tiledef[i].deSerialize (is, version, drawtype);
13461339 // CF_SPECIAL_COUNT in version 6 = 2
13471340 if (readU8 (is) != 2 )
13481341 throw SerializationError (" unsupported CF_SPECIAL_COUNT" );
13491342 for (u32 i = 0 ; i < 2 ; i++)
1350- tiledef_special[i].deSerialize (is, drawtype);
1343+ tiledef_special[i].deSerialize (is, version, drawtype);
13511344 alpha = readU8 (is);
13521345 post_effect_color.setAlpha (readU8 (is));
13531346 post_effect_color.setRed (readU8 (is));
0 commit comments