summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-13 12:54:33 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:41 +0200
commit3b77a63d5dbfff0ae5ca8eb04a001904f7f568b2 (patch)
treec89430a5746c4eaf1177afd0f948595de87437e7
parent64fa59e24f7b3e046b7dfeba930e44c86e32668e (diff)
downloadminetest-3b77a63d5dbfff0ae5ca8eb04a001904f7f568b2.tar.gz
minetest-3b77a63d5dbfff0ae5ca8eb04a001904f7f568b2.tar.bz2
minetest-3b77a63d5dbfff0ae5ca8eb04a001904f7f568b2.zip
Allocate MapBlock::m_node_metadata on heap to allow less header bloat
-rw-r--r--src/client.cpp1
-rw-r--r--src/environment.cpp5
-rw-r--r--src/game.cpp1
-rw-r--r--src/map.cpp8
-rw-r--r--src/mapblock.cpp14
-rw-r--r--src/mapblock.h4
6 files changed, 19 insertions, 14 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 69c91bc30..80d7febe6 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "profiler.h"
#include "log.h"
+#include "nodemetadata.h"
/*
QueuedMeshUpdate
diff --git a/src/environment.cpp b/src/environment.cpp
index 50c5a4b81..d9f24ede9 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h"
#include "scriptapi.h"
#include "mapnode_contentfeatures.h"
+#include "nodemetadata.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@@ -607,7 +608,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
activateObjects(block);
// Run node metadata
- bool changed = block->m_node_metadata.step((float)dtime_s);
+ bool changed = block->m_node_metadata->step((float)dtime_s);
if(changed)
{
MapEditEvent event;
@@ -917,7 +918,7 @@ void ServerEnvironment::step(float dtime)
block->setTimestampNoChangedFlag(m_game_time);
// Run node metadata
- bool changed = block->m_node_metadata.step(dtime);
+ bool changed = block->m_node_metadata->step(dtime);
if(changed)
{
MapEditEvent event;
diff --git a/src/game.cpp b/src/game.cpp
index 638ad9155..bd84593b8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -45,6 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
// Needed for determining pointing to nodes
#include "mapnode_contentfeatures.h"
+#include "nodemetadata.h"
/*
Setting this to 1 enables a special camera mode that forces
diff --git a/src/map.cpp b/src/map.cpp
index 858c08b63..b70b76b71 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1836,7 +1836,7 @@ NodeMetadata* Map::getNodeMetadata(v3s16 p)
<<std::endl;
return NULL;
}
- NodeMetadata *meta = block->m_node_metadata.get(p_rel);
+ NodeMetadata *meta = block->m_node_metadata->get(p_rel);
return meta;
}
@@ -1856,7 +1856,7 @@ void Map::setNodeMetadata(v3s16 p, NodeMetadata *meta)
<<std::endl;
return;
}
- block->m_node_metadata.set(p_rel, meta);
+ block->m_node_metadata->set(p_rel, meta);
}
void Map::removeNodeMetadata(v3s16 p)
@@ -1870,7 +1870,7 @@ void Map::removeNodeMetadata(v3s16 p)
<<std::endl;
return;
}
- block->m_node_metadata.remove(p_rel);
+ block->m_node_metadata->remove(p_rel);
}
void Map::nodeMetadataStep(float dtime,
@@ -1895,7 +1895,7 @@ void Map::nodeMetadataStep(float dtime,
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
{
MapBlock *block = *i;
- bool changed = block->m_node_metadata.step(dtime);
+ bool changed = block->m_node_metadata->step(dtime);
if(changed)
changed_blocks[block->getPos()] = block;
}
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 85cd7e45e..012cbd4d1 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -24,12 +24,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "light.h"
#include <sstream>
#include "mapnode_contentfeatures.h"
+#include "nodemetadata.h"
/*
MapBlock
*/
MapBlock::MapBlock(Map *parent, v3s16 pos, bool dummy):
+ m_node_metadata(new NodeMetadataList),
m_parent(parent),
m_pos(pos),
m_modified(MOD_STATE_WRITE_NEEDED),
@@ -44,8 +46,6 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, bool dummy):
if(dummy == false)
reallocate();
- //m_spawn_timer = -10000;
-
#ifndef SERVER
m_mesh_expired = false;
mesh_mutex.Init();
@@ -68,6 +68,8 @@ MapBlock::~MapBlock()
}
#endif
+ delete m_node_metadata;
+
if(data)
delete[] data;
}
@@ -632,7 +634,7 @@ void MapBlock::serialize(std::ostream &os, u8 version)
{
try{
std::ostringstream oss(std::ios_base::binary);
- m_node_metadata.serialize(oss);
+ m_node_metadata->serialize(oss);
os<<serializeString(oss.str());
}
// This will happen if the string is longer than 65535
@@ -645,7 +647,7 @@ void MapBlock::serialize(std::ostream &os, u8 version)
else
{
std::ostringstream oss(std::ios_base::binary);
- m_node_metadata.serialize(oss);
+ m_node_metadata->serialize(oss);
compressZlib(oss.str(), os);
//os<<serializeLongString(oss.str());
}
@@ -784,7 +786,7 @@ void MapBlock::deSerialize(std::istream &is, u8 version)
{
std::string data = deSerializeString(is);
std::istringstream iss(data, std::ios_base::binary);
- m_node_metadata.deSerialize(iss);
+ m_node_metadata->deSerialize(iss);
}
else
{
@@ -792,7 +794,7 @@ void MapBlock::deSerialize(std::istream &is, u8 version)
std::ostringstream oss(std::ios_base::binary);
decompressZlib(is, oss);
std::istringstream iss(oss.str(), std::ios_base::binary);
- m_node_metadata.deSerialize(iss);
+ m_node_metadata->deSerialize(iss);
}
}
catch(SerializationError &e)
diff --git a/src/mapblock.h b/src/mapblock.h
index 22b3b7db6..18b679cfc 100644
--- a/src/mapblock.h
+++ b/src/mapblock.h
@@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serialization.h"
#include "constants.h"
#include "voxel.h"
-#include "nodemetadata.h"
#include "staticobject.h"
#include "mapblock_nodemod.h"
#ifndef SERVER
@@ -38,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
class Map;
+class NodeMetadataList;
#define BLOCK_TIMESTAMP_UNDEFINED 0xffffffff
@@ -575,7 +575,7 @@ public:
JMutex mesh_mutex;
#endif
- NodeMetadataList m_node_metadata;
+ NodeMetadataList *m_node_metadata;
StaticObjectList m_static_objects;
private: