Skip to content

Commit

Permalink
Plantlike visual scale: Send sqrt(visual_scale) to old clients
Browse files Browse the repository at this point in the history
Keep compatibility with protocol < 30 clients now that visual_scale
is no longer applied twice to plantlike drawtype and mods are being
updated to a new value.
  • Loading branch information
paramat committed Jan 30, 2017
1 parent e761b9f commit cdc538e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/network/networkprotocol.h
Expand Up @@ -146,6 +146,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
PROTOCOL VERSION 30:
New ContentFeatures serialization version
Add node and tile color and palette
Fix plantlike visual_scale being applied squared and add compatibility
with pre-30 clients by sending sqrt(visual_scale)
*/

#define LATEST_PROTOCOL_VERSION 30
Expand Down
10 changes: 7 additions & 3 deletions src/nodedef.cpp
Expand Up @@ -1611,6 +1611,10 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
compatible_param_type_2 = CPT2_WALLMOUNTED;
}

float compatible_visual_scale = visual_scale;
if (protocol_version < 30 && drawtype == NDT_PLANTLIKE)
compatible_visual_scale = sqrt(visual_scale);

if (protocol_version == 13)
{
writeU8(os, 5); // version
Expand All @@ -1622,7 +1626,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, visual_scale);
writeF1000(os, compatible_visual_scale);
writeU8(os, 6);
for (u32 i = 0; i < 6; i++)
tiledef[i].serialize(os, protocol_version);
Expand Down Expand Up @@ -1670,7 +1674,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, visual_scale);
writeF1000(os, compatible_visual_scale);
writeU8(os, 6);
for (u32 i = 0; i < 6; i++)
tiledef[i].serialize(os, protocol_version);
Expand Down Expand Up @@ -1724,7 +1728,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, visual_scale);
writeF1000(os, compatible_visual_scale);
writeU8(os, 6);
for (u32 i = 0; i < 6; i++)
tiledef[i].serialize(os, protocol_version);
Expand Down

0 comments on commit cdc538e

Please sign in to comment.