本文整理汇总了C++中NodeMetadata::serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeMetadata::serialize方法的具体用法?C++ NodeMetadata::serialize怎么用?C++ NodeMetadata::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeMetadata
的用法示例。
在下文中一共展示了NodeMetadata::serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
void NodeMetadataList::serialize(std::ostream &os) const
{
/*
Version 0 is a placeholder for "nothing to see here; go away."
*/
if(m_data.empty()){
writeU8(os, 0); // version
return;
}
writeU8(os, 1); // version
u16 count = m_data.size();
writeU16(os, count);
for(std::map<v3s16, NodeMetadata*>::const_iterator
i = m_data.begin();
i != m_data.end(); ++i)
{
v3s16 p = i->first;
NodeMetadata *data = i->second;
u16 p16 = p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE + p.Y * MAP_BLOCKSIZE + p.X;
writeU16(os, p16);
data->serialize(os);
}
}
示例2: os
RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef)
{
INodeDefManager *ndef = gamedef->ndef();
MapNode n = map->getNodeNoEx(p);
name = ndef->get(n).name;
param1 = n.param1;
param2 = n.param2;
NodeMetadata *metap = map->getNodeMetadata(p);
if (metap) {
std::ostringstream os(std::ios::binary);
metap->serialize(os);
meta = os.str();
}
}
示例3: serialize
void NodeMetadataList::serialize(std::ostream &os)
{
u8 buf[6];
u16 version = 1;
writeU16(buf, version);
os.write((char*)buf, 2);
u16 count = m_data.size();
writeU16(buf, count);
os.write((char*)buf, 2);
for (core::map<v3s16, NodeMetadata*>::Iterator i = m_data.getIterator(); i.atEnd()==false; i++) {
v3s16 p = i.getNode()->getKey();
NodeMetadata *data = i.getNode()->getValue();
u16 p16 = p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X;
writeU16(buf, p16);
os.write((char*)buf, 2);
data->serialize(os);
}
}