aboutsummaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-07-14 22:43:22 +0200
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-07-14 22:43:28 +0200
commitaf05e4b2defde537f3b953a7dae0ef44fae225aa (patch)
tree3f751014432b35df1cc2fd6fb976410e86b70e73 /src/mapblock.cpp
parent4415d95c503f083d871abaf84516f2b6487ecb60 (diff)
parent81535f6277b66c869cda7125b2aeaf99e8078b92 (diff)
downloadminetest-af05e4b2defde537f3b953a7dae0ef44fae225aa.tar.gz
minetest-af05e4b2defde537f3b953a7dae0ef44fae225aa.tar.bz2
minetest-af05e4b2defde537f3b953a7dae0ef44fae225aa.zip
Merge branch 'upstream/master'
Conflicts: data/oerkki1.png src/client.cpp
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp63
1 files changed, 17 insertions, 46 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 2f6a4b850..647a17756 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
MapBlock
*/
-MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
+MapBlock::MapBlock(Map *parent, v3s16 pos, bool dummy):
m_parent(parent),
m_pos(pos),
m_modified(MOD_STATE_WRITE_NEEDED),
@@ -38,7 +38,7 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
m_generated(false),
m_objects(this),
m_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
- m_usage_timer(BLOCK_TIMESTAMP_UNDEFINED)
+ m_usage_timer(0)
{
data = NULL;
if(dummy == false)
@@ -607,24 +607,20 @@ void MapBlock::serialize(std::ostream &os, u8 version)
Get data
*/
- SharedBuffer<u8> databuf(nodecount*3);
-
- // Get contents
+ // Serialize nodes
+ SharedBuffer<u8> databuf_nodelist(nodecount*3);
for(u32 i=0; i<nodecount; i++)
{
- databuf[i] = data[i].d;
+ data[i].serialize(&databuf_nodelist[i*3], version);
}
-
- // Get params
- for(u32 i=0; i<nodecount; i++)
- {
- databuf[i+nodecount] = data[i].param;
- }
-
- // Get param2
+
+ // Create buffer with different parameters sorted
+ SharedBuffer<u8> databuf(nodecount*3);
for(u32 i=0; i<nodecount; i++)
{
- databuf[i+nodecount*2] = data[i].param2;
+ databuf[i] = databuf_nodelist[i*3];
+ databuf[i+nodecount] = databuf_nodelist[i*3+1];
+ databuf[i+nodecount*2] = databuf_nodelist[i*3+2];
}
/*
@@ -773,20 +769,14 @@ void MapBlock::deSerialize(std::istream &is, u8 version)
("MapBlock::deSerialize: decompress resulted in size"
" other than nodecount*3");
- // Set contents
- for(u32 i=0; i<nodecount; i++)
- {
- data[i].d = s[i];
- }
- // Set params
- for(u32 i=0; i<nodecount; i++)
- {
- data[i].param = s[i+nodecount];
- }
- // Set param2
+ // deserialize nodes from buffer
for(u32 i=0; i<nodecount; i++)
{
- data[i].param2 = s[i+nodecount*2];
+ u8 buf[3];
+ buf[0] = s[i];
+ buf[1] = s[i+nodecount];
+ buf[2] = s[i+nodecount*2];
+ data[i].deSerialize(buf, version);
}
/*
@@ -818,25 +808,6 @@ void MapBlock::deSerialize(std::istream &is, u8 version)
}
}
}
-
- /*
- Translate nodes as specified in the translate_to fields of
- node features
-
- NOTE: This isn't really used. Should it be removed?
- */
- for(u32 i=0; i<MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++)
- {
- MapNode &n = data[i];
-
- MapNode *translate_to = content_features(n.d).translate_to;
- if(translate_to)
- {
- dstream<<"MapBlock: WARNING: Translating node "<<n.d<<" to "
- <<translate_to->d<<std::endl;
- n = *translate_to;
- }
- }
}
void MapBlock::serializeDiskExtra(std::ostream &os, u8 version)