]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapblock_mesh.cpp
Fix some "Conditional jump or move depends on uninitialised value(s)" valgrind detections
[minetest.git] / src / mapblock_mesh.cpp
index bcbf374188cee72b0f1c9669d07da3f14f27df5d..2bee572f04169c43221a22b3237d7fd60d17f10c 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "main.h" // For g_settings and g_texturesource
 #include "content_mapblock.h"
+#include "settings.h"
 
 void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block)
 {
@@ -151,7 +152,7 @@ video::SColor MapBlock_LightColor(u8 alpha, u8 light)
 #if 1
        // Emphase blue a bit in darker places
        float lim = 80;
-       float power = 0.7;
+       float power = 0.8;
        if(light > lim)
                return video::SColor(alpha,light,light,light);
        else
@@ -300,7 +301,7 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
        return spec;
 }
 
-u8 getNodeContent(v3s16 p, MapNode mn, NodeModMap &temp_mods)
+content_t getNodeContent(v3s16 p, MapNode mn, NodeModMap &temp_mods)
 {
        /*
                Check temporary modifications on this node
@@ -335,7 +336,7 @@ u8 getNodeContent(v3s16 p, MapNode mn, NodeModMap &temp_mods)
                }
        }
 
-       return mn.d;
+       return mn.getContent();
 }
 
 v3s16 dirs8[8] = {
@@ -358,16 +359,16 @@ u8 getSmoothLight(v3s16 p, VoxelManipulator &vmanip, u32 daynight_ratio)
        for(u32 i=0; i<8; i++)
        {
                MapNode n = vmanip.getNodeNoEx(p - dirs8[i]);
-               if(content_features(n.d).param_type == CPT_LIGHT
+               if(content_features(n).param_type == CPT_LIGHT
                                // Fast-style leaves look better this way
-                               && content_features(n.d).solidness != 2)
+                               && content_features(n).solidness != 2)
                {
                        light += decode_light(n.getLightBlend(daynight_ratio));
                        light_count++;
                }
                else
                {
-                       if(n.d != CONTENT_IGNORE)
+                       if(n.getContent() != CONTENT_IGNORE)
                                ambient_occlusion++;
                }
        }
@@ -423,8 +424,8 @@ void getTileInfo(
        TileSpec tile1 = getNodeTile(n1, p + face_dir, -face_dir, temp_mods);
        
        // This is hackish
-       u8 content0 = getNodeContent(p, n0, temp_mods);
-       u8 content1 = getNodeContent(p + face_dir, n1, temp_mods);
+       content_t content0 = getNodeContent(p, n0, temp_mods);
+       content_t content1 = getNodeContent(p + face_dir, n1, temp_mods);
        u8 mf = face_contents(content0, content1);
 
        if(mf == 0)
@@ -491,10 +492,10 @@ void updateFastFaceRow(
        
        u16 continuous_tiles_count = 0;
        
-       bool makes_face;
+       bool makes_face = false;
        v3s16 p_corrected;
        v3s16 face_dir_corrected;
-       u8 lights[4];
+       u8 lights[4] = {0,0,0,0};
        TileSpec tile;
        getTileInfo(blockpos_nodes, p, face_dir, daynight_ratio,
                        vmanip, temp_mods, smooth_lighting,
@@ -619,9 +620,9 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
        /*
                Some settings
        */
-       //bool new_style_water = g_settings.getBool("new_style_water");
-       //bool new_style_leaves = g_settings.getBool("new_style_leaves");
-       bool smooth_lighting = g_settings.getBool("smooth_lighting");
+       //bool new_style_water = g_settings->getBool("new_style_water");
+       //bool new_style_leaves = g_settings->getBool("new_style_leaves");
+       bool smooth_lighting = g_settings->getBool("smooth_lighting");
        
        /*
                We are including the faces of the trailing edges of the block.