summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2015-01-17 19:19:26 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-01-18 13:39:50 +1000
commit805c8e51e5dd4dfad381a0d40b4388b5de90becf (patch)
treef84388699288e570b3244ce7534fbd7aed684081
parent2f0a8f1c3e6429d0d579093c95b9bf27c32e6fd1 (diff)
downloadminetest-805c8e51e5dd4dfad381a0d40b4388b5de90becf.tar.gz
minetest-805c8e51e5dd4dfad381a0d40b4388b5de90becf.tar.bz2
minetest-805c8e51e5dd4dfad381a0d40b4388b5de90becf.zip
Create empty default constructor for MapNode
-rw-r--r--src/map.cpp15
-rw-r--r--src/map.h4
-rw-r--r--src/mapnode.h5
-rw-r--r--src/test.cpp3
-rw-r--r--src/voxel.cpp6
5 files changed, 21 insertions, 12 deletions
diff --git a/src/map.cpp b/src/map.cpp
index fdc35558d..52303cd38 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -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) {
diff --git a/src/map.h b/src/map.h
index 3335d9026..1089e6d34 100644
--- 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()
{
diff --git a/src/mapnode.h b/src/mapnode.h
index ec21a2014..82c53e7d4 100644
--- a/src/mapnode.h
+++ b/src/mapnode.h
@@ -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)
diff --git a/src/test.cpp b/src/test.cpp
index a9ec6ffbb..80494e07a 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -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);
diff --git a/src/voxel.cpp b/src/voxel.cpp
index 02da42459..8ac786aab 100644
--- a/src/voxel.cpp
+++ b/src/voxel.cpp
@@ -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);