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


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

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


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

示例1: unserialize

bool ItemAttribute::unserialize(PropStream& stream)
{
  // dealloc possible string value
  dealloc();
  
  // read type
  stream.GET_UCHAR(reinterpret_cast<uint8_t&>(m_type));
  
  // do not call here set(...) or any other function depending on m_type which may result in deallocating phantom string !

  // read contents
  switch(m_type){
    case STRING: {
      m_var.string = new std::string;   
      if(!stream.GET_LSTRING(*m_var.string))
        return false;
      
      break;
    }
    
    case INTEGER: 
    case FLOAT: {
      if(!stream.GET_ULONG(m_var.unsignedInteger))
        return false;
      
      break;
    }
    
    case BOOLEAN: {
      if(!stream.GET_UCHAR(m_var.unsignedChar))
        return false;
        
      break;
    }
    
    default: {
      m_type = NONE; 
      break;
    }
  }
  
  return true;
}
开发者ID:RGZorzo,项目名称:server,代码行数:43,代码来源:item_attributes.cpp

示例2: unserialize

bool Condition::unserialize(PropStream& propStream)
{
	uint8_t attr_type;
	while(propStream.GET_UCHAR(attr_type) && attr_type != CONDITIONATTR_END)
	{
		if(!unserializeProp((ConditionAttr_t)attr_type, propStream))
			return false;
	}
	return true;
}
开发者ID:armadaazteca,项目名称:tfs0.2.15,代码行数:10,代码来源:condition.cpp

示例3: loadMap

bool IOMapSerialize::loadMap(Map* map)
{
	int64_t start = OTSYS_TIME();

	Database* db = Database::getInstance();
	std::ostringstream query;

	DBResult* result = db->storeQuery("SELECT `id` FROM `houses`");
	if (!result) {
		return true;
	}

	do {
		query.str("");
		query << "SELECT `data` FROM `tile_store` WHERE `house_id` = " << result->getDataInt("id");
		DBResult* tileResult = db->storeQuery(query.str());
		if (!tileResult) {
			continue;
		}

		do {
			unsigned long attrSize = 0;
			const char* attr = tileResult->getDataStream("data", attrSize);

			PropStream propStream;
			propStream.init(attr, attrSize);

			uint16_t x = 0, y = 0;
			uint8_t z = 0;
			propStream.GET_USHORT(x);
			propStream.GET_USHORT(y);
			propStream.GET_UCHAR(z);
			if (x == 0 || y == 0) {
				continue;
			}

			Tile* tile = map->getTile(x, y, z);
			if (!tile) {
				continue;
			}

			uint32_t item_count = 0;
			propStream.GET_ULONG(item_count);

			while (item_count--) {
				loadItem(propStream, tile);
			}
		} while (tileResult->next());
		db->freeResult(tileResult);
	} while (result->next());
	db->freeResult(result);
	std::cout << "> Loaded house items in: " << (OTSYS_TIME() - start) / (1000.) << " s" << std::endl;
	return true;
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:54,代码来源:iomapserialize.cpp

示例4: readAttr

Attr_ReadValue Teleport::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	if (ATTR_TELE_DEST == attr) {
		if (!propStream.GET_USHORT(destPos.x) || !propStream.GET_USHORT(destPos.y) || !propStream.GET_UCHAR(destPos.z)) {
			return ATTR_READ_ERROR;
		}
		return ATTR_READ_CONTINUE;
	} else {
		return Item::readAttr(attr, propStream);
	}
}
开发者ID:Ablankzin,项目名称:forgottenserver,代码行数:11,代码来源:teleport.cpp

示例5: readAttr

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

	uint8_t doorId = 0;
	if(!propStream.GET_UCHAR(doorId))
		return ATTR_READ_ERROR;

	setDoorId(doorId);
	return ATTR_READ_CONTINUE;
}
开发者ID:novasdream,项目名称:tyano-core,代码行数:12,代码来源:house.cpp

示例6: unserializeAttr

bool Item::unserializeAttr(PropStream& propStream)
{
	unsigned char attr_type;
	while(propStream.GET_UCHAR(attr_type)){
		if(!readAttr((AttrTypes_t)attr_type, propStream)){
			return false;
			break;
		}
	}

	return true;
}
开发者ID:divinity76,项目名称:server,代码行数:12,代码来源:item.cpp

示例7: readAttr

Attr_ReadValue Door::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	if (ATTR_HOUSEDOORID == attr) {
		unsigned char _doorId = 0;
		if (!propStream.GET_UCHAR(_doorId)) {
			return ATTR_READ_ERROR;
		}

		setDoorId(_doorId);
		return ATTR_READ_CONTINUE;
	} else {
		return Item::readAttr(attr, propStream);
	}
}
开发者ID:ArthurF5,项目名称:lforgottenserver,代码行数:14,代码来源:house.cpp

