forked from Mirrorlandia_minetest/minetest
Backface culling: Ignore setting in tiledef from old servers.
Outdated servers are always sending tiledefs with culling enabled no matter what, as the value was previously entirely ignored. To compensate, we must (1) detect that we're running against an old server with a new client, and (2) disable culling for mesh, plantlike, firelike and liquid draw types no matter what the server is telling us. In order to achieve this, we need to bump the protocol version since we cannot rely on the tiledef version, and test for it being older. I've bumped the protocol version, although that should have likely happened in the actual change that introduced the new backface_culling PR #3578. Fortunately that's only 2 commits back at this point. We also explicitly test for the drawtype to assure we are not changing the culling value for other nodes, where it should remain enabled. This was tested against various pub servers, including 0.4.13 and 0.4.12. Fixes #3598
This commit is contained in:
parent
ef779b0ab6
commit
735e3b7059
@ -132,9 +132,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO
|
||||
PROTOCOL_VERSION 26:
|
||||
Add TileDef tileable_horizontal, tileable_vertical flags
|
||||
PROTOCOL_VERSION 27:
|
||||
backface_culling: backwards compatibility for playing with
|
||||
newer client on pre-27 servers.
|
||||
*/
|
||||
|
||||
#define LATEST_PROTOCOL_VERSION 26
|
||||
#define LATEST_PROTOCOL_VERSION 27
|
||||
|
||||
// Server's supported network protocol range
|
||||
#define SERVER_PROTOCOL_VERSION_MIN 13
|
||||
|
@ -139,7 +139,7 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
|
||||
}
|
||||
}
|
||||
|
||||
void TileDef::deSerialize(std::istream &is)
|
||||
void TileDef::deSerialize(std::istream &is, bool culling_ignore)
|
||||
{
|
||||
int version = readU8(is);
|
||||
name = deSerializeString(is);
|
||||
@ -153,6 +153,11 @@ void TileDef::deSerialize(std::istream &is)
|
||||
tileable_horizontal = readU8(is);
|
||||
tileable_vertical = readU8(is);
|
||||
}
|
||||
// when connecting to old servers - do not use
|
||||
// provided values here since culling needs to be
|
||||
// disabled by default for these drawtypes
|
||||
if (culling_ignore)
|
||||
backface_culling = false;
|
||||
}
|
||||
|
||||
|
||||
@ -339,15 +344,22 @@ void ContentFeatures::deSerialize(std::istream &is)
|
||||
groups[name] = value;
|
||||
}
|
||||
drawtype = (enum NodeDrawType)readU8(is);
|
||||
|
||||
bool ignore_culling = ((version <= 26) &&
|
||||
((drawtype == NDT_MESH) ||
|
||||
(drawtype == NDT_PLANTLIKE) ||
|
||||
(drawtype == NDT_FIRELIKE) ||
|
||||
(drawtype == NDT_LIQUID)));
|
||||
|
||||
visual_scale = readF1000(is);
|
||||
if(readU8(is) != 6)
|
||||
throw SerializationError("unsupported tile count");
|
||||
for(u32 i = 0; i < 6; i++)
|
||||
tiledef[i].deSerialize(is);
|
||||
tiledef[i].deSerialize(is, ignore_culling);
|
||||
if(readU8(is) != CF_SPECIAL_COUNT)
|
||||
throw SerializationError("unsupported CF_SPECIAL_COUNT");
|
||||
for(u32 i = 0; i < CF_SPECIAL_COUNT; i++)
|
||||
tiledef_special[i].deSerialize(is);
|
||||
tiledef_special[i].deSerialize(is, ignore_culling);
|
||||
alpha = readU8(is);
|
||||
post_effect_color.setAlpha(readU8(is));
|
||||
post_effect_color.setRed(readU8(is));
|
||||
@ -1258,7 +1270,6 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
|
||||
"Unsupported version requested");
|
||||
}
|
||||
|
||||
|
||||
void ContentFeatures::deSerializeOld(std::istream &is, int version)
|
||||
{
|
||||
if (version == 5) // In PROTOCOL_VERSION 13
|
||||
@ -1272,15 +1283,22 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
|
||||
groups[name] = value;
|
||||
}
|
||||
drawtype = (enum NodeDrawType)readU8(is);
|
||||
|
||||
bool ignore_culling = ((version <= 26) &&
|
||||
((drawtype == NDT_MESH) ||
|
||||
(drawtype == NDT_PLANTLIKE) ||
|
||||
(drawtype == NDT_FIRELIKE) ||
|
||||
(drawtype == NDT_LIQUID)));
|
||||
|
||||
visual_scale = readF1000(is);
|
||||
if (readU8(is) != 6)
|
||||
throw SerializationError("unsupported tile count");
|
||||
for (u32 i = 0; i < 6; i++)
|
||||
tiledef[i].deSerialize(is);
|
||||
tiledef[i].deSerialize(is, ignore_culling);
|
||||
if (readU8(is) != CF_SPECIAL_COUNT)
|
||||
throw SerializationError("unsupported CF_SPECIAL_COUNT");
|
||||
for (u32 i = 0; i < CF_SPECIAL_COUNT; i++)
|
||||
tiledef_special[i].deSerialize(is);
|
||||
tiledef_special[i].deSerialize(is, ignore_culling);
|
||||
alpha = readU8(is);
|
||||
post_effect_color.setAlpha(readU8(is));
|
||||
post_effect_color.setRed(readU8(is));
|
||||
@ -1324,12 +1342,12 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
|
||||
if (readU8(is) != 6)
|
||||
throw SerializationError("unsupported tile count");
|
||||
for (u32 i = 0; i < 6; i++)
|
||||
tiledef[i].deSerialize(is);
|
||||
tiledef[i].deSerialize(is, drawtype);
|
||||
// CF_SPECIAL_COUNT in version 6 = 2
|
||||
if (readU8(is) != 2)
|
||||
throw SerializationError("unsupported CF_SPECIAL_COUNT");
|
||||
for (u32 i = 0; i < 2; i++)
|
||||
tiledef_special[i].deSerialize(is);
|
||||
tiledef_special[i].deSerialize(is, drawtype);
|
||||
alpha = readU8(is);
|
||||
post_effect_color.setAlpha(readU8(is));
|
||||
post_effect_color.setRed(readU8(is));
|
||||
|
@ -137,7 +137,7 @@ struct TileDef
|
||||
}
|
||||
|
||||
void serialize(std::ostream &os, u16 protocol_version) const;
|
||||
void deSerialize(std::istream &is);
|
||||
void deSerialize(std::istream &is, bool culling_ignore);
|
||||
};
|
||||
|
||||
enum NodeDrawType
|
||||
|
Loading…
Reference in New Issue
Block a user