summaryrefslogtreecommitdiff
path: root/src/resources/npcdb.cpp
diff options
context:
space:
mode:
authorPrzemysław Grzywacz <nexather@gmail.com>2013-05-04 21:57:58 +0200
committerPrzemysław Grzywacz <nexather@gmail.com>2013-05-04 21:57:58 +0200
commitbd1fdd87eed48ba3ffcc413936d6a6a60a429a97 (patch)
tree159fcd36797021939967c770febd59d9fbe1ee19 /src/resources/npcdb.cpp
parent0ef59afb6ee029a4e2247684f3f32f5bd064eb0b (diff)
downloadmana-bd1fdd87eed48ba3ffcc413936d6a6a60a429a97.tar.gz
mana-bd1fdd87eed48ba3ffcc413936d6a6a60a429a97.tar.bz2
mana-bd1fdd87eed48ba3ffcc413936d6a6a60a429a97.tar.xz
mana-bd1fdd87eed48ba3ffcc413936d6a6a60a429a97.zip
Client-side settings are now available from settings.xml
Diffstat (limited to 'src/resources/npcdb.cpp')
-rw-r--r--src/resources/npcdb.cpp71
1 files changed, 31 insertions, 40 deletions
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 45b36dfe..7d0f72b0 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -35,61 +35,52 @@ namespace
bool mLoaded = false;
}
-void NPCDB::load()
+
+void NPCDB::init()
{
if (mLoaded)
unload();
- logger->log("Initializing NPC database...");
-
- XML::Document doc("npcs.xml");
- xmlNodePtr rootNode = doc.rootNode();
+}
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "npcs"))
+void NPCDB::readNPCNode(xmlNodePtr node, const std::string &filename)
+{
+ int id = XML::getProperty(node, "id", 0);
+ if (id == 0)
{
- logger->error("NPC Database: Error while loading npcs.xml!");
+ logger->log("NPC Database: NPC with missing ID in %s", filename.c_str());
+ return;
}
- //iterate <npc>s
- for_each_xml_child_node(npcNode, rootNode)
- {
- if (!xmlStrEqual(npcNode->name, BAD_CAST "npc"))
- continue;
+ BeingInfo *currentInfo = new BeingInfo;
+
+ currentInfo->setTargetCursorSize(XML::getProperty(node,
+ "targetCursor", "medium"));
- int id = XML::getProperty(npcNode, "id", 0);
- if (id == 0)
+ SpriteDisplay display;
+ for_each_xml_child_node(spriteNode, node)
+ {
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
- logger->log("NPC Database: NPC with missing ID in npcs.xml!");
- continue;
+ SpriteReference currentSprite;
+ currentSprite.sprite = (const char*)spriteNode->xmlChildrenNode->content;
+ currentSprite.variant = XML::getProperty(spriteNode, "variant", 0);
+ display.sprites.push_back(currentSprite);
}
-
- BeingInfo *currentInfo = new BeingInfo;
-
- currentInfo->setTargetCursorSize(XML::getProperty(npcNode,
- "targetCursor", "medium"));
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, npcNode)
+ else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))
{
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
- {
- SpriteReference currentSprite;
- currentSprite.sprite = (const char*)spriteNode->xmlChildrenNode->content;
- currentSprite.variant = XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))
- {
- std::string particlefx = (const char*)spriteNode->xmlChildrenNode->content;
- display.particles.push_back(particlefx);
- }
+ std::string particlefx = (const char*)spriteNode->xmlChildrenNode->content;
+ display.particles.push_back(particlefx);
}
+ }
- currentInfo->setDisplay(display);
+ currentInfo->setDisplay(display);
- mNPCInfos[id] = currentInfo;
- }
+ mNPCInfos[id] = currentInfo;
+}
+void NPCDB::checkStatus()
+{
mLoaded = true;
}