Skip to content

Commit 1de08e1

Browse files
committedFeb 10, 2017
Plantlike: Fix visual_scale being applied squared
This re-applies 2 commits that were reverted. Visual_scale was applied twice to plantlike by accident sometime between 2011 and 2013, squaring the requested scale value. Visual_scale is correctly applied once in it's other uses in signlike and torchlike. Two lines of code are removed, they also had no effect for the vast majority of nodes with the default visual_scale of 1.0. The texture continues to have it's base at ground level. Send sqrt(visual_scale) to old clients. 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.
1 parent bb4db84 commit 1de08e1

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed
 

Diff for: ‎src/content_mapblock.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
16021602
}
16031603

16041604
for (int i = 0; i < 4; i++) {
1605-
vertices[i].Pos *= f.visual_scale;
1606-
vertices[i].Pos.Y += BS/2 * (f.visual_scale - 1);
16071605
if (data->m_smooth_lighting)
16081606
vertices[i].Color = blendLight(frame, vertices[i].Pos, tile.color);
16091607
vertices[i].Pos += intToFloat(p, BS);

Diff for: ‎src/network/networkprotocol.h

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
146146
PROTOCOL VERSION 30:
147147
New ContentFeatures serialization version
148148
Add node and tile color and palette
149+
Fix plantlike visual_scale being applied squared and add compatibility
150+
with pre-30 clients by sending sqrt(visual_scale)
149151
*/
150152

151153
#define LATEST_PROTOCOL_VERSION 30

Diff for: ‎src/nodedef.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,10 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
16111611
compatible_param_type_2 = CPT2_WALLMOUNTED;
16121612
}
16131613

1614+
float compatible_visual_scale = visual_scale;
1615+
if (protocol_version < 30 && drawtype == NDT_PLANTLIKE)
1616+
compatible_visual_scale = sqrt(visual_scale);
1617+
16141618
if (protocol_version == 13)
16151619
{
16161620
writeU8(os, 5); // version
@@ -1622,7 +1626,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
16221626
writeS16(os, i->second);
16231627
}
16241628
writeU8(os, drawtype);
1625-
writeF1000(os, visual_scale);
1629+
writeF1000(os, compatible_visual_scale);
16261630
writeU8(os, 6);
16271631
for (u32 i = 0; i < 6; i++)
16281632
tiledef[i].serialize(os, protocol_version);
@@ -1670,7 +1674,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
16701674
writeS16(os, i->second);
16711675
}
16721676
writeU8(os, drawtype);
1673-
writeF1000(os, visual_scale);
1677+
writeF1000(os, compatible_visual_scale);
16741678
writeU8(os, 6);
16751679
for (u32 i = 0; i < 6; i++)
16761680
tiledef[i].serialize(os, protocol_version);
@@ -1724,7 +1728,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
17241728
writeS16(os, i->second);
17251729
}
17261730
writeU8(os, drawtype);
1727-
writeF1000(os, visual_scale);
1731+
writeF1000(os, compatible_visual_scale);
17281732
writeU8(os, 6);
17291733
for (u32 i = 0; i < 6; i++)
17301734
tiledef[i].serialize(os, protocol_version);

0 commit comments

Comments
 (0)
Please sign in to comment.