diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index eb630f76..8a11a63e 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -24,6 +24,8 @@ #include #include #include +#include + #include "passwordhasher.h" #include "servatrice.h" #include "server_logger.h" @@ -34,6 +36,7 @@ #include "version_string.h" #include + RNG_Abstract *rng; ServerLogger *logger; QThread *loggerThread; @@ -111,15 +114,36 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); app.setOrganizationName("Cockatrice"); app.setApplicationName("Servatrice"); - - QStringList args = app.arguments(); - bool testRandom = args.contains("--test-random"); - bool testHashFunction = args.contains("--test-hash"); - bool logToConsole = args.contains("--log-to-console"); + app.setApplicationVersion(VERSION_STRING); + + bool testRandom = false; + bool testHashFunction = false; + bool logToConsole = false; QString configPath; - int hasConfigPath=args.indexOf("--config"); - if(hasConfigPath > -1 && args.count() > hasConfigPath + 1) - configPath = args.at(hasConfigPath + 1); + + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + + QCommandLineOption testRandomOpt("test-random", "Test PRNG (chi^2)"); + parser.addOption(testRandomOpt); + + QCommandLineOption testHashFunctionOpt("test-hash", "Test password hash function"); + parser.addOption(testHashFunctionOpt); + + QCommandLineOption logToConsoleOpt("log-to-console", "Write server logs to console"); + parser.addOption(logToConsoleOpt); + + QCommandLineOption configPathOpt("config", "Read server configuration from ", "file", ""); + parser.addOption(configPathOpt); + + parser.process(app); + + testRandom = parser.isSet(testRandomOpt); + testHashFunction = parser.isSet(testHashFunctionOpt); + logToConsole = parser.isSet(logToConsoleOpt); + configPath = parser.value(configPathOpt); + qRegisterMetaType >("QList"); diff --git a/servatrice/src/settingscache.cpp b/servatrice/src/settingscache.cpp index 190be452..5569d5af 100644 --- a/servatrice/src/settingscache.cpp +++ b/servatrice/src/settingscache.cpp @@ -32,6 +32,6 @@ QString SettingsCache::guessConfigurationPath(QString & specificPath) return guessFileName; #endif - guessFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + fileName; + guessFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + fileName; return guessFileName; }