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


C++ PropStream类代码示例

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


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

示例1: unserializeProp

bool ConditionAttributes::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
	switch(attr)
	{
		case CONDITIONATTR_SKILLS:
		{
			int32_t value = 0;
			if(!propStream.GET_VALUE(value))
				return false;

			skills[currentSkill++] = value;
			return true;
		}

		case CONDITIONATTR_STATS:
		{
			int32_t value = 0;
			if(!propStream.GET_VALUE(value))
				return false;

			stats[currentStat++] = value;
			return true;
		}

		default:
			break;
	}

	return ConditionGeneric::unserializeProp(attr, propStream);
}
开发者ID:Alexy234,项目名称:poketibia,代码行数:30,代码来源:condition.cpp

示例2: unserializeProp

bool Condition::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
	switch (attr) {
		case CONDITIONATTR_TYPE: {
			int32_t value;
			if (!propStream.GET_VALUE(value)) {
				return false;
			}

			conditionType = (ConditionType_t)value;
			return true;
		}

		case CONDITIONATTR_ID: {
			int32_t value;
			if (!propStream.GET_VALUE(value)) {
				return false;
			}

			id = (ConditionId_t)value;
			return true;
		}

		case CONDITIONATTR_TICKS: {
			int32_t value;
			if (!propStream.GET_VALUE(value)) {
				return false;
			}

			ticks = value;
			return true;
		}

		case CONDITIONATTR_ISBUFF: {
			int8_t value;
			if (!propStream.GET_VALUE(value)) {
				return false;
			}

			isBuff = value != 0;
			return true;
		}

		case CONDITIONATTR_SUBID: {
			int32_t value;
			if (!propStream.GET_VALUE(value)) {
				return false;
			}

			subId = value;
			return true;
		}

		case CONDITIONATTR_END:
			return true;

		default:
			return false;
	}
}
开发者ID:sheen123,项目名称:forgottenserver,代码行数:60,代码来源:condition.cpp

示例3: parseWaypoints

bool IOMap::parseWaypoints(OTB::Loader& loader, const OTB::Node& waypointsNode, Map& map)
{
	PropStream propStream;
	for (auto& node : waypointsNode.children) {
		if (node.type != OTBM_WAYPOINT) {
			setLastErrorString("Unknown waypoint node.");
			return false;
		}

		if (!loader.getProps(node, propStream)) {
			setLastErrorString("Could not read waypoint data.");
			return false;
		}

		std::string name;
		if (!propStream.readString(name)) {
			setLastErrorString("Could not read waypoint name.");
			return false;
		}

		OTBM_Destination_coords waypoint_coords;
		if (!propStream.read(waypoint_coords)) {
			setLastErrorString("Could not read waypoint coordinates.");
			return false;
		}

		map.waypoints[name] = Position(waypoint_coords.x, waypoint_coords.y, waypoint_coords.z);
	}
	return true;
}
开发者ID:LuisPro,项目名称:forgottenserver,代码行数:30,代码来源:iomap.cpp

示例4: loadItems

void IOLoginData::loadItems(ItemMap& itemMap, DBResult* result)
{
	do {
		int32_t sid = result->getDataInt("sid");
		int32_t pid = result->getDataInt("pid");
		int32_t type = result->getDataInt("itemtype");
		int32_t count = result->getDataInt("count");

		unsigned long attrSize = 0;
		const char* attr = result->getDataStream("attributes", attrSize);

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

		Item* item = Item::CreateItem(type, count);

		if (item) {
			if (!item->unserializeAttr(propStream)) {
				std::cout << "WARNING: Serialize error in IOLoginData::loadItems" << std::endl;
			}

			std::pair<Item*, int32_t> pair(item, pid);
			itemMap[sid] = pair;
		}
	} while (result->next());
}
开发者ID:oneshot-git,项目名称:forgottenserver,代码行数:26,代码来源:iologindata.cpp

示例5: unserializeProp

bool ConditionSpeed::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
    switch(attr)
    {
    case CONDITIONATTR_SPEEDDELTA:
    {
        int32_t value = 0;
        if(!propStream.GET_VALUE(value))
            return false;

        speedDelta = value;
        return true;
    }

    case CONDITIONATTR_FORMULA_MINA:
    {
        float value = 0;
        if(!propStream.GET_VALUE(value))
            return false;

        mina = value;
        return true;
    }

    case CONDITIONATTR_FORMULA_MINB:
    {
        float value = 0;
        if(!propStream.GET_VALUE(value))
            return false;

        minb = value;
        return true;
    }

    case CONDITIONATTR_FORMULA_MAXA:
    {
        float value = 0;
        if(!propStream.GET_VALUE(value))
            return false;

        maxa = value;
        return true;
    }

    case CONDITIONATTR_FORMULA_MAXB:
    {
        float value = 0;
        if(!propStream.GET_VALUE(value))
            return false;

        maxb = value;
        return true;
    }

    default:
        break;
    }

    return ConditionOutfit::unserializeProp(attr, propStream);
}
开发者ID:Ceetros,项目名称:Pokemon-Dash-Evolution,代码行数:60,代码来源:condition.cpp

示例6: unserializeProp

bool ConditionAttributes::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
	if (attr == CONDITIONATTR_SKILLS) {
		int32_t value = 0;

		if (!propStream.GET_VALUE(value)) {
			return false;
		}

		skills[currentSkill] = value;
		++currentSkill;
		return true;
	} else if (attr == CONDITIONATTR_STATS) {
		int32_t value = 0;

		if (!propStream.GET_VALUE(value)) {
			return false;
		}

		stats[currentStat] = value;
		++currentStat;
		return true;
	}

	return Condition::unserializeProp(attr, propStream);
}
开发者ID:CkyLua,项目名称:forgottenserver-1,代码行数:26,代码来源:condition.cpp

