Mess up with node definitions to make CONTENT_IGNORE be correctly interpreted when...
authorPerttu Ahola <celeron55@gmail.com>
Sat, 19 Nov 2011 17:06:19 +0000 (19:06 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:49 +0000 (19:13 +0200)
src/nodedef.cpp

index de724659bd3af5a927240b9096f0101556def221..0e48c8c07aaa99ba84b6f23ba4ee916e497135ea 100644 (file)
@@ -347,13 +347,13 @@ public:
                        ContentFeatures f;
                        f.name = "ignore";
                        f.drawtype = NDT_AIRLIKE;
-                       f.param_type = CPT_LIGHT;
+                       /*f.param_type = CPT_LIGHT;
                        f.light_propagates = true;
-                       f.sunlight_propagates = true;
+                       f.sunlight_propagates = true;*/
                        f.walkable = false;
                        f.pointable = false;
                        f.diggable = false;
-                       f.buildable_to = true;
+                       f.buildable_to = false;
                        f.air_equivalent = true;
                        set(CONTENT_IGNORE, f);
                }
@@ -424,6 +424,15 @@ public:
                infostream<<"registerNode: registering content id \""<<c
                                <<"\": name=\""<<def.name<<"\""<<std::endl;
                assert(c <= MAX_CONTENT);
+               // Check that the special contents are not redefined as different id
+               // because it would mess up everything
+               if((def.name == "ignore" && c != CONTENT_IGNORE) ||
+                       (def.name == "air" && c != CONTENT_AIR)){
+                       errorstream<<"registerNode: IGNORING ERROR: "
+                                       <<"trying to register built-in type \""
+                                       <<def.name<<"\" as different id"<<std::endl;
+                       return;
+               }
                m_content_features[c] = def;
                if(def.name != "")
                        m_name_id_mapping.set(c, def.name);
@@ -615,6 +624,9 @@ public:
                                                <<"Too large content id: "<<i<<std::endl;
                                continue;
                        }
+                       /*// Do not deserialize special types
+                       if(i == CONTENT_IGNORE || i == CONTENT_AIR)
+                               continue;*/
                        ContentFeatures *f = &m_content_features[i];
                        f->deSerialize(tmp_is, gamedef);
                        if(f->name != "")