当前位置: 首页>>代码示例>>C++>>正文


C++ PropWriteStream::addLong方法代码示例

本文整理汇总了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;
}
开发者ID:Fir3element,项目名称:0.3.7,代码行数:26,代码来源:itemattributes.cpp

示例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;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:29,代码来源:iomapserialize.cpp

示例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;
}
开发者ID:AhmedWaly,项目名称:CastOnly,代码行数:10,代码来源:beds.cpp

示例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;
	}
}
开发者ID:Luck-Oake,项目名称:therebornserver,代码行数:20,代码来源:itemattributes.cpp

示例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;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:15,代码来源:iomapserialize.cpp


注:本文中的PropWriteStream::addLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。