]> git.lizzy.rs Git - minetest.git/blobdiff - src/nodedef.cpp
small drawItemStack cleanup
[minetest.git] / src / nodedef.cpp
index 269c2b9d69430f3b94fd40a2c34601e16a65b250..e30cf6f12f92f0e2d4df2772eb25c1de61dce6b3 100644 (file)
@@ -65,7 +65,7 @@ void NodeBox::serialize(std::ostream &os, u16 protocol_version) const
                writeU16(os, fixed.size());
                for(std::vector<aabb3f>::const_iterator
                                i = fixed.begin();
-                               i != fixed.end(); i++)
+                               i != fixed.end(); ++i)
                {
                        writeV3F1000(os, i->MinEdge);
                        writeV3F1000(os, i->MaxEdge);
@@ -139,7 +139,7 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
        }
 }
 
-void TileDef::deSerialize(std::istream &is)
+void TileDef::deSerialize(std::istream &is, bool culling_ignore)
 {
        int version = readU8(is);
        name = deSerializeString(is);
@@ -153,6 +153,11 @@ void TileDef::deSerialize(std::istream &is)
                tileable_horizontal = readU8(is);
                tileable_vertical = readU8(is);
        }
+       // when connecting to old servers - do not use
+       // provided values here since culling needs to be
+       // disabled by default for these drawtypes
+       if (culling_ignore)
+               backface_culling = false;
 }
 
 
@@ -233,6 +238,7 @@ void ContentFeatures::reset()
        diggable = true;
        climbable = false;
        buildable_to = false;
+       floodable = false;
        rightclickable = true;
        leveled = 0;
        liquid_type = LIQUID_NONE;
@@ -266,7 +272,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
        os<<serializeString(name);
        writeU16(os, groups.size());
        for(ItemGroupList::const_iterator
-                       i = groups.begin(); i != groups.end(); i++){
+                       i = groups.begin(); i != groups.end(); ++i){
                os<<serializeString(i->first);
                writeS16(os, i->second);
        }
@@ -318,6 +324,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
        // the protocol version
        os<<serializeString(mesh);
        collision_box.serialize(os, protocol_version);
+       writeU8(os, floodable);
 }
 
 void ContentFeatures::deSerialize(std::istream &is)
@@ -337,15 +344,22 @@ void ContentFeatures::deSerialize(std::istream &is)
                groups[name] = value;
        }
        drawtype = (enum NodeDrawType)readU8(is);
+
+       bool ignore_culling = ((version <= 26) &&
+                       ((drawtype == NDT_MESH) ||
+                        (drawtype == NDT_PLANTLIKE) ||
+                        (drawtype == NDT_FIRELIKE) ||
+                        (drawtype == NDT_LIQUID)));
+
        visual_scale = readF1000(is);
        if(readU8(is) != 6)
                throw SerializationError("unsupported tile count");
        for(u32 i = 0; i < 6; i++)
-               tiledef[i].deSerialize(is);
+               tiledef[i].deSerialize(is, ignore_culling);
        if(readU8(is) != CF_SPECIAL_COUNT)
                throw SerializationError("unsupported CF_SPECIAL_COUNT");
        for(u32 i = 0; i < CF_SPECIAL_COUNT; i++)
-               tiledef_special[i].deSerialize(is);
+               tiledef_special[i].deSerialize(is, ignore_culling);
        alpha = readU8(is);
        post_effect_color.setAlpha(readU8(is));
        post_effect_color.setRed(readU8(is));
@@ -388,6 +402,7 @@ void ContentFeatures::deSerialize(std::istream &is)
                // otherwise changes the protocol version
        mesh = deSerializeString(is);
        collision_box.deSerialize(is);
+       floodable = readU8(is);
        }catch(SerializationError &e) {};
 }
 
@@ -520,6 +535,7 @@ void CNodeDefManager::clear()
                f.pointable           = false;
                f.diggable            = false;
                f.buildable_to        = true;
+               f.floodable           = true;
                f.is_ground_content   = true;
                // Insert directly into containers
                content_t c = CONTENT_AIR;
