mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
initial steps in doing content type extension
This commit is contained in:
parent
7b290660ea
commit
8f742855a1
5 changed files with 153 additions and 146 deletions
|
@ -607,24 +607,20 @@ void MapBlock::serialize(std::ostream &os, u8 version)
|
|||
Get data
|
||||
*/
|
||||
|
||||
// Serialize nodes
|
||||
SharedBuffer<u8> databuf_nodelist(nodecount*3);
|
||||
for(u32 i=0; i<nodecount; i++)
|
||||
{
|
||||
data[i].serialize(&databuf_nodelist[i*3], version);
|
||||
}
|
||||
|
||||
// Create buffer with different parameters sorted
|
||||
SharedBuffer<u8> databuf(nodecount*3);
|
||||
|
||||
// Get contents
|
||||
for(u32 i=0; i<nodecount; i++)
|
||||
{
|
||||
databuf[i] = data[i].d;
|
||||
}
|
||||
|
||||
// Get params
|
||||
for(u32 i=0; i<nodecount; i++)
|
||||
{
|
||||
databuf[i+nodecount] = data[i].param;
|
||||
}
|
||||
|
||||
// Get param2
|
||||
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
|
||||
// deserialize nodes from buffer
|
||||
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
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue