diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-07-02 01:07:54 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-07-02 01:07:54 +0300 |
commit | 8f742855a1f7b7679be1987c1b0c469e822c73f1 (patch) | |
tree | 8f31d3cdc91241a18636bd3b892e51f7ea94fbd7 /src/mapblock.cpp | |
parent | 7b290660ead5e9cfc7ee2762217212ff995a6c85 (diff) | |
download | minetest-8f742855a1f7b7679be1987c1b0c469e822c73f1.tar.gz minetest-8f742855a1f7b7679be1987c1b0c469e822c73f1.tar.bz2 minetest-8f742855a1f7b7679be1987c1b0c469e822c73f1.zip |
initial steps in doing content type extension
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r-- | src/mapblock.cpp | 59 |
1 files changed, 15 insertions, 44 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c125e67c8..647a17756 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -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) |