本文整理汇总了C++中Quest::newMission方法的典型用法代码示例。如果您正苦于以下问题:C++ Quest::newMission方法的具体用法?C++ Quest::newMission怎么用?C++ Quest::newMission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quest
的用法示例。
在下文中一共展示了Quest::newMission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseQuestNode
bool Quests::parseQuestNode(xmlNodePtr p, bool checkDuplicate)
{
if(xmlStrcmp(p->name, (const xmlChar*)"quest"))
return false;
int32_t intValue;
std::string strValue;
uint32_t id = m_lastId;
if(readXMLInteger(p, "id", intValue) && id > 0)
{
id = intValue;
if(id > m_lastId)
m_lastId = id;
}
std::string name;
if(readXMLString(p, "name", strValue))
name = strValue;
uint32_t startStorageId = 0;
if(readXMLInteger(p, "startstorageid", intValue) || readXMLInteger(p, "storageId", intValue))
startStorageId = intValue;
int32_t startStorageValue = 0;
if(readXMLInteger(p, "startstoragevalue", intValue) || readXMLInteger(p, "storageValue", intValue))
startStorageValue = intValue;
Quest* quest = new Quest(name, id, startStorageId, startStorageValue);
if(!quest)
return false;
for(xmlNodePtr missionNode = p->children; missionNode; missionNode = missionNode->next)
{
if(xmlStrcmp(missionNode->name, (const xmlChar*)"mission"))
continue;
std::string missionName, missionState;
if(readXMLString(missionNode, "name", strValue))
missionName = strValue;
if(readXMLString(missionNode, "state", strValue) || readXMLString(missionNode, "description", strValue))
missionState = strValue;
uint32_t storageId = 0;
if(readXMLInteger(missionNode, "storageid", intValue) || readXMLInteger(missionNode, "storageId", intValue))
storageId = intValue;
int32_t startValue = 0, endValue = 0;
if(readXMLInteger(missionNode, "startvalue", intValue) || readXMLInteger(missionNode, "startValue", intValue))
startValue = intValue;
if(readXMLInteger(missionNode, "endvalue", intValue) || readXMLInteger(missionNode, "endValue", intValue))
endValue = intValue;
if(Mission* mission = new Mission(missionName, missionState, storageId, startValue, endValue))
{
if(missionState.empty())
{
// parse sub-states only if main is not set
for(xmlNodePtr stateNode = missionNode->children; stateNode; stateNode = stateNode->next)
{
if(xmlStrcmp(stateNode->name, (const xmlChar*)"missionstate"))
continue;
uint32_t missionId;
if(!readXMLInteger(stateNode, "id", intValue))
{
std::clog << "[Warning - Quests::parseQuestNode] Missing missionId for mission state" << std::endl;
continue;
}
missionId = intValue;
std::string description;
if(readXMLString(stateNode, "description", strValue))
description = strValue;
mission->newState(missionId, description);
}
}
quest->newMission(mission);
}
}
if(checkDuplicate)
{
for(QuestList::iterator it = quests.begin(); it != quests.end(); ++it)
{
if((*it)->getName() == name)
delete *it;
}
}
m_lastId++;
quests.push_back(quest);
return true;
}