diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-11-01 13:44:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-11-01 17:13:46 +0100 |
commit | 5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed (patch) | |
tree | 19d2d94b8c90ccb9a24529102431e6a68c0b7a4b /src/game-server | |
parent | fba5a19e5885e3f4ddca2c249a96fbbe24c846b8 (diff) | |
download | manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.gz manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.bz2 manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.xz manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.zip |
Have one place where the Configuration is initialized
Also, removed the fallback to the standard config file path when a
config file path is specified on the command line. Surely that's not
what you would want to happen.
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/main-game.cpp | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index a9a6652a..e7a06c84 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -63,7 +63,6 @@ using utils::Logger; // Default options that automake should be able to override. #define DEFAULT_LOG_FILE "manaserv-game.log" -#define DEFAULT_CONFIG_FILE "manaserv.xml" #define DEFAULT_ITEMSDB_FILE "items.xml" #define DEFAULT_EQUIPDB_FILE "equip.xml" #define DEFAULT_SKILLSDB_FILE "skills.xml" @@ -108,47 +107,6 @@ static void closeGracefully(int) running = false; } -static void initializeConfiguration(std::string configPath = std::string()) -{ - if (configPath.empty()) - configPath = DEFAULT_CONFIG_FILE; - - bool configFound = true; - if (!Configuration::initialize(configPath)) - { - configFound = false; - - // If the config file isn't the default and fail to load, - // we try the default one with a warning. - if (configPath.compare(DEFAULT_CONFIG_FILE)) - { - LOG_WARN("Invalid config path: " << configPath - << ". Trying default value: " << DEFAULT_CONFIG_FILE "."); - configPath = DEFAULT_CONFIG_FILE; - configFound = true; - - if (!Configuration::initialize(configPath)) - configFound = false; - } - - if (!configFound) - { - LOG_FATAL("Refusing to run without configuration!" << std::endl - << "Invalid config path: " << configPath << "."); - exit(EXIT_CONFIG_NOT_FOUND); - } - } - - LOG_INFO("Using config file: " << configPath); - - // Check inter-server password. - if (Configuration::getValue("net_password", std::string()).empty()) - { - LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); - exit(EXIT_BAD_CONFIG_PARAMETER); - } -} - static void initializeServer() { // Used to close via process signals @@ -266,7 +224,6 @@ static void printHelp() struct CommandLineOptions { CommandLineOptions(): - configPath(DEFAULT_CONFIG_FILE), verbosity(Logger::Warn), verbosityChanged(false), port(DEFAULT_SERVER_PORT + 3), @@ -339,7 +296,18 @@ int main(int argc, char *argv[]) CommandLineOptions options; parseOptions(argc, argv, options); - initializeConfiguration(options.configPath); + if (!Configuration::initialize(options.configPath)) + { + LOG_FATAL("Refusing to run without configuration!"); + exit(EXIT_CONFIG_NOT_FOUND); + } + + // Check inter-server password. + if (Configuration::getValue("net_password", std::string()).empty()) + { + LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); + exit(EXIT_BAD_CONFIG_PARAMETER); + } if (!options.verbosityChanged) options.verbosity = static_cast<Logger::Level>( |