]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/nodedef.cpp
Fix player:set_animation() in third person view
[dragonfireclient.git] / src / nodedef.cpp
index a4d0368830007d92765cadc8f0ee5f95f25fdb4e..2b6de0461b14e505918d050b66152722b84bf1ee 100644 (file)
@@ -46,10 +46,15 @@ void NodeBox::reset()
        wall_side = aabb3f(-BS/2, -BS/2, -BS/2, -BS/2+BS/16., BS/2, BS/2);
 }
 
-void NodeBox::serialize(std::ostream &os) const
+void NodeBox::serialize(std::ostream &os, u16 protocol_version) const
 {
-       writeU8(os, 1); // version
-       writeU8(os, type);
+       int version = protocol_version >= 21 ? 2 : 1;
+       writeU8(os, version);
+
+       if (version == 1 && type == NODEBOX_LEVELED)
+               writeU8(os, NODEBOX_FIXED);
+       else
+               writeU8(os, type);
 
        if(type == NODEBOX_FIXED || type == NODEBOX_LEVELED)
        {
@@ -76,7 +81,7 @@ void NodeBox::serialize(std::ostream &os) const
 void NodeBox::deSerialize(std::istream &is)
 {
        int version = readU8(is);
-       if(version != 1)
+       if(version < 1 || version > 2)
                throw SerializationError("unsupported NodeBox version");
 
        reset();
@@ -213,12 +218,14 @@ void ContentFeatures::reset()
        liquid_alternative_source = "";
        liquid_viscosity = 0;
        liquid_renewable = true;
+       freezemelt = "";
        liquid_range = LIQUID_LEVEL_MAX+1;
-       drowning = true;
+       drowning = 0;
        light_source = 0;
        damage_per_second = 0;
        node_box = NodeBox();
        selection_box = NodeBox();
+       waving = 0;
        legacy_facedir_simple = false;
        legacy_wallmounted = false;
        sound_footstep = SimpleSoundSpec();
@@ -273,8 +280,8 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
        writeU8(os, liquid_renewable);
        writeU8(os, light_source);
        writeU32(os, damage_per_second);
-       node_box.serialize(os);
-       selection_box.serialize(os);
+       node_box.serialize(os, protocol_version);
+       selection_box.serialize(os, protocol_version);
        writeU8(os, legacy_facedir_simple);
        writeU8(os, legacy_wallmounted);
        serializeSimpleSoundSpec(sound_footstep, os);
@@ -286,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)
@@ -353,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) {};
 }
 
@@ -390,15 +399,16 @@ class CNodeDefManager: public IWritableNodeDefManager
                // Set CONTENT_AIR
                {
                        ContentFeatures f;
-                       f.name = "air";
-                       f.drawtype = NDT_AIRLIKE;
-                       f.param_type = CPT_LIGHT;
-                       f.light_propagates = true;
+                       f.name                = "air";
+                       f.drawtype            = NDT_AIRLIKE;
+                       f.param_type          = CPT_LIGHT;
+                       f.light_propagates    = true;
                        f.sunlight_propagates = true;
-                       f.walkable = false;
-                       f.pointable = false;
-                       f.diggable = false;
-                       f.buildable_to = true;
+                       f.walkable            = false;
+                       f.pointable           = false;
+                       f.diggable            = false;
+                       f.buildable_to        = true;
+                       f.is_ground_content   = true;
                        // Insert directly into containers
                        content_t c = CONTENT_AIR;
                        m_content_features[c] = f;
@@ -408,16 +418,16 @@ class CNodeDefManager: public IWritableNodeDefManager
                // Set CONTENT_IGNORE
                {
                        ContentFeatures f;
-                       f.name = "ignore";
-                       f.drawtype = NDT_AIRLIKE;
-                       f.param_type = CPT_NONE;
-                       f.light_propagates = false;
+                       f.name                = "ignore";
+                       f.drawtype            = NDT_AIRLIKE;
+                       f.param_type          = CPT_NONE;
+                       f.light_propagates    = false;
                        f.sunlight_propagates = false;
-                       f.walkable = false;
-                       f.pointable = false;
-                       f.diggable = false;
-                       // A way to remove accidental CONTENT_IGNOREs
-                       f.buildable_to = true;
+                       f.walkable            = false;
+                       f.pointable           = false;
+                       f.diggable            = false;
+                       f.buildable_to        = true; // A way to remove accidental CONTENT_IGNOREs
+                       f.is_ground_content   = true;
                        // Insert directly into containers
                        content_t c = CONTENT_IGNORE;
                        m_content_features[c] = f;
@@ -611,6 +621,9 @@ class CNodeDefManager: public IWritableNodeDefManager
                        }
 
                        bool is_liquid = false;
+                       u8 material_type;
+                       material_type = (f->alpha == 255) ? TILE_MATERIAL_BASIC : TILE_MATERIAL_ALPHA;
+
                        switch(f->drawtype){
                        default:
                        case NDT_NORMAL:
@@ -662,10 +675,14 @@ class CNodeDefManager: public IWritableNodeDefManager
                                                tiledef[i].name += std::string("^[noalpha");
                                        }
                                }
+                               if (f->waving == 1)
+                                       material_type = TILE_MATERIAL_LEAVES;
                                break;
                        case NDT_PLANTLIKE:
                                f->solidness = 0;
                                f->backface_culling = false;
+                               if (f->waving == 1)
+                                       material_type = TILE_MATERIAL_PLANTS;
                                break;
                        case NDT_TORCHLIKE:
                        case NDT_SIGNLIKE:
@@ -676,11 +693,8 @@ class CNodeDefManager: public IWritableNodeDefManager
                                break;
                        }
 
-                       u8 material_type;
                        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;
 
                        // Tiles (fill in f->tiles[])
                        for(u16 j=0; j<6; j++){
@@ -917,8 +931,8 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
                writeU8(os, liquid_viscosity);
                writeU8(os, light_source);
                writeU32(os, damage_per_second);
-               node_box.serialize(os);
-               selection_box.serialize(os);
+               node_box.serialize(os, protocol_version);
+               selection_box.serialize(os, protocol_version);
                writeU8(os, legacy_facedir_simple);
                writeU8(os, legacy_wallmounted);
                serializeSimpleSoundSpec(sound_footstep, os);