]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
MapNode constructor to allow ndef+name
authorPerttu Ahola <celeron55@gmail.com>
Wed, 16 Nov 2011 14:47:20 +0000 (16:47 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:47 +0000 (19:13 +0200)
src/mapnode.cpp
src/mapnode.h

index c5756e8ba207871e3ee33aa47415cc6e57b2fdd3..a757149b10612925093837750b52a9a0d43f5599 100644 (file)
@@ -155,6 +155,20 @@ v3s16 unpackDir(u8 b)
        MapNode
 */
 
+// Create directly from a nodename
+// If name is unknown, sets CONTENT_IGNORE
+MapNode::MapNode(INodeDefManager *ndef, const std::string &name,
+               u8 a_param1, u8 a_param2)
+{
+       content_t id = CONTENT_IGNORE;
+       ndef->getId(name, id);
+       param1 = a_param1;
+       param2 = a_param2;
+       // Set content (param0 and (param2&0xf0)) after other params
+       // because this needs to override part of param2
+       setContent(id);
+}
+
 void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
 {
        // If node doesn't contain light data, ignore this
index 285f197db995bd7a47dac0783b79736808e29d9e..e287ea54fec9f6137489bf34362a83de14115aa2 100644 (file)
@@ -147,6 +147,11 @@ struct MapNode
                // because this needs to override part of param2
                setContent(content);
        }
+       
+       // Create directly from a nodename
+       // If name is unknown, sets CONTENT_IGNORE
+       MapNode(INodeDefManager *ndef, const std::string &name,
+                       u8 a_param1=0, u8 a_param2=0);
 
        bool operator==(const MapNode &other)
        {