示例7: unserializeProp

bool ConditionSoul::unserializeProp(const ConditionAttr_t& attr, PropStream& propStream)
{
	if (attr == CONDITIONATTR_SOULGAIN)
	{
		uint32_t value = 0;

		if (!propStream.GET_UINT32(value))
		{
			return false;
		}

		soulGain = value;
		return true;
	}
	else if (attr == CONDITIONATTR_SOULTICKS)
	{
		uint32_t value = 0;

		if (!propStream.GET_UINT32(value))
		{
			return false;
		}

		soulTicks = value;
		return true;
	}

	return Condition::unserializeProp(attr, propStream);
}
开发者ID:edubart,项目名称:otserv,代码行数:29,代码来源:condition.cpp

示例8: getProps

bool FileLoader::getProps(const NODE node, PropStream& props)
{
	size_t size;
	if (const uint8_t* a = getProps(node, size)) {
		props.init((char*)a, size);
		return true;
	}

	props.init(nullptr, 0);
	return false;
}
开发者ID:Badhu,项目名称:PokeB-Distro,代码行数:11,代码来源:fileloader.cpp

示例9: 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

示例10: getProps

bool FileLoader::getProps(const NODE node, PropStream& props)
{
	size_t size;
	if (const uint8_t* a = getProps(node, size)) {
		props.init(reinterpret_cast<const char*>(a), size); // does not break strict aliasing
		return true;
	}

	props.init(nullptr, 0);
	return false;
}
开发者ID:Fir3element,项目名称:tfs12,代码行数:11,代码来源:fileloader.cpp

示例11: OTSYS_TIME

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

示例12: unserializeProp

bool ConditionDamage::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
	switch(attr)
	{
		case CONDITIONATTR_DELAYED:
		{
			bool value = false;
			if(!propStream.getType(value))
				return false;

			delayed = value;
			return true;
		}

		case CONDITIONATTR_PERIODDAMAGE:
		{
			int32_t value = 0;
			if(!propStream.getType(value))
				return false;

			periodDamage = value;
			return true;
		}

		case CONDITIONATTR_OWNER:
		{
			uint32_t value = 0;
			if(!propStream.getType(value))
				return false;

			owner = value;
			return true;
		}

		case CONDITIONATTR_INTERVALDATA:
		{
			IntervalInfo damageInfo;
			if(!propStream.getType(damageInfo))
				return false;

			damageList.push_back(damageInfo);
			if(getTicks() != -1)
				setTicks(getTicks() + damageInfo.interval);

			return true;
		}

		default:
			break;
	}

	return Condition::unserializeProp(attr, propStream);
}
开发者ID:Codex-NG,项目名称:thecrystalserver,代码行数:53,代码来源:condition.cpp

示例13: getProps

bool FileLoader::getProps(const NODE node, PropStream &props)
{
	unsigned long size;
	const unsigned char* a = getProps(node, size);
	if(!a){
		props.init(NULL, 0);
		return false;
	}
	else{
		props.init((char*)a, size);
		return true;
	}
}
开发者ID:WeDontGiveAF,项目名称:OOServer,代码行数:13,代码来源:fileloader.cpp

示例14: parseMapDataAttributes

bool IOMap::parseMapDataAttributes(OTB::Loader& loader, const OTB::Node& mapNode, Map& map, const std::string& fileName)
{
	PropStream propStream;
	if (!loader.getProps(mapNode, propStream)) {
		setLastErrorString("Could not read map data attributes.");
		return false;
	}

	std::string mapDescription;
	std::string tmp;

	uint8_t attribute;
	while (propStream.read<uint8_t>(attribute)) {
		switch (attribute) {
			case OTBM_ATTR_DESCRIPTION:
				if (!propStream.readString(mapDescription)) {
					setLastErrorString("Invalid description tag.");
					return false;
				}
				break;

			case OTBM_ATTR_EXT_SPAWN_FILE:
				if (!propStream.readString(tmp)) {
					setLastErrorString("Invalid spawn tag.");
					return false;
				}

				map.spawnfile = fileName.substr(0, fileName.rfind('/') + 1);
				map.spawnfile += tmp;
				break;

			case OTBM_ATTR_EXT_HOUSE_FILE:
				if (!propStream.readString(tmp)) {
					setLastErrorString("Invalid house tag.");
					return false;
				}

				map.housefile = fileName.substr(0, fileName.rfind('/') + 1);
				map.housefile += tmp;
				break;

			default:
				setLastErrorString("Unknown header node.");
				return false;
		}
	}
	return true;
}
开发者ID:LuisPro,项目名称:forgottenserver,代码行数:48,代码来源:iomap.cpp

示例15: unserializeProp

bool ConditionDamage::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
	if (attr == CONDITIONATTR_DELAYED) {
		uint8_t value;
		if (!propStream.read<uint8_t>(value)) {
			return false;
		}

		delayed = (value != 0);
		return true;
	} else if (attr == CONDITIONATTR_PERIODDAMAGE) {
		return propStream.read<int32_t>(periodDamage);
	} else if (attr == CONDITIONATTR_OWNER) {
		return propStream.skip(4);
	} else if (attr == CONDITIONATTR_INTERVALDATA) {
		IntervalInfo damageInfo;
		if (!propStream.read<IntervalInfo>(damageInfo)) {
			return false;
		}

		damageList.push_back(damageInfo);
		if (ticks != -1) {
			setTicks(ticks + damageInfo.interval);
		}
		return true;
	}
	return Condition::unserializeProp(attr, propStream);
}
开发者ID:DevelopersPL,项目名称:forgottenserver,代码行数:28,代码来源:condition.cpp


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