diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-11 21:39:51 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 17:05:37 +0100 |
commit | 78d6d9352f66f41963207b04a999d94c17d67cf2 (patch) | |
tree | c286d4a6ebd46bc89808d3e18b2d7d920ea10351 /src/gui | |
parent | 8546361abaa6123acd9dc1429575d1fd1cf6a4ec (diff) | |
download | Mana-78d6d9352f66f41963207b04a999d94c17d67cf2.tar.gz Mana-78d6d9352f66f41963207b04a999d94c17d67cf2.tar.bz2 Mana-78d6d9352f66f41963207b04a999d94c17d67cf2.tar.xz Mana-78d6d9352f66f41963207b04a999d94c17d67cf2.zip |
Added support for -y / --server-type parameter
Usually this would be guessed correctly by the port, but now it is also
possible to just specify the server type and the port will be derived
from there, unless a default port is given in the branding file.
Closes #56
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/customserverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/logindialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/logindialog.h | 3 | ||||
-rw-r--r-- | src/gui/register.cpp | 4 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 25 |
5 files changed, 16 insertions, 30 deletions
diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp index 733a6b5c..455951ec 100644 --- a/src/gui/customserverdialog.cpp +++ b/src/gui/customserverdialog.cpp @@ -194,7 +194,7 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) if (mPortField->getText().empty()) serverInfo.port = ServerInfo::defaultPortForServerType(serverInfo.type); else - serverInfo.port = (short) atoi(mPortField->getText().c_str()); + serverInfo.port = static_cast<uint16_t>(atoi(mPortField->getText().c_str())); // Tell the server has to be saved serverInfo.save = true; diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 4d065d65..1f96e02d 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -22,14 +22,12 @@ #include "gui/logindialog.h" #include "client.h" -#include "configuration.h" #include "gui/okdialog.h" #include "gui/sdlinput.h" #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" -#include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/passwordfield.h" @@ -40,12 +38,6 @@ #include "net/net.h" #include "utils/gettext.h" -#include "utils/stringutils.h" - -static const int MAX_SERVER_LIST_SIZE = 5; -static const int LOGIN_DIALOG_WIDTH = 220; -static const int LOGIN_DIALOG_HEIGHT = 140; -static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70; LoginDialog::LoginDialog(LoginData *loginData): Window(_("Login")), @@ -93,9 +85,7 @@ LoginDialog::LoginDialog(LoginData *loginData): mLoginButton->setEnabled(canSubmit()); } -LoginDialog::~LoginDialog() -{ -} +LoginDialog::~LoginDialog() = default; void LoginDialog::action(const gcn::ActionEvent &event) { diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index 5761f4a6..67814cd4 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -28,9 +28,6 @@ #include <guichan/keylistener.hpp> #include <guichan/listmodel.hpp> -#include <string> -#include <vector> - class LoginData; /** diff --git a/src/gui/register.cpp b/src/gui/register.cpp index b57ee975..0e23777c 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -167,7 +167,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) minUser); error = 1; } - else if (user.length() > maxUser - 1 ) + else if (user.length() > maxUser - 1) { // Name too long errorMessage = strprintf @@ -183,7 +183,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) minPass); error = 2; } - else if (mPasswordField->getText().length() > maxPass - 1 ) + else if (mPasswordField->getText().length() > maxPass - 1) { // Pass too long errorMessage = strprintf diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index cc1fa26a..0bff4c9e 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -51,7 +51,6 @@ #include <guichan/font.hpp> #include <cstdlib> -#include <iostream> #include <string> static const int MAX_SERVERLIST = 6; @@ -65,13 +64,13 @@ static std::string serverTypeToString(ServerInfo::Type type) case ServerInfo::MANASERV: return "ManaServ"; default: - return ""; + return std::string(); } } ServersListModel::ServersListModel(ServerInfos *servers, ServerDialog *parent): mServers(servers), - mVersionStrings(servers->size(), VersionString(0, "")), + mVersionStrings(servers->size(), VersionString(0, std::string())), mParent(parent) { } @@ -96,7 +95,7 @@ std::string ServersListModel::getElementAt(int elementIndex) void ServersListModel::setVersionString(int index, const std::string &version) { if (version.empty()) - mVersionStrings[index] = VersionString(0, ""); + mVersionStrings[index] = VersionString(0, std::string()); else { int width = gui->getFont()->getWidth(version); @@ -421,7 +420,7 @@ void ServerDialog::downloadServerList() // Fall back to manasource.org when neither branding nor config set it if (listFile.empty()) - listFile = "http://www.manasource.org/serverlist.xml"; + listFile = "https://www.manasource.org/serverlist.xml"; mDownload = new Net::Download(this, listFile, &downloadUpdate); mDownload->setFile(mDir + "/serverlist.xml"); @@ -490,7 +489,7 @@ void ServerDialog::loadServers() { if (xmlStrEqual(subNode->name, BAD_CAST "connection")) { - server.hostname = XML::getProperty(subNode, "hostname", ""); + server.hostname = XML::getProperty(subNode, "hostname", std::string()); server.port = XML::getProperty(subNode, "port", 0); if (server.port == 0) { @@ -552,13 +551,13 @@ void ServerDialog::loadCustomServers() const std::string descriptionKey = "MostUsedServerDescription" + index; ServerInfo server; - server.name = config.getValue(nameKey, ""); - server.hostname = config.getValue(hostNameKey, ""); - server.type = ServerInfo::parseType(config.getValue(typeKey, "")); + server.name = config.getValue(nameKey, std::string()); + server.hostname = config.getValue(hostNameKey, std::string()); + server.type = ServerInfo::parseType(config.getValue(typeKey, std::string())); - const int defaultPort = ServerInfo::defaultPortForServerType(server.type); - server.port = (unsigned short) config.getValue(portKey, defaultPort); - server.description = config.getValue(descriptionKey, ""); + const uint16_t defaultPort = ServerInfo::defaultPortForServerType(server.type); + server.port = static_cast<uint16_t>(config.getValue(portKey, defaultPort)); + server.description = config.getValue(descriptionKey, std::string()); // Stop on the first invalid server if (!server.isValid()) @@ -623,7 +622,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, int index) // Insert an invalid entry at the end to make the loading stop there if (savedServerCount < MAX_SERVERLIST) - config.setValue("MostUsedServerName" + toString(savedServerCount), ""); + config.setValue("MostUsedServerName" + toString(savedServerCount), std::string()); // Restore the correct description if (index < 0) |