]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Create empty default constructor for MapNode
authorCraig Robbins <kde.psych@gmail.com>
Sat, 17 Jan 2015 09:19:26 +0000 (19:19 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Sun, 18 Jan 2015 03:39:50 +0000 (13:39 +1000)
src/map.cpp
src/map.h
src/mapnode.h
src/test.cpp
src/voxel.cpp

index fdc35558d342f1707f5383c4fbc121c557172b0b..52303cd38e7527d6cdff94657cbbbca9f4dac51b 100644 (file)
@@ -1189,8 +1189,7 @@ void Map::removeNodeAndUpdate(v3s16 p,
                This also clears the lighting.
        */
 
-       MapNode n;
-       n.setContent(replace_material);
+       MapNode n(replace_material);
        setNode(p, n);
 
        for(s32 i=0; i<2; i++)
@@ -1603,6 +1602,16 @@ struct NodeNeighbor {
        NeighborType t;
        v3s16 p;
        bool l; //can liquid
+
+       NodeNeighbor()
+               : n(CONTENT_AIR)
+       { }
+
+       NodeNeighbor(const MapNode &node, NeighborType n_type, v3s16 pos)
+               : n(node),
+                 t(n_type),
+                 p(pos)
+       { }
 };
 
 void Map::transforming_liquid_add(v3s16 p) {
@@ -1716,7 +1725,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
                                        break;
                        }
                        v3s16 npos = p0 + dirs[i];
-                       NodeNeighbor nb = {getNodeNoEx(npos), nt, npos};
+                       NodeNeighbor nb(getNodeNoEx(npos), nt, npos);
                        switch (nodemgr->get(nb.n.getContent()).liquid_type) {
                                case LIQUID_NONE:
                                        if (nb.n.getContent() == CONTENT_AIR) {
index 3335d9026382f40c639fb22ba2bc3d2c25950342..1089e6d34b3fab3b8705257eb7b4e2d3d9df7874 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -80,9 +80,9 @@ struct MapEditEvent
 
        MapEditEvent():
                type(MEET_OTHER),
+               n(CONTENT_AIR),
                already_known_by_peer(0)
-       {
-       }
+       { }
 
        MapEditEvent * clone()
        {
index ec21a201404fbdfde7f09eaf21e863359443666f..82c53e7d4474b4fc86a9e11fe14e093f5f841cb8 100644 (file)
@@ -139,12 +139,15 @@ struct MapNode
        */
        u8 param2;
 
+       MapNode()
+       { }
+
        MapNode(const MapNode & n)
        {
                *this = n;
        }
 
-       MapNode(content_t content = CONTENT_AIR, u8 a_param1=0, u8 a_param2=0)
+       MapNode(content_t content, u8 a_param1=0, u8 a_param2=0)
                : param0(content),
                  param1(a_param1),
                  param2(a_param2)
index a9ec6ffbbb481f3074120c46279af370e43ffc2e..80494e07a4351bfd42295572ed843ede9c2ef486 100644 (file)
@@ -855,9 +855,8 @@ struct TestMapNode: public TestBase
 {
        void Run(INodeDefManager *nodedef)
        {
-               MapNode n;
+               MapNode n(CONTENT_AIR);
 
-               // Default values
                UASSERT(n.getContent() == CONTENT_AIR);
                UASSERT(n.getLight(LIGHTBANK_DAY, nodedef) == 0);
                UASSERT(n.getLight(LIGHTBANK_NIGHT, nodedef) == 0);
index 02da42459ea3edbede63289d54cbe32402d7bba9..8ac786aab461d7fa114549aade4f1ff7345bba57 100644 (file)
@@ -173,10 +173,8 @@ void VoxelManipulator::addArea(const VoxelArea &area)
        dstream<<", new_size="<<new_size;
        dstream<<std::endl;*/
 
-       // Allocate and clear new data
-       // FIXME: UGLY KLUDGE because MapNode default constructor is FUBAR; it
-       //        initialises data that is going to be overwritten anyway
-       MapNode *new_data = (MapNode*)new char[new_size * sizeof (*new_data)];
+       // Allocate new data and clear flags
+       MapNode *new_data = new MapNode[new_size];
        assert(new_data);
        u8 *new_flags = new u8[new_size];
        assert(new_flags);