summaryrefslogtreecommitdiff
path: root/src/account-server
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-13 13:39:52 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-16 23:25:19 +0200
commite5c7ef4573adcdcafec7523a77724b171456b215 (patch)
tree797833ddc766d92131da86096de81741a94f4d20 /src/account-server
parent0a48f0d41653d0a0758fc84fd6a18830bd37da18 (diff)
downloadmanaserv-e5c7ef4573adcdcafec7523a77724b171456b215.tar.gz
manaserv-e5c7ef4573adcdcafec7523a77724b171456b215.tar.bz2
manaserv-e5c7ef4573adcdcafec7523a77724b171456b215.tar.xz
manaserv-e5c7ef4573adcdcafec7523a77724b171456b215.zip
Changed and split up the default location for loading data
Instead of loading data from a 'data' directory in the current working directory, the server now uses clientDataPath and serverDataPath as specified in the configuration. This removes the need to set up symbolic links in order to merge these two types of data. The default values point to example/clientdata and example/serverdata, where a minimal example world can be developed to make setting up an initial server quick and easy. The XML::Document convenience class was copied over from the client. Also, the ResourceManager is now shared between both servers, since the account client is reading items.xml. Reviewed-by: Jared Adams
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/main-account.cpp33
-rw-r--r--src/account-server/storage.cpp20
2 files changed, 18 insertions, 35 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 0a3fd5f5..460a5f1b 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -18,14 +18,6 @@
* along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cstdlib>
-#include <getopt.h>
-#include <signal.h>
-#include <iostream>
-#include <fstream>
-#include <physfs.h>
-#include <enet/enet.h>
-
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
@@ -38,6 +30,7 @@
#include "chat-server/guildmanager.hpp"
#include "chat-server/post.hpp"
#include "common/configuration.hpp"
+#include "common/resourcemanager.hpp"
#include "net/bandwidth.hpp"
#include "net/connectionhandler.hpp"
#include "net/messageout.hpp"
@@ -46,6 +39,14 @@
#include "utils/stringfilter.h"
#include "utils/timer.h"
+#include <cstdlib>
+#include <getopt.h>
+#include <signal.h>
+#include <iostream>
+#include <fstream>
+#include <physfs.h>
+#include <enet/enet.h>
+
using utils::Logger;
// Default options that automake should be able to override.
@@ -63,16 +64,9 @@ Storage *storage;
/** Communications (chat) message handler */
ChatHandler *chatHandler;
-/** Chat Channels Manager */
ChatChannelManager *chatChannelManager;
-
-/** Guild Manager */
GuildManager *guildManager;
-
-/** Post Manager */
PostManager *postalManager;
-
-/** Bandwidth Monitor */
BandwidthMonitor *gBandwidth;
/** Callback used when SIGQUIT signal is received. */
@@ -147,6 +141,8 @@ static void initialize()
LOG_INFO("Using config file: " << configPath);
LOG_INFO("Using log file: " << logPath);
+ ResourceManager::initialize();
+
// check inter-server password
if (Configuration::getValue("net_password", "") == "")
{
@@ -164,15 +160,10 @@ static void initialize()
}
// --- Initialize the managers
- // Initialize the slang's and double quotes filter.
- stringFilter = new StringFilter;
- // Initialize the Chat channels manager
+ stringFilter = new StringFilter; // The slang's and double quotes filter.
chatChannelManager = new ChatChannelManager;
- // Initialise the Guild manager
guildManager = new GuildManager;
- // Initialise the post manager
postalManager = new PostManager;
- // Initialise the bandwidth monitor
gBandwidth = new BandwidthMonitor;
// --- Initialize the global handlers
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 6e11f598..39735067 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -36,8 +36,7 @@
#include "utils/xml.hpp"
#include "utils/sha256.h"
-// TODO: make data/items.xml a constant or read it from config file
-static const char *DEFAULT_ITEM_FILE = "data/items.xml";
+static const char *DEFAULT_ITEM_FILE = "items.xml";
// defines the supported db version
static const char *DB_VERSION_PARAMETER = "database_version";
@@ -1920,24 +1919,18 @@ void Storage::deletePost(Letter *letter)
*/
void Storage::syncDatabase()
{
- xmlDocPtr doc = xmlReadFile(DEFAULT_ITEM_FILE, NULL, 0);
- if (!doc)
- {
- LOG_ERROR("Item Manager: Error while parsing item database (items.xml)!");
- return;
- }
+ XML::Document doc(DEFAULT_ITEM_FILE);
+ xmlNodePtr rootNode = doc.rootNode();
- xmlNodePtr node = xmlDocGetRootElement(doc);
- if (!node || !xmlStrEqual(node->name, BAD_CAST "items"))
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items"))
{
- LOG_ERROR("Item Manager:(items.xml) is not a valid database file!");
- xmlFreeDoc(doc);
+ LOG_ERROR("Item Manager: Error while parsing item database (items.xml)!");
return;
}
mDb->beginTransaction();
int itmCount = 0;
- for (node = node->xmlChildrenNode; node != NULL; node = node->next)
+ for_each_xml_child_node(node, rootNode)
{
// Try to load the version of the item database. The version is defined
// as subversion tag embedded as XML attribute. So every modification
@@ -2024,7 +2017,6 @@ void Storage::syncDatabase()
}
mDb->commitTransaction();
- xmlFreeDoc(doc);
}
/**