本文整理汇总了C++中Monsters::loadMonster方法的典型用法代码示例。如果您正苦于以下问题:C++ Monsters::loadMonster方法的具体用法?C++ Monsters::loadMonster怎么用?C++ Monsters::loadMonster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monsters
的用法示例。
在下文中一共展示了Monsters::loadMonster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromXml
//.........这里部分代码省略.........
if(!supported)
{
std::clog << "[Warning - ScriptManager::loadFromXml] Your server is not supported by mod " << file << std::endl;
xmlFreeDoc(doc);
return false;
}
if(mod.enabled)
{
std::string scriptsPath = getFilePath(FILE_TYPE_MOD, "scripts/");
for(p = root->children; p; p = p->next)
{
if(!xmlStrcmp(p->name, (const xmlChar*)"quest"))
Quests::getInstance()->parseQuestNode(p, modsLoaded);
else if(!xmlStrcmp(p->name, (const xmlChar*)"outfit"))
Outfits::getInstance()->parseOutfitNode(p);
else if(!xmlStrcmp(p->name, (const xmlChar*)"vocation"))
Vocations::getInstance()->parseVocationNode(p); //duplicates checking is dangerous, shouldn't be performed until we find some good solution
else if(!xmlStrcmp(p->name, (const xmlChar*)"group"))
Groups::getInstance()->parseGroupNode(p); //duplicates checking is dangerous, shouldn't be performed until we find some good solution
else if(!xmlStrcmp(p->name, (const xmlChar*)"raid"))
Raids::getInstance()->parseRaidNode(p, modsLoaded, FILE_TYPE_MOD); //TODO: support mods path
else if(!xmlStrcmp(p->name, (const xmlChar*)"spawn"))
Spawns::getInstance()->parseSpawnNode(p, modsLoaded);
else if(!xmlStrcmp(p->name, (const xmlChar*)"channel"))
g_chat.parseChannelNode(p); //TODO: duplicates- channel destructor needs to send closeChannel to users!
else if(!xmlStrcmp(p->name, (const xmlChar*)"npc"))
g_npcs.parseNpcNode(p, FILE_TYPE_MOD);
else if(!xmlStrcmp(p->name, (const xmlChar*)"monster"))
{
std::string path, name;
if((readXMLString(p, "file", path) || readXMLString(p, "path", path)) && readXMLString(p, "name", name))
g_monsters.loadMonster(getFilePath(FILE_TYPE_MOD, "monster/" + path), name, true);
}
else if(!xmlStrcmp(p->name, (const xmlChar*)"item"))
{
if(readXMLInteger(p, "id", intValue))
Item::items.parseItemNode(p, intValue);
}
if(!xmlStrcmp(p->name, (const xmlChar*)"description") || !xmlStrcmp(p->name, (const xmlChar*)"info"))
{
if(parseXMLContentString(p->children, strValue))
{
replaceString(strValue, "\t", "");
mod.description = strValue;
}
}
else if(!xmlStrcmp(p->name, (const xmlChar*)"lib") || !xmlStrcmp(p->name, (const xmlChar*)"config"))
{
if(!readXMLString(p, "name", strValue))
{
if(!xmlStrcmp(p->name, (const xmlChar*)"lib"))
strValue = mod.name + "-lib";
else if(!xmlStrcmp(p->name, (const xmlChar*)"config"))
strValue = mod.name + "-config";
}
else
toLowerCaseString(strValue);
std::string strLib;
if(parseXMLContentString(p->children, strLib))
{
LibMap::iterator it = libMap.find(strValue);
if(it == libMap.end())
{
示例2: loadFromXml
bool ScriptingManager::loadFromXml(const std::string& file, bool& enabled)
{
std::string modPath = getFilePath(FILE_TYPE_MOD, file);
xmlDocPtr doc = xmlParseFile(modPath.c_str());
if(!doc)
{
std::cout << "[Error - ScriptingManager::loadFromXml] Cannot load mod " << modPath << std::endl;
std::cout << getLastXMLError() << std::endl;
return false;
}
int32_t intValue;
std::string strValue;
xmlNodePtr p, root = xmlDocGetRootElement(doc);
if(xmlStrcmp(root->name,(const xmlChar*)"mod"))
{
std::cout << "[Error - ScriptingManager::loadFromXml] Malformed mod " << modPath << std::endl;
std::cout << getLastXMLError() << std::endl;
xmlFreeDoc(doc);
return false;
}
if(!readXMLString(root, "name", strValue))
{
std::cout << "[Warning - ScriptingManager::loadFromXml] Empty name in mod " << modPath << std::endl;
xmlFreeDoc(doc);
return false;
}
ModBlock mod;
mod.enabled = false;
if(readXMLString(root, "enabled", strValue) && booleanString(strValue))
mod.enabled = true;
mod.file = file;
mod.name = strValue;
if(readXMLString(root, "author", strValue))
mod.author = strValue;
if(readXMLString(root, "version", strValue))
mod.version = strValue;
if(readXMLString(root, "contact", strValue))
mod.contact = strValue;
if(mod.enabled)
{
std::string scriptsPath = getFilePath(FILE_TYPE_MOD, "scripts/");
p = root->children;
while(p)
{
if(!xmlStrcmp(p->name, (const xmlChar*)"quest"))
Quests::getInstance()->parseQuestNode(p, modsLoaded);
else if(!xmlStrcmp(p->name, (const xmlChar*)"outfit"))
Outfits::getInstance()->parseOutfitNode(p); //TODO: duplicates (I just don't remember how it works here)
else if(!xmlStrcmp(p->name, (const xmlChar*)"vocation"))
Vocations::getInstance()->parseVocationNode(p); //duplicates checking is dangerous, shouldn't be performed
else if(!xmlStrcmp(p->name, (const xmlChar*)"group"))
Groups::getInstance()->parseGroupNode(p); //duplicates checking is dangerous, shouldn't be performed
else if(!xmlStrcmp(p->name, (const xmlChar*)"raid"))
Raids::getInstance()->parseRaidNode(p, modsLoaded, FILE_TYPE_MOD);
else if(!xmlStrcmp(p->name, (const xmlChar*)"spawn"))
Spawns::getInstance()->parseSpawnNode(p, modsLoaded);
else if(!xmlStrcmp(p->name, (const xmlChar*)"channel"))
g_chat.parseChannelNode(p); //TODO: duplicates (channel destructor needs sending self close to users)
else if(!xmlStrcmp(p->name, (const xmlChar*)"monster"))
{
std::string file, name;
if(readXMLString(p, "file", file) && readXMLString(p, "name", name))
{
file = getFilePath(FILE_TYPE_MOD, "monster/" + file);
g_monsters.loadMonster(file, name, true);
}
}
else if(!xmlStrcmp(p->name, (const xmlChar*)"item"))
{
if(readXMLInteger(p, "id", intValue))
Item::items.parseItemNode(p, intValue); //duplicates checking isn't necessary here
}
if(!xmlStrcmp(p->name, (const xmlChar*)"description") || !xmlStrcmp(p->name, (const xmlChar*)"info"))
{
if(parseXMLContentString(p->children, strValue))
{
replaceString(strValue, "\t", "");
mod.description = strValue;
}
}
else if(!xmlStrcmp(p->name, (const xmlChar*)"lib") || !xmlStrcmp(p->name, (const xmlChar*)"config"))
{
if(!readXMLString(p, "name", strValue))
{
std::cout << "[Warning - ScriptingManager::loadFromXml] Lib without name in mod " << strValue << std::endl;
p = p->next;
continue;
}
toLowerCaseString(strValue);
std::string strLib;
if(parseXMLContentString(p->children, strLib))
{
//.........这里部分代码省略.........