本文整理汇总了C++中PropWriteStream::addLong方法的典型用法代码示例。如果您正苦于以下问题:C++ PropWriteStream::addLong方法的具体用法?C++ PropWriteStream::addLong怎么用?C++ PropWriteStream::addLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropWriteStream
的用法示例。
在下文中一共展示了PropWriteStream::addLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
void ItemAttribute::serialize(PropWriteStream& stream) const
{
bool ok;
if(m_data.type() == typeid(std::string))
{
stream.addByte((uint8_t)STRING);
stream.addLongString(getString(ok));
}
else if(m_data.type() == typeid(int32_t))
{
stream.addByte((uint8_t)INTEGER);
stream.addLong(getInteger(ok));
}
else if(m_data.type() == typeid(float))
{
stream.addByte((uint8_t)FLOAT);
stream.addLong(getFloat(ok));
}
else if(m_data.type() == typeid(bool))
{
stream.addByte((uint8_t)BOOLEAN);
stream.addByte(getBoolean(ok));
}
else
std::clog << "[ItemAttribute::serialize]: Invalid data type." << std::endl;
}
示例2: saveTile
bool IOMapSerialize::saveTile(PropWriteStream& stream, const Tile* tile)
{
int32_t tileCount = tile->getThingCount();
if(!tileCount)
return true;
std::vector<Item*> items;
Item* item = NULL;
for(; tileCount > 0; --tileCount)
{
if((item = tile->__getThing(tileCount - 1)->getItem()) && // CHECKME: wouldn't it be better to use TileItemVector in here?
(item->isMovable() || item->forceSerialize()))
items.push_back(item);
}
tileCount = items.size(); //lame, but at least we don't need a new variable
if(tileCount > 0)
{
stream.addShort(tile->getPosition().x);
stream.addShort(tile->getPosition().y);
stream.addByte(tile->getPosition().z);
stream.addLong(tileCount);
for(std::vector<Item*>::iterator it = items.begin(); it != items.end(); ++it)
saveItem(stream, (*it));
}
return true;
}
示例3: serializeAttr
bool BedItem::serializeAttr(PropWriteStream& propWriteStream) const
{
bool ret = Item::serializeAttr(propWriteStream);
if(!sleeper)
return ret;
propWriteStream.addByte(ATTR_SLEEPERGUID);
propWriteStream.addLong(sleeper);
return ret;
}
示例4: serialize
void ItemAttribute::serialize(PropWriteStream& stream) const
{
stream.addByte((uint8_t)type);
switch(type)
{
case STRING:
stream.addLongString(*getString());
break;
case INTEGER:
stream.addLong(*(uint32_t*)getInteger());
break;
case FLOAT:
stream.addLong(*(uint32_t*)getFloat());
break;
case BOOLEAN:
stream.addByte(*(uint8_t*)getBoolean());
default:
break;
}
}
示例5: saveItem
bool IOMapSerialize::saveItem(PropWriteStream& stream, const Item* item)
{
stream.addShort(item->getID());
item->serializeAttr(stream);
if(const Container* container = item->getContainer())
{
stream.addByte(ATTR_CONTAINER_ITEMS);
stream.addLong(container->size());
for(ItemList::const_reverse_iterator rit = container->getReversedItems(); rit != container->getReversedEnd(); ++rit)
saveItem(stream, (*rit));
}
stream.addByte(ATTR_END);
return true;
}