• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ readXMLString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: xmlParseMemory

Item* ProtocolAdmin::createMail(const std::string& xmlData, std::string& name, uint32_t& depotId)
{
	xmlDocPtr doc = xmlParseMemory(xmlData.c_str(), strlen(xmlData.c_str()));
	if(!doc){
		return NULL;
	}

	xmlNodePtr root = xmlDocGetRootElement(doc);

	if(xmlStrcmp(root->name,(const xmlChar*)"mail") != 0){
		return NULL;
	}

	int32_t itemId = ITEM_PARCEL;

	int32_t intValue;
	std::string strValue;

	if(readXMLString(root, "to", strValue)){
		name = strValue;
	}

	if(readXMLString(root, "town", strValue)){
		if(!Mailbox::getDepotId(strValue, depotId)){
			return NULL;
		}
	}
	else{
		//use the players default town
		if(!IOPlayer::instance()->getDefaultTown(name, depotId)){
			return NULL;
		}
	}

	if(readXMLInteger(root, "id", intValue)){
		itemId = intValue;
	}

	Item* mailItem = Item::CreateItem(itemId);
	mailItem->setParent(VirtualCylinder::virtualCylinder);

	if(Container* mailContainer = mailItem->getContainer()){
		xmlNodePtr node = root->children;
		while(node){
			if(node->type != XML_ELEMENT_NODE){
				node = node->next;
				continue;
			}

			if(!Item::loadItem(node, mailContainer)){
				delete mailContainer;
				return NULL;
			}

			node = node->next;
		}
	}

	return mailItem;
}
开发者ID:CkyLua,项目名称:OTHire,代码行数:60,代码来源:admin.cpp


示例2: LOGe

