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


C++ PropStream::getShort方法代码示例

本文整理汇总了C++中PropStream::getShort方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::getShort方法的具体用法?C++ PropStream::getShort怎么用?C++ PropStream::getShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropStream的用法示例。


在下文中一共展示了PropStream::getShort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readAttr

Attr_ReadValue Depot::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	if(attr != ATTR_DEPOT_ID)
		return Item::readAttr(attr, propStream);

	uint16_t depotId;
	if(!propStream.getShort(depotId))
		return ATTR_READ_ERROR;

	setAttribute("depotid", depotId);
	return ATTR_READ_CONTINUE;
}
开发者ID:Drakos1,项目名称:otxserver,代码行数:12,代码来源:depot.cpp

示例2: unserializeMap

bool ItemAttributes::unserializeMap(PropStream& stream)
{
	uint16_t n;
	if(!stream.getShort(n))
		return true;

	createAttributes();
	while(n--)
	{
		std::string key;
		if(!stream.getString(key))
			return false;

		ItemAttribute attr;
		if(!attr.unserialize(stream))
			return false;

		(*attributes)[key] = attr;
	}

	return true;
}
开发者ID:Luck-Oake,项目名称:therebornserver,代码行数:22,代码来源:itemattributes.cpp

示例3: loadItem

bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent, bool depotTransfer/* = false*/)
{
	Tile* tile = NULL;
	if(!parent->getItem())
		tile = parent->getTile();

	uint16_t id = 0;
	propStream.getShort(id);
	Item* item = NULL;

	const ItemType& iType = Item::items[id];
	if(iType.movable || iType.forceSerialize || (!depotTransfer && !tile))
	{
		if(!(item = Item::CreateItem(id)))
			return true;

		if(!item->unserializeAttr(propStream))
		{
			std::clog << "[Warning - IOMapSerialize::loadItem] Unserialization error [0] for item type " << id << std::endl;
			delete item;
			return false;
		}

		if(Container* container = item->getContainer())
		{
			if(!loadContainer(propStream, container))
			{
				delete item;
				return false;
			}
		}

		if(parent)
		{
			parent->__internalAddThing(item);
			item->__startDecaying();
		}
		else
			delete item;

		return true;
	}

	if(tile)
	{
		//Stationary items
		if(TileItemVector* items = tile->getItemList())
		{
			for(ItemVector::iterator it = items->begin(); it != items->end(); ++it)
			{
				if((*it)->getID() == id)
				{
					item = *it;
					break;
				}

				if(iType.isBed() && (*it)->getBed())
				{
					item = *it;
					break;
				}

				if(iType.isDoor() && (*it)->getDoor())
				{
					item = *it;
					break;
				}
			}
		}
	}

	if(item)
	{
		if(item->unserializeAttr(propStream))
		{
			Container* container = item->getContainer();
			if(container && !loadContainer(propStream, container))
				return false;

			if(!item->getDoor() || item->getID() == iType.transformUseTo)
				item = g_game.transformItem(item, id);
		}
		else
			std::clog << "[Warning - IOMapSerialize::loadItem] Unserialization error [1] for item type " << id << std::endl;

		return true;
	}

	//The map changed since the last save, just read the attributes
	if(!(item = Item::CreateItem(id)))
		return true;

	item->unserializeAttr(propStream);
	if(Container* container = item->getContainer())
	{
		if(!loadContainer(propStream, container))
		{
			delete item;
			return false;
		}
//.........这里部分代码省略.........
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:101,代码来源:iomapserialize.cpp

示例4: loadMapBinaryTileBased

bool IOMapSerialize::loadMapBinaryTileBased(Map* map)
{
	Database* db = Database::getInstance();
	DBResult* result;

	DBQuery query;
	query << "SELECT `house_id`, `data` FROM `tile_store` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
	if(!(result = db->storeQuery(query.str())))
		return false;

	House* house = NULL;
	do
	{
		int32_t houseId = result->getDataInt("house_id");
		house = Houses::getInstance()->getHouse(houseId);

		uint64_t attrSize = 0;
		const char* attr = result->getDataStream("data", attrSize);

		PropStream propStream;
		propStream.init(attr, attrSize);
		while(propStream.size())
		{
			uint16_t x = 0, y = 0;
			uint8_t z = 0;

			propStream.getShort(x);
			propStream.getShort(y);
			propStream.getByte(z);

			uint32_t itemCount = 0;
			propStream.getLong(itemCount);

			Position pos(x, y, (int16_t)z);
			if(house && house->hasPendingTransfer())
			{
				if(Player* player = g_game.getPlayerByGuidEx(house->getOwner()))
				{
					while(itemCount--)
						loadItem(propStream, player->getInbox(), true);

					if(player->isVirtual())
					{
						IOLoginData::getInstance()->savePlayer(player);
						delete player;
					}
				}
			}
			else if(Tile* tile = map->getTile(pos))
			{
				while(itemCount--)
					loadItem(propStream, tile, false);
			}
			else
			{
				std::clog << "[Error - IOMapSerialize::loadMapBinary] Unserialization of invalid tile"
					<< " at position " << pos << std::endl;
				break;
			}
 		}
	}
	while(result->next());
	result->free();
 	return true;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:65,代码来源:iomapserialize.cpp

示例5: readAttr

Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch(attr)
	{
		case ATTR_COUNT:
		{
			uint8_t _count;
			if(!propStream.getByte(_count))
				return ATTR_READ_ERROR;

			setSubType((uint16_t)_count);
			break;
		}

		case ATTR_ACTION_ID:
		{
			uint16_t aid;
			if(!propStream.getShort(aid))
				return ATTR_READ_ERROR;

			setAttribute("aid", aid);
			break;
		}

		case ATTR_UNIQUE_ID:
		{
			uint16_t uid;
			if(!propStream.getShort(uid))
				return ATTR_READ_ERROR;

			setUniqueId(uid);
			break;
		}

		case ATTR_NAME:
		{
			std::string name;
			if(!propStream.getString(name))
				return ATTR_READ_ERROR;

			setAttribute("name", name);
			break;
		}

		case ATTR_PLURALNAME:
		{
			std::string name;
			if(!propStream.getString(name))
				return ATTR_READ_ERROR;

			setAttribute("pluralname", name);
			break;
		}

		case ATTR_ARTICLE:
		{
			std::string article;
			if(!propStream.getString(article))
				return ATTR_READ_ERROR;

			setAttribute("article", article);
			break;
		}

		case ATTR_ATTACK:
		{
			int32_t attack;
			if(!propStream.getLong((uint32_t&)attack))
				return ATTR_READ_ERROR;

			setAttribute("attack", attack);
			break;
		}

		case ATTR_EXTRAATTACK:
		{
			int32_t attack;
			if(!propStream.getLong((uint32_t&)attack))
				return ATTR_READ_ERROR;

			setAttribute("extraattack", attack);
			break;
		}

		case ATTR_DEFENSE:
		{
			int32_t defense;
			if(!propStream.getLong((uint32_t&)defense))
				return ATTR_READ_ERROR;

			setAttribute("defense", defense);
			break;
		}

		case ATTR_EXTRADEFENSE:
		{
			int32_t defense;
			if(!propStream.getLong((uint32_t&)defense))
				return ATTR_READ_ERROR;

//.........这里部分代码省略.........
开发者ID:Elexonic,项目名称:otxserver,代码行数:101,代码来源:item.cpp


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