ServerRemotePlayer implements ServerActiveObject
[oweals/minetest.git] / src / mapnode.cpp
index 956abe5c714b86d36f828f31beb20ae030f42c7e..f816319999e1c30196c0b066f5aa83a45f55800a 100644 (file)
@@ -19,7 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "common_irrlicht.h"
 #include "mapnode.h"
+#ifndef SERVER
 #include "tile.h"
+#endif
 #include "porting.h"
 #include <string>
 #include "mineral.h"
@@ -31,12 +33,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 ContentFeatures::~ContentFeatures()
 {
        delete initial_metadata;
+#ifndef SERVER
        delete special_material;
        delete special_atlas;
+#endif
 }
 
+#ifndef SERVER
 void ContentFeatures::setTexture(u16 i, std::string name, u8 alpha)
 {
+       used_texturenames[name] = true;
+       
        if(g_texturesource)
        {
                tiles[i].texture = g_texturesource->getTexture(name);
@@ -81,6 +88,7 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
        imgname_full += right;
        inventory_texture = g_texturesource->getTextureRaw(imgname_full);
 }
+#endif
 
 struct ContentFeatures g_content_features[MAX_CONTENT+1];
 
@@ -118,7 +126,8 @@ void init_mapnode()
        /*
                Initialize content feature table
        */
-       
+
+#ifndef SERVER
        /*
                Set initial material type to same in all tiles, so that the
                same material can be used in more stuff.
@@ -140,6 +149,7 @@ void init_mapnode()
                for(u16 j=0; j<6; j++)
                        f->tiles[j].material_type = initial_material_type;
        }
+#endif
 
        /*
                Initially set every block to be shown as an unknown block.
@@ -154,6 +164,9 @@ void init_mapnode()
                f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
        }
 
+       // Make CONTENT_IGNORE to not block the view when occlusion culling
+       content_features(CONTENT_IGNORE).solidness = 0;
+
        /*
                Initialize mapnode content
        */
@@ -161,6 +174,57 @@ void init_mapnode()
        
 }
 
+/*
+       Nodes make a face if contents differ and solidness differs.
+       Return value:
+               0: No face
+               1: Face uses m1's content
+               2: Face uses m2's content
+       equivalent: Whether the blocks share the same face (eg. water and glass)
+*/
+u8 face_contents(content_t m1, content_t m2, bool *equivalent)
+{
+       *equivalent = false;
+
+       if(m1 == CONTENT_IGNORE || m2 == CONTENT_IGNORE)
+               return 0;
+       
+       bool contents_differ = (m1 != m2);
+       
+       // Contents don't differ for different forms of same liquid
+       if(content_liquid(m1) && content_liquid(m2)
+                       && make_liquid_flowing(m1) == make_liquid_flowing(m2))
+               contents_differ = false;
+       
+       u8 c1 = content_solidness(m1);
+       u8 c2 = content_solidness(m2);
+
+       bool solidness_differs = (c1 != c2);
+       bool makes_face = contents_differ && solidness_differs;
+
+       if(makes_face == false)
+               return 0;
+       
+       if(c1 == 0)
+               c1 = content_features(m1).visual_solidness;
+       if(c2 == 0)
+               c2 = content_features(m2).visual_solidness;
+       
+       if(c1 == c2){
+               *equivalent = true;
+               // If same solidness, liquid takes precense
+               if(content_features(m1).liquid_type != LIQUID_NONE)
+                       return 1;
+               if(content_features(m2).liquid_type != LIQUID_NONE)
+                       return 2;
+       }
+       
+       if(c1 > c2)
+               return 1;
+       else
+               return 2;
+}
+
 v3s16 facedir_rotate(u8 facedir, v3s16 dir)
 {
        /*
@@ -184,6 +248,7 @@ v3s16 facedir_rotate(u8 facedir, v3s16 dir)
        return newdir;
 }
 
+#ifndef SERVER
 TileSpec MapNode::getTile(v3s16 dir)
 {
        if(content_features(*this).param_type == CPT_FACEDIR_SIMPLE)
@@ -235,6 +300,7 @@ TileSpec MapNode::getTile(v3s16 dir)
 
        return spec;
 }
+#endif
 
 u8 MapNode::getMineral()
 {