summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-23 22:06:33 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-24 19:08:09 +0100
commita3dc6e19b1cb7eec1dcbbcef5d370f4ab55a9ade (patch)
tree91b7bd840756eff88d59617054854d55bb5910d2
parent94d97450bc3a52cd90baa696320bd08d91ac301f (diff)
downloadmanaserv-a3dc6e19b1cb7eec1dcbbcef5d370f4ab55a9ade.tar.gz
manaserv-a3dc6e19b1cb7eec1dcbbcef5d370f4ab55a9ade.tar.bz2
manaserv-a3dc6e19b1cb7eec1dcbbcef5d370f4ab55a9ade.tar.xz
manaserv-a3dc6e19b1cb7eec1dcbbcef5d370f4ab55a9ade.zip
Rely more on the functionality in XML::Document
By default XML::Document will use the ResourceManager to resolve the file name you pass to it. There is no point in disabling that functionality only to resolve it manually. Reviewed-by: Jared Adams
-rw-r--r--src/account-server/accounthandler.cpp11
-rw-r--r--src/common/configuration.cpp12
-rw-r--r--src/game-server/attributemanager.cpp12
-rw-r--r--src/game-server/itemmanager.cpp28
-rw-r--r--src/game-server/mapmanager.cpp12
-rw-r--r--src/game-server/monstermanager.cpp14
-rw-r--r--src/game-server/statusmanager.cpp12
7 files changed, 22 insertions, 79 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index cb587ae5..aada5dbb 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -28,7 +28,6 @@
#include "chat-server/chathandler.h"
#include "common/configuration.h"
#include "common/manaserv_protocol.h"
-#include "common/resourcemanager.h"
#include "common/transaction.h"
#include "net/connectionhandler.h"
#include "net/messagein.h"
@@ -150,15 +149,9 @@ AccountHandler::AccountHandler(const std::string &attributesFile):
mUpdateHost(Configuration::getValue("net_defaultUpdateHost", std::string())),
mDataUrl(Configuration::getValue("net_clientDataUrl", std::string()))
{
- std::string absPathFile = ResourceManager::resolve(attributesFile);
- if (absPathFile.empty())
- {
- LOG_FATAL("Account handler: Could not find " << attributesFile << "!");
- exit(EXIT_XML_NOT_FOUND);
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(attributesFile);
xmlNodePtr node = doc.rootNode();
+
if (!node || !xmlStrEqual(node->name, BAD_CAST "attributes"))
{
LOG_FATAL("Account handler: " << attributesFile << ": "
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 9d0e81ee..89b77e32 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -38,18 +38,11 @@ bool Configuration::initialize(const std::string &filename)
{
configPath = filename;
- xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
-
- if (!doc) {
- LOG_WARN("Could not read configuration file '" << filename.c_str() << "'.");
- return false;
- }
-
- xmlNodePtr node = xmlDocGetRootElement(doc);
+ XML::Document doc(filename, false);
+ xmlNodePtr node = doc.rootNode();
if (!node || !xmlStrEqual(node->name, BAD_CAST "configuration")) {
LOG_WARN("No configuration file '" << filename.c_str() << "'.");
- xmlFreeDoc(doc);
return false;
}
@@ -67,7 +60,6 @@ bool Configuration::initialize(const std::string &filename)
options[key] = value;
}
- xmlFreeDoc(doc);
return true;
}
diff --git a/src/game-server/attributemanager.cpp b/src/game-server/attributemanager.cpp
index 6cbdae9f..31566bed 100644
--- a/src/game-server/attributemanager.cpp
+++ b/src/game-server/attributemanager.cpp
@@ -21,7 +21,6 @@
#include "game-server/attributemanager.h"
#include "common/defines.h"
-#include "common/resourcemanager.h"
#include "utils/string.h"
#include "utils/logger.h"
@@ -112,16 +111,9 @@ const std::string *AttributeManager::getTag(const ModifierLocation &location) co
void AttributeManager::readAttributesFile()
{
- std::string absPathFile = ResourceManager::resolve(mAttributeReferenceFile);
- if (absPathFile.empty())
- {
- LOG_FATAL("Attribute Manager: Could not find "
- << mAttributeReferenceFile << "!");
- exit(EXIT_XML_NOT_FOUND);
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(mAttributeReferenceFile);
xmlNodePtr node = doc.rootNode();
+
if (!node || !xmlStrEqual(node->name, BAD_CAST "attributes"))
{
LOG_FATAL("Attribute Manager: " << mAttributeReferenceFile
diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp
index b9ac2feb..ab9d511e 100644
--- a/src/game-server/itemmanager.cpp
+++ b/src/game-server/itemmanager.cpp
@@ -21,7 +21,6 @@
#include "game-server/itemmanager.h"
#include "common/defines.h"
-#include "common/resourcemanager.h"
#include "game-server/attributemanager.h"
#include "game-server/item.h"
#include "game-server/skillmanager.h"
@@ -121,23 +120,17 @@ bool ItemManager::isEquipSlotVisible(unsigned int id) const
void ItemManager::readEquipSlotsFile()
{
- std::string absPathFile = ResourceManager::resolve(mEquipSlotsFile);
- if (absPathFile.empty()) {
- LOG_ERROR("Item Manager: Could not find " << mEquipSlotsFile << "!");
- return;
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(mEquipSlotsFile);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "equip-slots"))
{
LOG_ERROR("Item Manager: Error while parsing equip slots database ("
- << absPathFile << ")!");
+ << mEquipSlotsFile << ")!");
return;
}
- LOG_INFO("Loading equip slots: " << absPathFile);
+ LOG_INFO("Loading equip slots: " << mEquipSlotsFile);
unsigned totalCount = 0;
unsigned slotCount = 0;
@@ -179,24 +172,17 @@ void ItemManager::readEquipSlotsFile()
void ItemManager::readItemsFile()
{
- std::string absPathFile = ResourceManager::resolve(mItemsFile);
- if (absPathFile.empty())
- {
- LOG_ERROR("Item Manager: Could not find " << mItemsFile << "!");
- return;
- }
-
- XML::Document doc2(absPathFile, false);
+ XML::Document doc2(mItemsFile);
xmlNodePtr rootNode = doc2.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items"))
{
LOG_ERROR("Item Manager: Error while parsing item database ("
- << absPathFile << ")!");
+ << mItemsFile << ")!");
return;
}
- LOG_INFO("Loading item reference: " << absPathFile);
+ LOG_INFO("Loading item reference: " << mItemsFile);
for_each_xml_child_node(node, rootNode)
{
@@ -207,7 +193,7 @@ void ItemManager::readItemsFile()
}
LOG_INFO("Loaded " << mItemClasses.size() << " items from "
- << absPathFile << ".");
+ << mItemsFile << ".");
}
void ItemManager::readItemNode(xmlNodePtr itemNode)
diff --git a/src/game-server/mapmanager.cpp b/src/game-server/mapmanager.cpp
index fce5cc5a..094af923 100644
--- a/src/game-server/mapmanager.cpp
+++ b/src/game-server/mapmanager.cpp
@@ -44,23 +44,17 @@ int MapManager::initialize(const std::string &mapReferenceFile)
// Indicates the number of maps loaded successfully
int loadedMaps = 0;
- std::string absPathFile = ResourceManager::resolve(mapReferenceFile);
- if (absPathFile.empty()) {
- LOG_ERROR("Map Manager: Could not find " << mapReferenceFile << "!");
- return loadedMaps;
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(mapReferenceFile);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "maps"))
{
LOG_ERROR("Item Manager: Error while parsing map database ("
- << absPathFile << ")!");
+ << mapReferenceFile << ")!");
return loadedMaps;
}
- LOG_INFO("Loading map reference: " << absPathFile);
+ LOG_INFO("Loading map reference: " << mapReferenceFile);
for_each_xml_child_node(node, rootNode)
{
if (!xmlStrEqual(node->name, BAD_CAST "map"))
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index 5fb0b675..cef6b7db 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -20,7 +20,6 @@
#include "game-server/monstermanager.h"
-#include "common/resourcemanager.h"
#include "game-server/attributemanager.h"
#include "game-server/itemmanager.h"
#include "game-server/monster.h"
@@ -60,24 +59,17 @@ void MonsterManager::initialize()
void MonsterManager::reload()
{
- std::string absPathFile = ResourceManager::resolve(mMonsterReferenceFile);
- if (absPathFile.empty()) {
- LOG_ERROR("Monster Manager: Could not find "
- << mMonsterReferenceFile << "!");
- return;
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(mMonsterReferenceFile);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters"))
{
LOG_ERROR("Monster Manager: Error while parsing monster database ("
- << absPathFile << ")!");
+ << mMonsterReferenceFile << ")!");
return;
}
- LOG_INFO("Loading monster reference: " << absPathFile);
+ LOG_INFO("Loading monster reference: " << mMonsterReferenceFile);
int nbMonsters = 0;
for_each_xml_child_node(node, rootNode)
{
diff --git a/src/game-server/statusmanager.cpp b/src/game-server/statusmanager.cpp
index 3d79d892..77519754 100644
--- a/src/game-server/statusmanager.cpp
+++ b/src/game-server/statusmanager.cpp
@@ -42,23 +42,17 @@ void StatusManager::initialize(const std::string &file)
void StatusManager::reload()
{
- std::string absPathFile = ResourceManager::resolve(statusReferenceFile);
- if (absPathFile.empty()) {
- LOG_ERROR("Status Manager: Could not find " << statusReferenceFile << "!");
- return;
- }
-
- XML::Document doc(absPathFile, false);
+ XML::Document doc(statusReferenceFile);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects"))
{
LOG_ERROR("Status Manager: Error while parsing status database ("
- << absPathFile << ")!");
+ << statusReferenceFile << ")!");
return;
}
- LOG_INFO("Loading status reference: " << absPathFile);
+ LOG_INFO("Loading status reference: " << statusReferenceFile);
for_each_xml_child_node(node, rootNode)
{
if (!xmlStrEqual(node->name, BAD_CAST "status-effect"))