bool Outfits::parseOutfitNode(xmlNodePtr p)
{
	if(xmlStrcmp(p->name, (const xmlChar*)"outfit"))
		return false;

	int32_t intValue;
	if(!readXMLInteger(p, "id", intValue))
	{
		LOGe("[Outfits::parseOutfitNode] Missing outfit id, skipping");
		return false;
	}

	Outfit newOutfit;
	newOutfit.outfitId = intValue;

	std::string name, strValue;
	if(readXMLString(p, "default", strValue))
		newOutfit.isDefault = booleanString(strValue);

	if(!readXMLString(p, "name", strValue))
	{
		std::stringstream ss;
		ss << "Outfit #" << newOutfit.outfitId;
		ss >> name;
	}
开发者ID:novasdream,项目名称:tyano-core,代码行数:25,代码来源:outfit.cpp


示例3: configureEvent

bool TalkAction::configureEvent(xmlNodePtr p)
{
	std::string str;
	int intValue;
	if(readXMLString(p, "words", str)){
		commandString = str;
	}
	else{
		std::cout << "Error: [TalkAction::configureEvent] No words for TalkAction or Spell." 
			<< std::endl;
		return false;
	}

	if(readXMLString(p, "filter", str)){
		if(str == "quotation") {
			filterType = TALKACTION_MATCH_QUOTATION;
		} else if(str == "first word") {
			filterType = TALKACTION_MATCH_FIRST_WORD;
		}
	}

	if(readXMLInteger(p, "case-sensitive", intValue) || readXMLInteger(p, "sensitive", intValue)){
		caseSensitive = (intValue != 0);
	}

	if(readXMLInteger(p, "access", intValue)){
		accessLevel = intValue;
	}

	return true;
}
开发者ID:Codex-NG,项目名称:avesta74,代码行数:31,代码来源:talkaction.cpp


示例4: parseIntegerVec

bool Monsters::loadLoot(xmlNodePtr node, LootBlock& lootBlock)
{
	std::string strValue;
	if(readXMLString(node, "id", strValue) || readXMLString(node, "ids", strValue))
	{
		IntegerVec idsVec;
		parseIntegerVec(strValue, idsVec);
		for(IntegerVec::iterator it = idsVec.begin(); it != idsVec.end(); ++it)
		{
			lootBlock.ids.push_back(*it);
			if(Item::items[(*it)].isContainer())
				loadChildLoot(node, lootBlock);
		}
	}
	else if(readXMLString(node, "name", strValue) || readXMLString(node, "names", strValue))
	{
		StringVec names = explodeString(strValue, ";");
		for(StringVec::iterator it = names.begin(); it != names.end(); ++it)
		{
			uint16_t tmp = Item::items.getItemIdByName(strValue);
			if(!tmp)
				continue;

			lootBlock.ids.push_back(tmp);
			if(Item::items[tmp].isContainer())
				loadChildLoot(node, lootBlock);
		}
	}

	if(lootBlock.ids.empty())
		return false;

	int32_t intValue;
	if(readXMLInteger(node, "count", intValue) || readXMLInteger(node, "countmax", intValue))
		lootBlock.count = intValue;
	else
		lootBlock.count = 1;

	if(readXMLInteger(node, "chance", intValue) || readXMLInteger(node, "chance1", intValue))
		lootBlock.chance = std::min(MAX_LOOTCHANCE, intValue);
	else
		lootBlock.chance = MAX_LOOTCHANCE;

	if(readXMLInteger(node, "subtype", intValue) || readXMLInteger(node, "subType", intValue))
		lootBlock.subType = intValue;

	if(readXMLInteger(node, "actionId", intValue) || readXMLInteger(node, "actionid", intValue)
		|| readXMLInteger(node, "aid", intValue))
		lootBlock.actionId = intValue;

	if(readXMLInteger(node, "uniqueId", intValue) || readXMLInteger(node, "uniqueid", intValue)
		|| readXMLInteger(node, "uid", intValue))
		lootBlock.uniqueId = intValue;

	if(readXMLString(node, "text", strValue))
		lootBlock.text = strValue;

	return true;
}
开发者ID:milbradt,项目名称:TFS,代码行数:59,代码来源:monsters.cpp


示例5: id

bool EffectEvent::configureRaidEvent(xmlNodePtr eventNode)
{
	if(!RaidEvent::configureRaidEvent(eventNode))
		return false;

	int32_t intValue;
	std::string strValue;
	if(!readXMLInteger(eventNode, "id", intValue))
	{
		if(!readXMLString(eventNode, "name", strValue))
		{
			std::clog << "[Error - EffectEvent::configureRaidEvent] id (or name) tag missing for effect event." << std::endl;
			return false;
		}
		else
			m_effect = getMagicEffect(strValue);
	}
	else
		m_effect = (MagicEffect_t)intValue;

	if(!readXMLString(eventNode, "pos", strValue))
	{
		if(!readXMLInteger(eventNode, "x", intValue))
		{
			std::clog << "[Error - EffectEvent::configureRaidEvent] x tag missing for effect event." << std::endl;
			return false;
		}

		m_position.x = intValue;
		if(!readXMLInteger(eventNode, "y", intValue))
		{
			std::clog << "[Error - EffectEvent::configureRaidEvent] y tag missing for effect event." << std::endl;
			return false;
		}

		m_position.y = intValue;
		if(!readXMLInteger(eventNode, "z", intValue))
		{
			std::clog << "[Error - EffectEvent::configureRaidEvent] z tag missing for effect event." << std::endl;
			return false;
		}

		m_position.z = intValue;
	}
	else
	{
		IntegerVec posList = vectorAtoi(explodeString(strValue, ";"));
		if(posList.size() < 3)
		{
			std::clog << "[Error - EffectEvent::configureRaidEvent] Malformed pos tag for effect event." << std::endl;
			return false;
		}

		m_position = Position(posList[0], posList[1], posList[2]);
	}

	return true;
}
开发者ID:milbradt,项目名称:TFS,代码行数:58,代码来源:raids.cpp


示例6: explodeString

bool Item::loadItem(xmlNodePtr node, Container* parent)
{
	if(!xmlStrcmp(node->name, (const xmlChar*)"item"))
		return false;

	int32_t intValue;
	std::string strValue;

	Item* item = NULL;
	if(readXMLInteger(node, "id", intValue))
		item = Item::CreateItem(intValue);

	if(!item)
		return false;

	if(readXMLString(node, "attributes", strValue))
	{
		StringVec v, attr = explodeString(strValue, ";");
		for(StringVec::iterator it = attr.begin(); it != attr.end(); ++it)
		{
			v = explodeString((*it), ",");
			if(v.size() < 2)
				continue;

			if(atoi(v[1].c_str()) || v[1] == "0")
				item->setAttribute(v[0].c_str(), atoi(v[1].c_str()));
			else
				item->setAttribute(v[0].c_str(), v[1]);
		}
	}

	//compatibility
	if(readXMLInteger(node, "subtype", intValue) || readXMLInteger(node, "subType", intValue))
		item->setSubType(intValue);

	if(readXMLInteger(node, "actionId", intValue) || readXMLInteger(node, "actionid", intValue)
		|| readXMLInteger(node, "aid", intValue))
		item->setActionId(intValue);

	if(readXMLInteger(node, "uniqueId", intValue) || readXMLInteger(node, "uniqueid", intValue)
		|| readXMLInteger(node, "uid", intValue))
		item->setUniqueId(intValue);

	if(readXMLString(node, "text", strValue))
		item->setText(strValue);

	if(item->getContainer())
		loadContainer(node, item->getContainer());

	if(parent)
		parent->addItem(item);

	return true;
}
开发者ID:Elexonic,项目名称:otxserver,代码行数:54,代码来源:item.cpp


示例7: setSubType

bool Item::unserialize(xmlNodePtr nodeItem)
{
	int intValue;
	std::string strValue;

	if(readXMLInteger(nodeItem, "id", intValue)){
		id = intValue;
	}
	else{
		return false;
	}

	if(readXMLInteger(nodeItem, "count", intValue)){
		setSubType(intValue);
	}

	if(readXMLString(nodeItem, "special_description", strValue)){
		setSpecialDescription(strValue);
	}

	if(readXMLString(nodeItem, "text", strValue)){
		setText(strValue);
	}

	if(readXMLInteger(nodeItem, "written_date", intValue)){
		setWrittenDate(intValue);
	}

	if(readXMLString(nodeItem, "writer", strValue)){
		setWriter(strValue);
	}

	if(readXMLInteger(nodeItem, "actionId", intValue)){
		setActionId(intValue);
	}

	if(readXMLInteger(nodeItem, "uniqueId", intValue)){
		setUniqueId(intValue);
	}

	if(readXMLInteger(nodeItem, "duration", intValue)){
		setDuration(intValue);
	}

	if(readXMLInteger(nodeItem, "decayState", intValue)){
		ItemDecayState_t decayState = (ItemDecayState_t)intValue;
		if(decayState != DECAYING_FALSE){
			setDecaying(DECAYING_PENDING);
		}
	}

	return true;
}
开发者ID:cp1337,项目名称:devland,代码行数:53,代码来源:item.cpp


示例8: configureRaidEvent

bool SingleSpawnEvent::configureRaidEvent(xmlNodePtr eventNode)
{
	if(!RaidEvent::configureRaidEvent(eventNode))
		return false;

	std::string strValue;
	if(!readXMLString(eventNode, "name", strValue))
	{
		std::clog << "[Error - SingleSpawnEvent::configureRaidEvent] name tag missing for singlespawn event." << std::endl;
		return false;
	}

	m_monsterName = strValue;
	if(!readXMLString(eventNode, "pos", strValue))
	{
		int32_t intValue;
		if(!readXMLInteger(eventNode, "x", intValue))
		{
			std::clog << "[Error - SingleSpawnEvent::configureRaidEvent] x tag missing for singlespawn event." << std::endl;
			return false;
		}

		m_position.x = intValue;
		if(!readXMLInteger(eventNode, "y", intValue))
		{
			std::clog << "[Error - SingleSpawnEvent::configureRaidEvent] y tag missing for singlespawn event." << std::endl;
			return false;
		}

		m_position.y = intValue;
		if(!readXMLInteger(eventNode, "z", intValue))
		{
			std::clog << "[Error - SingleSpawnEvent::configureRaidEvent] z tag missing for singlespawn event." << std::endl;
			return false;
		}

		m_position.z = intValue;
	}
	else
	{
		IntegerVec posList = vectorAtoi(explodeString(strValue, ";"));
		if(posList.size() < 3)
		{
			std::clog << "[Error - SingleSpawnEvent::configureRaidEvent] Malformed pos tag for singlespawn event." << std::endl;
			return false;
		}

		m_position = Position(posList[0], posList[1], posList[2]);
	}

	return true;
}
开发者ID:milbradt,项目名称:TFS,代码行数:52,代码来源:raids.cpp


示例9: configureRaidEvent

bool AnnounceEvent::configureRaidEvent(xmlNodePtr eventNode)
{
	if(!RaidEvent::configureRaidEvent(eventNode)){
		return false;
	}

	std::string strValue;

	if(readXMLString(eventNode, "message", strValue)){
		m_message = strValue;
	}
	else{
		std::cout << "[Error] Raid: message tag missing for announce event." << std::endl;
		return false;
	}

	if(readXMLString(eventNode, "type", strValue)){
		if(asLowerCaseString(strValue) == "warning"){
			m_messageType = MSG_STATUS_WARNING;
		}
		else if(asLowerCaseString(strValue) == "event"){
			m_messageType = MSG_EVENT_ADVANCE;
		}
		else if(asLowerCaseString(strValue) == "default"){
			m_messageType = MSG_EVENT_DEFAULT;
		}
		else if(asLowerCaseString(strValue) == "description"){
			m_messageType = MSG_INFO_DESCR;
		}
		else if(asLowerCaseString(strValue) == "smallstatus"){
			m_messageType = MSG_STATUS_SMALL;
		}
		else if(asLowerCaseString(strValue) == "blueconsole"){
			m_messageType = MSG_STATUS_CONSOLE_BLUE;
		}
		else if(asLowerCaseString(strValue) == "redconsole"){
			m_messageType = MSG_STATUS_CONSOLE_RED;
		}
		else{
			m_messageType = MSG_EVENT_ADVANCE;
			std::cout << "[Notice] Raid: Unknown type tag missing for announce event. Using default: " << (int32_t)m_messageType << std::endl;
		}
	}
	else{
		m_messageType = MSG_EVENT_ADVANCE;
		std::cout << "[Notice] Raid: type tag missing for announce event. Using default: " << (int32_t)m_messageType << std::endl;
	}
	return true;
}
开发者ID:ChubNtuck,项目名称:avesta74,代码行数:49,代码来源:raids.cpp


示例10: unserializeTileset

bool Materials::unserializeTileset(xmlNodePtr node, wxArrayString& warnings)
{
	std::string strVal;

	if(readXMLString(node, "name", strVal))
	{
		Tileset* ts;
		TilesetContainer::iterator iter = tilesets.find(strVal);
		if(iter != tilesets.end())
		{
			ts = iter->second;
		}
		else
		{
			ts = newd Tileset(brushes, strVal);
			tilesets.insert(make_pair(strVal, ts));
		}

		xmlNodePtr child = node->children;
		while(child)
		{
			ts->loadCategory(child, warnings);
			child = child->next;
		}
	}
	else
	{
		warnings.push_back(wxT("Couldn't read tileset name"));
		return false;
	}
	return true;
}
开发者ID:mattyx14,项目名称:rme,代码行数:32,代码来源:materials.cpp


示例11: configureEvent

bool WeaponWand::configureEvent(xmlNodePtr p)
{
	if(!Weapon::configureEvent(p))
		return false;

	int32_t intValue;
	std::string strValue;

	if(readXMLInteger(p, "min", intValue))
		minChange = intValue;

	if(readXMLInteger(p, "max", intValue))
		maxChange = intValue;

	if(readXMLString(p, "type", strValue))
	{
		std::string tmpStrValue = asLowerCaseString(strValue);
		if(tmpStrValue == "earth")
			params.combatType = COMBAT_EARTHDAMAGE;
		else if(tmpStrValue == "ice")
			params.combatType = COMBAT_ICEDAMAGE;
		else if(tmpStrValue == "energy")
			params.combatType = COMBAT_ENERGYDAMAGE;
		else if(tmpStrValue == "fire")
			params.combatType = COMBAT_FIREDAMAGE;
		else if(tmpStrValue == "death")
			params.combatType = COMBAT_DEATHDAMAGE;
		else if(tmpStrValue == "holy")
			params.combatType = COMBAT_HOLYDAMAGE;
		else
			std::cout << "[Warning - WeaponWand::configureEvent] Type \"" << strValue << "\" does not exist." << std::endl;
	}
	return true;
}
开发者ID:CkyLua,项目名称:tfs,代码行数:34,代码来源:weapons.cpp


示例12: configureRaidEvent

bool ScriptEvent::configureRaidEvent(xmlNodePtr eventNode)
{
	if(!RaidEvent::configureRaidEvent(eventNode))
		return false;

	std::string scriptsName = Raids::getInstance()->getScriptBaseName();
	if(!m_interface.loadDirectory(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/"))))
		std::cout << "[Warning - ScriptEvent::configureRaidEvent] Cannot load " << scriptsName << "/lib/" << std::endl;

	std::string strValue;
	if(readXMLString(eventNode, "file", strValue))
	{
		if(!loadScript(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/" + strValue)), true))
		{
			std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script file (" << strValue << ")." << std::endl;
			return false;
		}
	}
	else if(!parseXMLContentString(eventNode->children, strValue) && !loadBuffer(strValue))
	{
		std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script buffer." << std::endl;
		return false;
	}

	return true;
}
开发者ID:A-Syntax,项目名称:cryingdamson-0.3.6-8.60-V8.2,代码行数:26,代码来源:raids.cpp


示例13: configureEvent

bool CreatureEvent::configureEvent(xmlNodePtr p)
{
	std::string str;

	//Name that will be used in monster xml files and
	// lua function to register events to reference this event
	if (readXMLString(p, "name", str)) {
		m_eventName = str;
	} else {
		std::cout << "Error: [CreatureEvent::configureEvent] No name for creature event." << std::endl;
		return false;
	}

	if (readXMLString(p, "type", str)) {
		std::string tmpStr = asLowerCaseString(str);

		if (tmpStr == "login") {
			m_type = CREATURE_EVENT_LOGIN;
		} else if (tmpStr == "logout") {
			m_type = CREATURE_EVENT_LOGOUT;
		} else if (tmpStr == "think") {
			m_type = CREATURE_EVENT_THINK;
		} else if (tmpStr == "preparedeath") {
			m_type = CREATURE_EVENT_PREPAREDEATH;
		} else if (tmpStr == "death") {
			m_type = CREATURE_EVENT_DEATH;
		} else if (tmpStr == "kill") {
			m_type = CREATURE_EVENT_KILL;
		} else if (tmpStr == "advance") {
			m_type = CREATURE_EVENT_ADVANCE;
		} else if (tmpStr == "modalwindow") {
			m_type = CREATURE_EVENT_MODALWINDOW;
		} else if (tmpStr == "textedit") {
			m_type = CREATURE_EVENT_TEXTEDIT;
		} else {
			std::cout << "[Error - CreatureEvent::configureEvent] No valid type for creature event." << str << std::endl;
			return false;
		}
	} else {
		std::cout << "[Error - CreatureEvent::configureEvent] No type for creature event."  << std::endl;
		return false;
	}

	m_isLoaded = true;
	return true;
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:46,代码来源:creatureevent.cpp


示例14: Group

bool Groups::parseGroupNode(xmlNodePtr p)
{
	if(xmlStrcmp(p->name, (const xmlChar*)"group"))
		return false;

	int32_t intValue;
	if(!readXMLInteger(p, "id", intValue))
	{
		std::cout << "[Warning - Groups::parseGroupNode] Missing group id." << std::endl;
		return false;
	}

	std::string strValue;
	int64_t int64Value;

	Group* group = new Group(intValue);
	if(readXMLString(p, "name", strValue))
	{
		group->setFullName(strValue);
		group->setName(asLowerCaseString(strValue));
	}

	if(readXMLInteger64(p, "flags", int64Value))
		group->setFlags(int64Value);

	if(readXMLInteger64(p, "customFlags", int64Value))
		group->setCustomFlags(int64Value);

	if(readXMLInteger(p, "access", intValue))
		group->setAccess(intValue);

	if(readXMLInteger(p, "ghostAccess", intValue))
		group->setGhostAccess(intValue);
	else
		group->setGhostAccess(group->getAccess());

	if(readXMLInteger(p, "violationReasons", intValue))
		group->setViolationReasons(intValue);

	if(readXMLInteger(p, "nameViolationFlags", intValue))
		group->setNameViolationFlags(intValue);

	if(readXMLInteger(p, "statementViolationFlags", intValue))
		group->setStatementViolationFlags(intValue);

	if(readXMLInteger(p, "depotLimit", intValue))
		group->setDepotLimit(intValue);

	if(readXMLInteger(p, "maxVips", intValue))
		group->setMaxVips(intValue);

	if(readXMLInteger(p, "outfit", intValue))
		group->setOutfit(intValue);

	groupsMap[group->getId()] = group;
	return true;
}
开发者ID:A-Syntax,项目名称:cryingdamson-0.3.6-8.60-V8.2,代码行数:57,代码来源:group.cpp


示例15: configureEvent

bool CreatureEvent::configureEvent(xmlNodePtr p)
{
    std::string str;
    //Name that will be used in monster xml files and
    // lua function to register events to reference this event
    if(readXMLString(p, "name", str)) {
        m_eventName = str;
    }
    else {
        std::cout << "Error: [CreatureEvent::configureEvent] No name for creature event." << std::endl;
        return false;
    }

    if(readXMLString(p, "type", str)) {
        if(asLowerCaseString(str) == "login") {
            m_type = CREATURE_EVENT_LOGIN;
        }
        else if(asLowerCaseString(str) == "logout") {
            m_type = CREATURE_EVENT_LOGOUT;
        }
        else if(asLowerCaseString(str) == "die") {
            m_type = CREATURE_EVENT_DIE;
        }
        else if(asLowerCaseString(str) == "kill") {
            m_type = CREATURE_EVENT_KILL;
        }
        else if(asLowerCaseString(str) == "advance") {
            m_type = CREATURE_EVENT_ADVANCE;
        }
        else if(asLowerCaseString(str) == "look") {
            m_type = CREATURE_EVENT_LOOK;
        }
        else {
            std::cout << "Error: [CreatureEvent::configureEvent] No valid type for creature event." << str << std::endl;
            return false;
        }
    }
    else {
        std::cout << "Error: [CreatureEvent::configureEvent] No type for creature event."  << std::endl;
        return false;
    }

    return true;
}
开发者ID:carlesgrauvila,项目名称:avesta74,代码行数:44,代码来源:creatureevent.cpp


示例16: xmlParseFile

bool Monsters::loadFromXml(bool reloading /*= false*/)
{
	loaded = false;
	xmlDocPtr doc = xmlParseFile(getFilePath(FILE_TYPE_OTHER, "monster/monsters.xml").c_str());
	if(!doc)
	{
		std::clog << "[Warning - Monsters::loadFromXml] Cannot load monsters file." << std::endl;
		std::clog << getLastXMLError() << std::endl;
		return false;
	}

	xmlNodePtr root = xmlDocGetRootElement(doc);
	if(xmlStrcmp(root->name,(const xmlChar*)"monsters"))
	{
		std::clog << "[Error - Monsters::loadFromXml] Malformed monsters file." << std::endl;
		xmlFreeDoc(doc);
		return false;
	}

	for(xmlNodePtr p = root->children; p; p = p->next)
	{
		if(p->type != XML_ELEMENT_NODE)
			continue;

		if(xmlStrcmp(p->name, (const xmlChar*)"monster"))
		{
			std::clog << "[Warning - Monsters::loadFromXml] Unknown node name (" << p->name << ")." << std::endl;
			continue;
		}

		std::string file, name;
		if(!readXMLString(p, "file", file) || !readXMLString(p, "name", name))
			continue;

		file = getFilePath(FILE_TYPE_OTHER, "monster/" + file);
		loadMonster(file, name, reloading);
	}

	xmlFreeDoc(doc);
	loaded = true;
	return loaded;
}
开发者ID:milbradt,项目名称:TFS,代码行数:42,代码来源:monsters.cpp


示例17: xmlParseFile

bool Chat::load()
{
	xmlDocPtr doc = xmlParseFile("data/chatchannels/chatchannels.xml");
	if (!doc) {
		return false;
	}

	xmlNodePtr root = xmlDocGetRootElement(doc);
	if (xmlStrcmp(root->name, (const xmlChar*)"channels") != 0) {
		xmlFreeDoc(doc);
		return false;
	}

	xmlNodePtr p = root->children;
	while (p) {
		if (xmlStrcmp(p->name, (const xmlChar*)"channel") == 0) {
			ChatChannel channel;
			channel.id = readXMLValue<uint16_t>(p, "id");
			readXMLString(p, "name", channel.name);
			channel.publicChannel = readXMLValue<int32_t>(p, "public") > 0;

			std::string scriptFile;
			if (readXMLString(p, "script", scriptFile)) {
				if (m_scriptInterface.loadFile("data/chatchannels/scripts/" + scriptFile) == 0) {
					channel.onSpeakEvent = m_scriptInterface.getEvent("onSpeak");
					channel.canJoinEvent = m_scriptInterface.getEvent("canJoin");
					channel.onJoinEvent = m_scriptInterface.getEvent("onJoin");
					channel.onLeaveEvent = m_scriptInterface.getEvent("onLeave");
				} else {
					std::cout << "[Warning - Chat::load] Can not load script: " << scriptFile << std::endl;
				}
			}

			normalChannels[channel.id] = channel;
		}
		p = p->next;
	}

	xmlFreeDoc(doc);
	return true;
}
开发者ID:Remoq7,项目名称:forgottenserver,代码行数:41,代码来源:chat.cpp


示例18: configureEvent

bool TalkAction::configureEvent(xmlNodePtr p)
{
	std::string str;
	if(readXMLString(p, "words", str)){
		m_words = str;
	}
	else{
		std::cout << "Error: [TalkAction::configureEvent] No words for TalkAction or Spell." << std::endl;
		return false;
	}
	return true;
}
开发者ID:cp1337,项目名称:devland,代码行数:12,代码来源:talkaction.cpp


示例19: loadItem

bool Item::loadItem(xmlNodePtr node, Container* parent)
{
	if (xmlStrcmp(node->name, (const xmlChar*)"item") == 0)
	{
		int32_t intValue;
		std::string strValue;
		Item* item = NULL;

		if (readXMLInteger(node, "id", intValue))
		{
			item = Item::CreateItem(intValue);
		}

		if (!item)
		{
			return false;
		}

		//optional
		if (readXMLInteger(node, "subtype", intValue))
		{
			item->setSubType(intValue);
		}

		if (readXMLInteger(node, "actionid", intValue))
		{
			item->setActionId(intValue);
		}

		if (readXMLString(node, "text", strValue))
		{
			item->setText(strValue);
		}

		if (item->getContainer())
		{
			loadContainer(node, item->getContainer());
		}

		if (parent)
		{
			parent->addItem(item);
		}

		return true;
	}

	return false;
}
开发者ID:edubart,项目名称:otserv,代码行数:49,代码来源:item.cpp


示例20: xmlParseMemory

Item* Admin::createMail(const std::string xmlData, std::string& name)
{
	xmlDocPtr doc = xmlParseMemory(xmlData.c_str(), xmlData.length());
	if(!doc)
		return NULL;

	xmlNodePtr root = xmlDocGetRootElement(doc);
	if(xmlStrcmp(root->name,(const xmlChar*)"mail"))
		return NULL;

	int32_t intValue;
	std::string strValue;

	int32_t itemId = ITEM_PARCEL;
	if(readXMLString(root, "to", strValue))
		name = strValue;

	if(readXMLInteger(root, "id", intValue))
		itemId = intValue;

	Item* mailItem = Item::CreateItem(itemId);
	mailItem->setParent(VirtualCylinder::virtualCylinder);
	if(Container* mailContainer = mailItem->getContainer())
	{
		xmlNodePtr node = root->children;
		while(node)
		{
			if(node->type != XML_ELEMENT_NODE)
			{
				node = node->next;
				continue;
			}

			if(!Item::loadItem(node, mailContainer))
			{
				delete mailContainer;
				return NULL;
			}

			node = node->next;
		}
	}

	return mailItem;
}
开发者ID:081421,项目名称:otxserver,代码行数:45,代码来源:admin.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_16bitBE函数代码示例发布时间:2022-05-30
下一篇:
C++ readXMLInteger函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap