summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp2
-rw-r--r--src/client.h3
-rw-r--r--src/main.cpp23
3 files changed, 17 insertions, 11 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 98c8be30..15ebcf96 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -378,7 +378,7 @@ Client::Client(const Options &options):
// Initialize default server
mCurrentServer.hostname = options.serverName;
mCurrentServer.port = options.serverPort;
- mCurrentServer.type = ServerInfo::parseType(options.serverType);
+ mCurrentServer.type = options.serverType;
loginData.username = options.username;
loginData.password = options.password;
loginData.remember = config.getBoolValue("remember");
diff --git a/src/client.h b/src/client.h
index ccee43ba..dfcc3e70 100644
--- a/src/client.h
+++ b/src/client.h
@@ -135,6 +135,7 @@ public:
bool skipUpdate = false;
bool chooseDefault = false;
bool noOpenGL = false;
+ bool exitWithError = false;
std::string username;
std::string password;
std::string character;
@@ -145,7 +146,7 @@ public:
std::string configDir;
std::string localDataDir;
std::string screenshotDir;
- std::string serverType;
+ ServerType serverType = ServerType::UNKNOWN;
std::string serverName;
uint16_t serverPort = 0;
diff --git a/src/main.cpp b/src/main.cpp
index 6244b946..b44f4d3a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -118,6 +118,8 @@ static void parseOptions(int argc, char *argv[], Client::Options &options)
break;
case '?': // Unknown option
case ':': // Missing argument
+ options.exitWithError = true;
+ [[fallthrough]];
case 'h':
options.printHelp = true;
break;
@@ -158,7 +160,12 @@ static void parseOptions(int argc, char *argv[], Client::Options &options)
options.screenshotDir = optarg;
break;
case 'y':
- options.serverType = optarg;
+ options.serverType = ServerInfo::parseType(optarg);
+ if (options.serverType == ServerType::UNKNOWN)
+ {
+ std::cerr << _("Invalid server type, expected one of: tmwathena, manaserv") << std::endl;
+ options.exitWithError = true;
+ }
break;
}
}
@@ -203,16 +210,14 @@ int main(int argc, char *argv[])
Client::Options options;
parseOptions(argc, argv, options);
+ if (options.printVersion)
+ printVersion();
+
if (options.printHelp)
- {
printHelp();
- return 0;
- }
- else if (options.printVersion)
- {
- printVersion();
- return 0;
- }
+
+ if (options.printHelp || options.printVersion || options.exitWithError)
+ return options.exitWithError ? 1 : 0;
initInternationalization();