summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-07 23:14:34 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-07 23:14:34 +0200
commitde803e103f5317856d4eadf15661ef7516cfc72a (patch)
treebd9aeacc7699ae6cf861aeeef8fb37a2a45dd92d /src
parent3d7347011cc6b33ad2c2ceb939f27200a2cae4a6 (diff)
downloadmanaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.gz
manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.bz2
manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.xz
manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.zip
Added config options to set stats and log files and paths.
Also turned the absence of an inter-server password into a fatal error while documenting it in the manaserv.xml example file. Reviewed-by: Jaxad0127.
Diffstat (limited to 'src')
-rw-r--r--src/account-server/main-account.cpp42
-rw-r--r--src/game-server/main-game.cpp19
2 files changed, 34 insertions, 27 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 33df1cb7..733369d7 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -60,6 +60,8 @@ static bool running = true; /**< Determines if server keeps running */
utils::StringFilter *stringFilter; /**< Slang's Filter */
+static std::string statisticsFile = std::string();
+
/** Database handler. */
Storage *storage;
@@ -112,7 +114,10 @@ static void initializeConfiguration(std::string configPath = std::string())
// Check inter-server password.
if (Configuration::getValue("net_password", "") == "")
- LOG_WARN("SECURITY WARNING: 'net_password' not set!");
+ {
+ LOG_FATAL("SECURITY WARNING: 'net_password' not set!");
+ exit(3);
+ }
}
/**
@@ -133,30 +138,36 @@ static void initialize()
// Set enet to quit on exit.
atexit(enet_deinitialize);
-#if defined LOG_FILE
- std::string logPath = LOG_FILE;
-#else
- std::string logPath = DEFAULT_LOG_FILE;
-#endif // defined LOG_FILE
+ std::string logFile = Configuration::getValue("log_accountServerFile",
+ DEFAULT_LOG_FILE);
// Initialize PhysicsFS
PHYSFS_init("");
// Initialize the logger.
- Logger::setLogFile(logPath);
+ Logger::setLogFile(logFile);
// write the messages to both the screen and the log file.
Logger::setTeeMode(true);
- LOG_INFO("Using log file: " << logPath);
+ LOG_INFO("Using log file: " << logFile);
+
+ // Indicate in which file the statistics are put.
+ statisticsFile = Configuration::getValue("log_statisticsFile",
+ DEFAULT_STATS_FILE);
+
+ LOG_INFO("Using statistics file: " << statisticsFile);
ResourceManager::initialize();
// Open database
- try {
+ try
+ {
storage = new Storage;
storage->open();
- } catch (std::string &error) {
+ }
+ catch (std::string &error)
+ {
LOG_FATAL("Error opening the database: " << error);
exit(1);
}
@@ -174,7 +185,8 @@ static void initialize()
chatHandler = new ChatHandler;
// --- Initialize enet.
- if (enet_initialize() != 0) {
+ if (enet_initialize() != 0)
+ {
LOG_FATAL("An error occurred while initializing ENet");
exit(2);
}
@@ -222,13 +234,7 @@ static void deinitializeServer()
*/
static void dumpStatistics()
{
-#if defined STATS_FILE
- std::string path = STATS_FILE;
-#else
- std::string path = DEFAULT_STATS_FILE;
-#endif
-
- std::ofstream os(path.c_str());
+ std::ofstream os(statisticsFile.c_str());
os << "<statistics>\n";
GameServerHandler::dumpStatistics(os);
os << "</statistics>\n";
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index b42b6919..364745d4 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -140,7 +140,10 @@ static void initializeConfiguration(std::string configPath = std::string())
// Check inter-server password.
if (Configuration::getValue("net_password", "") == "")
- LOG_WARN("SECURITY WARNING: 'net_password' not set!");
+ {
+ LOG_FATAL("SECURITY WARNING: 'net_password' not set!");
+ exit(3);
+ }
}
static void initializeServer()
@@ -155,21 +158,18 @@ static void initializeServer()
signal(SIGINT, closeGracefully);
signal(SIGTERM, closeGracefully);
-#if defined LOG_FILE
- std::string logPath = LOG_FILE;
-#else
- std::string logPath = DEFAULT_LOG_FILE;
-#endif // defined LOG_FILE
+ std::string logFile = Configuration::getValue("log_gameServerFile",
+ DEFAULT_LOG_FILE);
// Initialize PhysicsFS
PHYSFS_init("");
// Initialize the logger.
- Logger::setLogFile(logPath);
+ Logger::setLogFile(logFile);
// Write the messages to both the screen and the log file.
Logger::setTeeMode(true);
- LOG_INFO("Using log file: " << logPath);
+ LOG_INFO("Using log file: " << logFile);
// --- Initialize the managers
// Initialize the slang's and double quotes filter.
@@ -200,7 +200,8 @@ static void initializeServer()
gBandwidth = new BandwidthMonitor;
// --- Initialize enet.
- if (enet_initialize() != 0) {
+ if (enet_initialize() != 0)
+ {
LOG_FATAL("An error occurred while initializing ENet");
exit(2);
}