Fix sqlite3 map shutdown fails due to missing to finalize list statement
[oweals/minetest.git] / src / nodedef.cpp
index d13d0653daeed31f7aa23053f971078b167b89a9..d009a952359709d8278ed3664caa8fe4845ad78b 100644 (file)
@@ -225,6 +225,7 @@ void ContentFeatures::reset()
        damage_per_second = 0;
        node_box = NodeBox();
        selection_box = NodeBox();
+       waving = 0;
        legacy_facedir_simple = false;
        legacy_wallmounted = false;
        sound_footstep = SimpleSoundSpec();
@@ -292,6 +293,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
        writeU8(os, liquid_range);
        // Stuff below should be moved to correct place in a version that otherwise changes
        // the protocol version
+       writeU8(os, waving);
 }
 
 void ContentFeatures::deSerialize(std::istream &is)
@@ -359,6 +361,7 @@ void ContentFeatures::deSerialize(std::istream &is)
        try{
                // Stuff below should be moved to correct place in a version that
                // otherwise changes the protocol version
+       waving = readU8(is);
        }catch(SerializationError &e) {};
 }
 
@@ -594,7 +597,8 @@ public:
                        }
                }
        }
-       virtual void updateTextures(ITextureSource *tsrc)
+       virtual void updateTextures(ITextureSource *tsrc,
+               IShaderSource *shdsrc)
        {
 #ifndef SERVER
                infostream<<"CNodeDefManager::updateTextures(): Updating "
@@ -618,6 +622,11 @@ public:
                        }
 
                        bool is_liquid = false;
+                       bool is_water_surface = false;
+
+                       u8 material_type;
+                       material_type = (f->alpha == 255) ? TILE_MATERIAL_BASIC : TILE_MATERIAL_ALPHA;
+
                        switch(f->drawtype){
                        default:
                        case NDT_NORMAL:
@@ -669,10 +678,14 @@ public:
                                                tiledef[i].name += std::string("^[noalpha");
                                        }
                                }
+                               if (f->waving == 1)
+                                       material_type = TILE_MATERIAL_WAVING_LEAVES;
                                break;
                        case NDT_PLANTLIKE:
                                f->solidness = 0;
                                f->backface_culling = false;
+                               if (f->waving == 1)
+                                       material_type = TILE_MATERIAL_WAVING_PLANTS;
                                break;
                        case NDT_TORCHLIKE:
                        case NDT_SIGNLIKE:
@@ -683,14 +696,22 @@ public:
                                break;
                        }
 
-                       u8 material_type;
-                       if (is_liquid)
+                       if (is_liquid){
                                material_type = (f->alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT;
-                       else
-                               material_type = (f->alpha == 255) ? TILE_MATERIAL_BASIC : TILE_MATERIAL_ALPHA;
+                               if (f->name == "default:water_source")
+                                       is_water_surface = true;
+                       }
+                       u32 tile_shader[6];
+                       for(u16 j=0; j<6; j++)
+                               tile_shader[j] = shdsrc->getShader("nodes_shader",material_type, f->drawtype);
+
+                       if (is_water_surface)
+                               tile_shader[0] = shdsrc->getShader("water_surface_shader",material_type, f->drawtype);
 
                        // Tiles (fill in f->tiles[])
                        for(u16 j=0; j<6; j++){
+                               // Shader
+                               f->tiles[j].shader_id = tile_shader[j];
                                // Texture
                                f->tiles[j].texture = tsrc->getTexture(
                                                tiledef[j].name,
@@ -733,6 +754,8 @@ public:
                        }
                        // Special tiles (fill in f->special_tiles[])
                        for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
+                               // Shader
+                               f->special_tiles[j].shader_id = tile_shader[j];
                                // Texture
                                f->special_tiles[j].texture = tsrc->getTexture(
                                                f->tiledef_special[j].name,