@@ -469,21 +469,18 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
469
469
writeU8 (os, legacy_wallmounted);
470
470
}
471
471
472
- void ContentFeatures::correctAlpha ()
472
+ void ContentFeatures::correctAlpha (TileDef *tiles, int length )
473
473
{
474
+ // alpha == 0 means that the node is using texture alpha
474
475
if (alpha == 0 || alpha == 255 )
475
476
return ;
476
477
477
- for (u32 i = 0 ; i < 6 ; i++) {
478
- std::stringstream s;
479
- s << tiledef[i].name << " ^[noalpha^[opacity:" << ((int )alpha);
480
- tiledef[i].name = s.str ();
481
- }
482
-
483
- for (u32 i = 0 ; i < CF_SPECIAL_COUNT; i++) {
478
+ for (int i = 0 ; i < length; i++) {
479
+ if (tiles[i].name == " " )
480
+ continue ;
484
481
std::stringstream s;
485
- s << tiledef_special [i].name << " ^[noalpha^[opacity:" << ((int )alpha);
486
- tiledef_special [i].name = s.str ();
482
+ s << tiles [i].name << " ^[noalpha^[opacity:" << ((int )alpha);
483
+ tiles [i].name = s.str ();
487
484
}
488
485
}
489
486
@@ -668,6 +665,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
668
665
if (tdef[j].name == " " )
669
666
tdef[j].name = " unknown_node.png" ;
670
667
}
668
+ // also the overlay tiles
669
+ TileDef tdef_overlay[6 ];
670
+ for (u32 j = 0 ; j < 6 ; j++)
671
+ tdef_overlay[j] = tiledef_overlay[j];
672
+ // also the special tiles
673
+ TileDef tdef_spec[6 ];
674
+ for (u32 j = 0 ; j < CF_SPECIAL_COUNT; j++)
675
+ tdef_spec[j] = tiledef_special[j];
671
676
672
677
bool is_liquid = false ;
673
678
@@ -720,8 +725,8 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
720
725
visual_solidness = 1 ;
721
726
} else if (tsettings.leaves_style == LEAVES_SIMPLE) {
722
727
for (u32 j = 0 ; j < 6 ; j++) {
723
- if (tiledef_special [j].name != " " )
724
- tdef[j].name = tiledef_special [j].name ;
728
+ if (tdef_spec [j].name != " " )
729
+ tdef[j].name = tdef_spec [j].name ;
725
730
}
726
731
drawtype = NDT_GLASSLIKE;
727
732
solidness = 0 ;
@@ -759,12 +764,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
759
764
break ;
760
765
}
761
766
762
- if (is_liquid)
767
+ if (is_liquid) {
768
+ // Vertex alpha is no longer supported, correct if necessary.
769
+ correctAlpha (tdef, 6 );
770
+ correctAlpha (tdef_overlay, 6 );
771
+ correctAlpha (tdef_spec, CF_SPECIAL_COUNT);
763
772
material_type = (alpha == 255 ) ?
764
773
TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT;
765
-
766
- // Vertex alpha is no longer supported, correct if necessary.
767
- correctAlpha ();
774
+ }
768
775
769
776
u32 tile_shader[6 ];
770
777
for (u16 j = 0 ; j < 6 ; j++) {
@@ -776,18 +783,18 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
776
783
for (u16 j = 0 ; j < 6 ; j++) {
777
784
fillTileAttribs (tsrc, &tiles[j].layers [0 ], &tdef[j], tile_shader[j],
778
785
tsettings.use_normal_texture ,
779
- tiledef [j].backface_culling , material_type);
780
- if (tiledef_overlay [j].name != " " )
781
- fillTileAttribs (tsrc, &tiles[j].layers [1 ], &tiledef_overlay [j],
786
+ tdef [j].backface_culling , material_type);
787
+ if (tdef_overlay [j].name != " " )
788
+ fillTileAttribs (tsrc, &tiles[j].layers [1 ], &tdef_overlay [j],
782
789
tile_shader[j], tsettings.use_normal_texture ,
783
- tiledef [j].backface_culling , material_type);
790
+ tdef [j].backface_culling , material_type);
784
791
}
785
792
786
793
// Special tiles (fill in f->special_tiles[])
787
794
for (u16 j = 0 ; j < CF_SPECIAL_COUNT; j++) {
788
- fillTileAttribs (tsrc, &special_tiles[j].layers [0 ], &tiledef_special [j],
795
+ fillTileAttribs (tsrc, &special_tiles[j].layers [0 ], &tdef_spec [j],
789
796
tile_shader[j], tsettings.use_normal_texture ,
790
- tiledef_special [j].backface_culling , material_type);
797
+ tdef_spec [j].backface_culling , material_type);
791
798
}
792
799
793
800
if (param_type_2 == CPT2_COLOR ||
0 commit comments