@@ -653,7 +669,7 @@ content_t CNodeDefManager::set(const std::string &name, const ContentFeatures &d
 
        // Don't allow redefining ignore (but allow air and unknown)
        if (name == "ignore") {
-               infostream << "NodeDefManager: WARNING: Ignoring "
+               warningstream << "NodeDefManager: Ignoring "
                        "CONTENT_IGNORE redefinition"<<std::endl;
                return CONTENT_IGNORE;
        }
@@ -663,7 +679,7 @@ content_t CNodeDefManager::set(const std::string &name, const ContentFeatures &d
                // Get new id
                id = allocateId();
                if (id == CONTENT_IGNORE) {
-                       infostream << "NodeDefManager: WARNING: Absolute "
+                       warningstream << "NodeDefManager: Absolute "
                                "limit reached" << std::endl;
                        return CONTENT_IGNORE;
                }
@@ -709,7 +725,7 @@ void CNodeDefManager::updateAliases(IItemDefManager *idef)
        std::set<std::string> all = idef->getAll();
        m_name_id_mapping_with_aliases.clear();
        for (std::set<std::string>::iterator
-                       i = all.begin(); i != all.end(); i++) {
+                       i = all.begin(); i != all.end(); ++i) {
                std::string name = *i;
                std::string convert_to = idef->getAlias(name);
                content_t id;
@@ -839,12 +855,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
                        assert(f->liquid_type == LIQUID_SOURCE);
                        if (opaque_water)
                                f->alpha = 255;
-                       if (new_style_water){
-                               f->solidness = 0;
-                       } else {
-                               f->solidness = 1;
-                               f->backface_culling = false;
-                       }
+                       f->solidness = new_style_water ? 0 : 1;
                        is_liquid = true;
                        break;
                case NDT_FLOWINGLIQUID:
@@ -895,17 +906,14 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
                        break;
                case NDT_PLANTLIKE:
                        f->solidness = 0;
-                       f->backface_culling = false;
                        if (f->waving == 1)
                                material_type = TILE_MATERIAL_WAVING_PLANTS;
                        break;
                case NDT_FIRELIKE:
-                       f->backface_culling = false;
                        f->solidness = 0;
                        break;
                case NDT_MESH:
                        f->solidness = 0;
-                       f->backface_culling = false;
                        break;
                case NDT_TORCHLIKE:
                case NDT_SIGNLIKE:
@@ -937,7 +945,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
                // Tiles (fill in f->tiles[])
                for (u16 j = 0; j < 6; j++) {
                        fillTileAttribs(tsrc, &f->tiles[j], &tiledef[j], tile_shader[j],
-                               use_normal_texture, f->backface_culling, f->alpha, material_type);
+                               use_normal_texture, f->tiledef[j].backface_culling, f->alpha, material_type);
                }
 
                // Special tiles (fill in f->special_tiles[])
@@ -1112,12 +1120,12 @@ void CNodeDefManager::deSerialize(std::istream &is)
 
                // Check error conditions
                if (i == CONTENT_IGNORE || i == CONTENT_AIR || i == CONTENT_UNKNOWN) {
-                       infostream << "NodeDefManager::deSerialize(): WARNING: "
+                       warningstream << "NodeDefManager::deSerialize(): "
                                "not changing builtin node " << i << std::endl;
                        continue;
                }
                if (f.name == "") {
-                       infostream << "NodeDefManager::deSerialize(): WARNING: "
+                       warningstream << "NodeDefManager::deSerialize(): "
                                "received empty name" << std::endl;
                        continue;
                }
@@ -1125,7 +1133,7 @@ void CNodeDefManager::deSerialize(std::istream &is)
                // Ignore aliases
                u16 existing_id;
                if (m_name_id_mapping.getId(f.name, existing_id) && i != existing_id) {
-                       infostream << "NodeDefManager::deSerialize(): WARNING: "
+                       warningstream << "NodeDefManager::deSerialize(): "
                                "already defined with different ID: " << f.name << std::endl;
                        continue;
                }
@@ -1162,7 +1170,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
                os<<serializeString(name);
                writeU16(os, groups.size());
                for (ItemGroupList::const_iterator
-                               i = groups.begin(); i != groups.end(); i++) {
+                               i = groups.begin(); i != groups.end(); ++i) {
                        os<<serializeString(i->first);
                        writeS16(os, i->second);
                }
@@ -1210,7 +1218,7 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
                os<<serializeString(name);
                writeU16(os, groups.size());
                for (ItemGroupList::const_iterator
-                       i = groups.begin(); i != groups.end(); i++) {
+                       i = groups.begin(); i != groups.end(); ++i) {
                                os<<serializeString(i->first);
                                writeS16(os, i->second);
                }
@@ -1262,7 +1270,6 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
                        "Unsupported version requested");
 }
 
-
 void ContentFeatures::deSerializeOld(std::istream &is, int version)
 {
        if (version == 5) // In PROTOCOL_VERSION 13
@@ -1276,15 +1283,22 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
                        groups[name] = value;
                }
                drawtype = (enum NodeDrawType)readU8(is);
+
+               bool ignore_culling = ((version <= 26) &&
+                               ((drawtype == NDT_MESH) ||
+                               (drawtype == NDT_PLANTLIKE) ||
+                               (drawtype == NDT_FIRELIKE) ||
+                               (drawtype == NDT_LIQUID)));
+
                visual_scale = readF1000(is);
                if (readU8(is) != 6)
                        throw SerializationError("unsupported tile count");
                for (u32 i = 0; i < 6; i++)
-                       tiledef[i].deSerialize(is);
+                       tiledef[i].deSerialize(is, ignore_culling);
                if (readU8(is) != CF_SPECIAL_COUNT)
                        throw SerializationError("unsupported CF_SPECIAL_COUNT");
                for (u32 i = 0; i < CF_SPECIAL_COUNT; i++)
-                       tiledef_special[i].deSerialize(is);
+                       tiledef_special[i].deSerialize(is, ignore_culling);
                alpha = readU8(is);
                post_effect_color.setAlpha(readU8(is));
                post_effect_color.setRed(readU8(is));
@@ -1328,12 +1342,12 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
                if (readU8(is) != 6)
                        throw SerializationError("unsupported tile count");
                for (u32 i = 0; i < 6; i++)
-                       tiledef[i].deSerialize(is);
+                       tiledef[i].deSerialize(is, drawtype);
                // CF_SPECIAL_COUNT in version 6 = 2
                if (readU8(is) != 2)
                        throw SerializationError("unsupported CF_SPECIAL_COUNT");
                for (u32 i = 0; i < 2; i++)
-                       tiledef_special[i].deSerialize(is);
+                       tiledef_special[i].deSerialize(is, drawtype);
                alpha = readU8(is);
                post_effect_color.setAlpha(readU8(is));
                post_effect_color.setRed(readU8(is));