diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-09-22 18:45:57 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-09-22 18:45:57 +0000 |
commit | ac5375e554e882e0b56eeed9b6e51c06c8d37656 (patch) | |
tree | 8c0095d23e880ab112dacc7e94505aac86d04dd7 /src/account-server | |
parent | 88e3d219588052a8ab222ab4f6f2b27c9c29c1b2 (diff) | |
download | manaserv-ac5375e554e882e0b56eeed9b6e51c06c8d37656.tar.gz manaserv-ac5375e554e882e0b56eeed9b6e51c06c8d37656.tar.bz2 manaserv-ac5375e554e882e0b56eeed9b6e51c06c8d37656.tar.xz manaserv-ac5375e554e882e0b56eeed9b6e51c06c8d37656.zip |
Cleaned both configuration and resource managers.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/accounthandler.cpp | 23 | ||||
-rw-r--r-- | src/account-server/dalstorage.cpp | 4 | ||||
-rw-r--r-- | src/account-server/main-account.cpp | 23 |
3 files changed, 24 insertions, 26 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 9eb6264e..77e66660 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -24,7 +24,6 @@ #include "account-server/accounthandler.hpp" #include "defines.h" -#include "configuration.h" #include "point.h" #include "account-server/account.hpp" #include "account-server/accountclient.hpp" @@ -34,6 +33,7 @@ #include "account-server/guildmanager.hpp" #include "account-server/serverhandler.hpp" #include "chat-server/chathandler.hpp" +#include "common/configuration.hpp" #include "net/connectionhandler.hpp" #include "net/messagein.hpp" #include "net/messageout.hpp" @@ -182,7 +182,7 @@ AccountHandler::handleLoginMessage(AccountClient &computer, MessageIn &msg) int clientVersion = msg.readLong(); - if (clientVersion < config.getValue("clientVersion", 0)) + if (clientVersion < Configuration::getValue("clientVersion", 0)) { reply.writeByte(LOGIN_INVALID_VERSION); computer.send(reply); @@ -296,7 +296,7 @@ AccountHandler::handleRegisterMessage(AccountClient &computer, MessageIn &msg) { reply.writeByte(ERRMSG_FAILURE); } - else if (clientVersion < config.getValue("clientVersion", 0)) + else if (clientVersion < Configuration::getValue("clientVersion", 0)) { reply.writeByte(REGISTER_INVALID_VERSION); } @@ -392,8 +392,8 @@ AccountHandler::handleUnregisterMessage(AccountClient &computer, } // Delete account and associated characters - LOG_DEBUG("Unregistered \"" << username - << "\", AccountID: " << acc->getID()); + LOG_INFO("Unregistered \"" << username + << "\", AccountID: " << acc->getID()); storage->delAccount(acc); reply.writeByte(ERRMSG_OK); @@ -589,9 +589,9 @@ AccountHandler::handleCharacterCreateMessage(AccountClient &computer, newCharacter->setGender(gender); newCharacter->setHairStyle(hairStyle); newCharacter->setHairColor(hairColor); - newCharacter->setMapId((int) config.getValue("defaultMap", 1)); - Point startingPos((int) config.getValue("startX", 512), - (int) config.getValue("startY", 512)); + newCharacter->setMapId(Configuration::getValue("defaultMap", 1)); + Point startingPos(Configuration::getValue("startX", 512), + Configuration::getValue("startY", 512)); newCharacter->setPosition(startingPos); acc->addCharacter(newCharacter); @@ -660,9 +660,10 @@ handleCharacterSelectMessage(AccountClient &computer, MessageIn &msg) reply.writeShort(port); // TODO: get correct address and port for the chat server - reply.writeString(config.getValue("accountServerAddress", "localhost")); - reply.writeShort(int(config.getValue("accountServerPort", - DEFAULT_SERVER_PORT)) + 2); + reply.writeString(Configuration::getValue("accountServerAddress", + "localhost")); + reply.writeShort(Configuration::getValue("accountServerPort", + DEFAULT_SERVER_PORT) + 2); serverHandler->registerGameClient(magic_token, selectedChar); registerChatClient(magic_token, selectedChar->getName(), AL_NORMAL); diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp index 08b149e2..2fe9c697 100644 --- a/src/account-server/dalstorage.cpp +++ b/src/account-server/dalstorage.cpp @@ -25,13 +25,13 @@ #include "account-server/dalstorage.hpp" -#include "configuration.h" #include "point.h" #include "account-server/account.hpp" #include "account-server/guild.hpp" #include "account-server/guildmanager.hpp" #include "account-server/dalstoragesql.hpp" #include "chat-server/chatchannel.hpp" +#include "common/configuration.hpp" #include "dal/dalexcept.h" #include "dal/dataproviderfactory.h" #include "utils/functors.h" @@ -297,7 +297,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne { // Set character to default map and one of the default location // Default map is to be 1, as not found return value will be 0. - character->setMapId((int)config.getValue("defaultMap", 1)); + character->setMapId(Configuration::getValue("defaultMap", 1)); } /* Fill the account-related fields. Last step, as it may require a new diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 68cb134b..e684cbad 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -28,18 +28,17 @@ #include <physfs.h> #include <enet/enet.h> -#if (defined __USE_UNIX98 || defined __FreeBSD__) +#ifdef HAVE_CONFIG_H #include "../config.h" #endif -#include "configuration.h" -#include "resourcemanager.h" #include "account-server/accounthandler.hpp" #include "account-server/guildmanager.hpp" #include "account-server/serverhandler.hpp" #include "account-server/dalstorage.hpp" #include "chat-server/chatchannelmanager.hpp" #include "chat-server/chathandler.hpp" +#include "common/configuration.hpp" #include "net/connectionhandler.hpp" #include "net/messageout.hpp" #include "utils/logger.h" @@ -55,8 +54,6 @@ static bool running = true; /**< Determines if server keeps running */ -Configuration config; /**< XML config reader */ - utils::StringFilter *stringFilter; /**< Slang's Filter */ /** Database handler. */ @@ -145,7 +142,7 @@ static void initialize() // write the messages to both the screen and the log file. Logger::setTeeMode(true); - config.init(configPath); + Configuration::initialize(configPath); LOG_INFO("Using Config File: " << configPath); LOG_INFO("Using Log File: " << logPath); @@ -155,7 +152,7 @@ static void initialize() // --- Initialize the managers // Initialize the slang's and double quotes filter. - stringFilter = new StringFilter(&config); + stringFilter = new StringFilter; // Initialize the Chat channels manager chatChannelManager = new ChatChannelManager; @@ -167,9 +164,9 @@ static void initialize() // --- Initialize the global handlers // FIXME: Make the global handlers global vars or part of a bigger // singleton or a local variable in the event-loop - accountHandler = new AccountHandler(); - chatHandler = new ChatHandler(); - serverHandler = new ServerHandler(); + accountHandler = new AccountHandler; + chatHandler = new ChatHandler; + serverHandler = new ServerHandler; // --- Initialize enet. if (enet_initialize() != 0) { @@ -192,7 +189,7 @@ static void deinitialize() { delete stringFilter; // Write configuration file - config.write(); + Configuration::deinitialize(); // Quit ENet enet_deinitialize(); @@ -290,7 +287,7 @@ static void parseOptions(int argc, char *argv[]) // Change the port to listen on. unsigned short portToListenOn; portToListenOn = atoi(optarg); - config.setValue("ListenOnPort", portToListenOn); + Configuration::setValue("ListenOnPort", portToListenOn); LOG_INFO("Setting Default Port to " << portToListenOn); break; } @@ -311,7 +308,7 @@ int main(int argc, char *argv[]) // General Initialization initialize(); - int port = int(config.getValue("accountServerPort", DEFAULT_SERVER_PORT)); + int port = Configuration::getValue("accountServerPort", DEFAULT_SERVER_PORT); if (!accountHandler->startListen(port) || !serverHandler->startListen(port + 1) || !chatHandler->startListen(port + 2)) |