示例8: readAttr

bool Door::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	if(ATTR_HOUSEDOORID == attr){
		unsigned char _doorId = 0;
		if(!propStream.GET_UCHAR(_doorId)){
			return false;
		}

		setDoorId(_doorId);
		return true;
	}
	else
		return Item::readAttr(attr, propStream);
}
开发者ID:WeDontGiveAF,项目名称:OOServer,代码行数:14,代码来源:house.cpp

示例9: unserializeAttr

bool Item::unserializeAttr(PropStream& propStream)
{
	uint8_t attr_type;

	while (propStream.GET_UCHAR(attr_type) && attr_type != 0) {
		Attr_ReadValue ret = readAttr((AttrTypes_t)attr_type, propStream);

		if (ret == ATTR_READ_ERROR) {
			return false;
		} else if (ret == ATTR_READ_END) {
			return true;
		}
	}

	return true;
}
开发者ID:HeberPcL,项目名称:forgottenserver,代码行数:16,代码来源:item.cpp

示例10: loadContainer

bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container)
{
	while (container->serializationCount > 0) {
		if (!loadItem(propStream, container)) {
			std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error for container item: " << container->getID() << std::endl;
			return false;
		}
		container->serializationCount--;
	}

	uint8_t endAttr;
	if (!propStream.GET_UCHAR(endAttr) || endAttr != 0) {
		std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error for container item: " << container->getID() << std::endl;
		return false;
	}
	return true;
}
开发者ID:Emperian,项目名称:forgottenserver,代码行数:17,代码来源:iomapserialize.cpp

示例11: loadContainer

bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container)
{
	while (container->serializationCount > 0) {
		if (!loadItem(propStream, container)) {
			std::cout << "WARNING: Unserialization error for containing item in IOMapSerialize::loadContainer() - " << container->getID() << std::endl;
			return false;
		}
		container->serializationCount--;
	}

	uint8_t endAttr = 0;
	propStream.GET_UCHAR(endAttr);
	if (endAttr != 0x00) {
		std::cout << "WARNING: Unserialization error for containing item in IOMapSerialize::loadContainer() - " << container->getID() << std::endl;
		return false;
	}
	return true;
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:18,代码来源:iomapserialize.cpp

示例12: loadMap

void IOMapSerialize::loadMap(Map* map)
{
	int64_t start = OTSYS_TIME();

	Database* db = Database::getInstance();

	DBResult* result = db->storeQuery("SELECT `data` FROM `tile_store`");
	if (!result) {
		return;
	}

	do {
		unsigned long attrSize;
		const char* attr = result->getDataStream("data", attrSize);

		PropStream propStream;
		propStream.init(attr, attrSize);

		uint16_t x, y;
		uint8_t z;
		if (!propStream.GET_USHORT(x) || !propStream.GET_USHORT(y) || !propStream.GET_UCHAR(z)) {
			continue;
		}

		Tile* tile = map->getTile(x, y, z);
		if (!tile) {
			continue;
		}

		uint32_t item_count;
		if (!propStream.GET_ULONG(item_count)) {
			continue;
		}

		while (item_count--) {
			loadItem(propStream, tile);
		}
	} while (result->next());
	db->freeResult(result);
	std::cout << "> Loaded house items in: " << (OTSYS_TIME() - start) / (1000.) << " s" << std::endl;
}
开发者ID:Emperian,项目名称:forgottenserver,代码行数:41,代码来源:iomapserialize.cpp

示例13: loadContainer

bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container)
{
	while(container->serializationCount > 0)
	{
		if(!loadItem(propStream, container, false))
		{
			std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error [0] for item in container " << container->getID() << std::endl;
			return false;
		}

		container->serializationCount--;
	}

	uint8_t endAttr = ATTR_END;
	propStream.GET_UCHAR(endAttr);
	if(endAttr == ATTR_END)
		return true;

	std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error [1] for item in container " << container->getID() << std::endl;
	return false;
}
开发者ID:PrzemolKing,项目名称:wedoserver,代码行数:21,代码来源:iomapserialize.cpp

示例14: readAttr

