Cleanup (some stuff went wrong when reverting 4-byte mapnodes); fix legacy_wallmounted
authorKahrl <kahrl@gmx.net>
Sun, 22 Jan 2012 13:55:55 +0000 (14:55 +0100)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 22 Jan 2012 15:31:20 +0000 (17:31 +0200)
src/mapblock.cpp
src/mapnode.cpp
src/mapnode.h
src/nodedef.cpp

index fb3bbf7a7fb466c8316ed791132befc537714b15..b436378da5a2cbc3f4f907fbabcee7e860640e6a 100644 (file)
@@ -1157,28 +1157,24 @@ void MapBlock::deSerialize_pre22(std::istream &is, u8 version, bool disk)
                if(nodedef->getId("default:stone") == data[i].getContent()
                                && data[i].getParam1() == 1)
                {
-                       //dstream << "legacy coal\n";
                        data[i].setContent(nodedef->getId("default:stone_with_coal"));
                        data[i].setParam1(0);
                }
                else if(nodedef->getId("default:stone") == data[i].getContent()
                                && data[i].getParam1() == 2)
                {
-                       //dstream << "legacy iron\n";
                        data[i].setContent(nodedef->getId("default:stone_with_iron"));
                        data[i].setParam1(0);
                }
                // facedir_simple
                if(f.legacy_facedir_simple)
                {
-                       dstream << "legacy_facedir_simple\n";
                        data[i].setParam2(data[i].getParam1());
                        data[i].setParam1(0);
                }
                // wall_mounted
                if(f.legacy_wallmounted)
                {
-                       dstream << "legacy_wallmounted\n";
                        u8 wallmounted_new_to_old[8] = {0x04, 0x08, 0x01, 0x02, 0x10, 0x20, 0, 0};
                        u8 dir_old_format = data[i].getParam2();
                        u8 dir_new_format = 0;
index bfadbeac5ddbe919dac889322be71e23d62426b3..6cb9671b51b998671a920cdfa24f801f1677043b 100644 (file)
@@ -291,31 +291,31 @@ void MapNode::serialize_pre22(u8 *dest, u8 version)
        // Translate to wanted version
        MapNode n_foreign = mapnode_translate_from_internal(*this, version);
 
-       u16 actual_content = n_foreign.param0;
+       u8 actual_param0 = n_foreign.param0;
 
        // Convert special values from new version to old
        if(version <= 18)
        {
                // In these versions, CONTENT_IGNORE and CONTENT_AIR
                // are 255 and 254
-               if(actual_content == CONTENT_IGNORE)
-                       actual_content = 255;
-               else if(actual_content == CONTENT_AIR)
-                       actual_content = 254;
+               if(actual_param0 == CONTENT_IGNORE)
+                       actual_param0 = 255;
+               else if(actual_param0 == CONTENT_AIR)
+                       actual_param0 = 254;
        }
 
        if(version == 0)
        {
-               dest[0] = actual_content;
+               dest[0] = actual_param0;
        }
        else if(version <= 9)
        {
-               dest[0] = actual_content;
+               dest[0] = actual_param0;
                dest[1] = n_foreign.param1;
        }
        else
        {
-               dest[0] = actual_content;
+               dest[0] = actual_param0;
                dest[1] = n_foreign.param1;
                dest[2] = n_foreign.param2;
        }
index 1c75f39c57e6361bfcd855e2f4f93907963ce6f9..5e066604bfc00ddc02bd23b7cd4b9739effb399d 100644 (file)
@@ -112,7 +112,7 @@ struct MapNode
        {
                param1 = a_param1;
                param2 = a_param2;
-               // Set content (param0 and param2&0xf0)) after other params
+               // Set content (param0 and (param2&0xf0)) after other params
                // because this needs to override part of param2
                setContent(content);
        }
index 3d85bdbd92a557f032151f7a081d3b5b6fd3876d..0c2793a0ea04a456a58a1bfea18511f1f6add4b8 100644 (file)
@@ -394,6 +394,8 @@ public:
                                def.param_type_2 == CPT2_FULL
                                ||
                                def.param_type_2 == CPT2_FLOWINGLIQUID
+                               ||
+                               def.legacy_wallmounted
                        );
                        // Get some id
                        id = getFreeId(require_full_param2);