bool Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch(attr){
		case ATTR_COUNT:
		{
			unsigned char _count = 0;
			if(!propStream.GET_UCHAR(_count)){
				return false;
			}

			setItemCountOrSubtype(_count);
			break;
		}

		case ATTR_ACTION_ID:
		{
			unsigned short _actionid = 0;
			if(!propStream.GET_USHORT(_actionid)){
				return false;
			}

			setActionId(_actionid);
			break;
		}

		case ATTR_UNIQUE_ID:
		{
			unsigned short _uniqueid;
			if(!propStream.GET_USHORT(_uniqueid)){
				return false;
			}
			
			setUniqueId(_uniqueid);
			break;
		}

		case ATTR_TEXT:
		{
			std::string _text;
			if(!propStream.GET_STRING(_text)){
				return false;
			}

			setText(_text);
			break;
		}

		case ATTR_DESC:
		{
			std::string _text;
			if(!propStream.GET_STRING(_text)){
				return false;
			}

			setSpecialDescription(_text);
			break;
		}

		case ATTR_RUNE_CHARGES:
		{
			unsigned char _charges = 1;
			if(!propStream.GET_UCHAR(_charges)){
				return false;
			}

			setItemCountOrSubtype(_charges);
			break;
		}

		//these should be handled through derived classes
		//If these are called then something has changed in the items.otb since the map was saved
		//just read the values

		//Depot class
		case ATTR_DEPOT_ID:
		{
			unsigned short _depotId;
			if(!propStream.GET_USHORT(_depotId)){
				return false;
			}
			
			return true;
		}

		//Door class
		case ATTR_HOUSEDOORID:
		{
			unsigned char _doorId;
			if(!propStream.GET_UCHAR(_doorId)){
				return false;
			}
			
			return true;
		}
	
		//Teleport class
		case ATTR_TELE_DEST:
		{
			TeleportDest* tele_dest;
			if(!propStream.GET_STRUCT(tele_dest)){
//.........这里部分代码省略.........
开发者ID:divinity76,项目名称:server,代码行数:101,代码来源:item.cpp

示例15: loadMap

bool IOMap::loadMap(Map* map, const std::string& identifier)
{
	FileLoader f;
	if(!f.openFile(identifier.c_str(), false, true))
	{
		std::stringstream ss;
		ss << "Could not open the file " << identifier << ".";
		setLastErrorString(ss.str());
		return false;
	}

	uint32_t type = 0;
	NODE root = f.getChildNode((NODE)NULL, type);

	PropStream propStream;
	if(!f.getProps(root, propStream))
	{
		setLastErrorString("Could not read root property.");
		return false;
	}

	OTBM_root_header* rootHeader;
	if(!propStream.GET_STRUCT(rootHeader))
	{
		setLastErrorString("Could not read header.");
		return false;
	}

	uint32_t headerVersion = rootHeader->version;
	if(headerVersion <= 0)
	{
		//In otbm version 1 the count variable after splashes/fluidcontainers and stackables
		//are saved as attributes instead, this solves alot of problems with items
		//that is changed (stackable/charges/fluidcontainer/splash) during an update.
		setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
		return false;
	}

	if(headerVersion > 2)
	{
		setLastErrorString("Unknown OTBM version detected.");
		return false;
	}

	uint32_t headerMajorItems = rootHeader->majorVersionItems;
	if(headerMajorItems < 3)
	{
		setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
		return false;
	}

	if(headerMajorItems > (uint32_t)Items::dwMajorVersion)
	{
		setLastErrorString("The map was saved with a different items.otb version, an upgraded items.otb is required.");
		return false;
	}

	uint32_t headerMinorItems = rootHeader->minorVersionItems;
	if(headerMinorItems < CLIENT_VERSION_810)
	{
		setLastErrorString("This map needs an updated items.otb.");
		return false;
	}

	if(headerMinorItems > (uint32_t)Items::dwMinorVersion)
		setLastErrorString("This map needs an updated items.otb.");

	std::cout << "> Map size: " << rootHeader->width << "x" << rootHeader->height << "." << std::endl;
	map->mapWidth = rootHeader->width;
	map->mapHeight = rootHeader->height;

	NODE nodeMap = f.getChildNode(root, type);
	if(type != OTBM_MAP_DATA)
	{
		setLastErrorString("Could not read data node.");
		return false;
	}

	if(!f.getProps(nodeMap, propStream))
	{
		setLastErrorString("Could not read map data attributes.");
		return false;
	}

	std::string tmp;
	uint8_t attribute;
	while(propStream.GET_UCHAR(attribute))
	{
		switch(attribute)
		{
			case OTBM_ATTR_DESCRIPTION:
			{
				if(!propStream.GET_STRING(tmp))
				{
					setLastErrorString("Invalid description tag.");
					return false;
				}

				map->descriptions.push_back(tmp);
				break;
//.........这里部分代码省略.........
开发者ID:Fir3element,项目名称:035,代码行数:101,代码来源:iomap.cpp


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