From 347cb6477d1394148340ed0f4650a6ecfaaaaf94 Mon Sep 17 00:00:00 2001 From: jurkan Date: Wed, 21 Mar 2012 19:53:50 +0800 Subject: Added default ports when connecting to a custom server. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating a custom server entry, the default port is used if no other port is specified. Reviewed-by: Thorbjørn Lindeijer Mantis-issue: 464 --- src/gui/customserverdialog.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gui/customserverdialog.cpp') diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp index 9d56a3ce..e0d25928 100644 --- a/src/gui/customserverdialog.cpp +++ b/src/gui/customserverdialog.cpp @@ -161,12 +161,10 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) if (event.getId() == "addServer") { // Check the given information - if (mServerAddressField->getText().empty() - || mPortField->getText().empty()) + if (mServerAddressField->getText().empty()) { OkDialog *dlg = new OkDialog(_("Error"), - _("Please at least type both the address and the port " - "of the server.")); + _("Please type in at least the address of the server.")); dlg->addActionListener(this); } else @@ -178,7 +176,6 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) serverInfo.name = mNameField->getText(); serverInfo.description = mDescriptionField->getText(); serverInfo.hostname = mServerAddressField->getText(); - serverInfo.port = (short) atoi(mPortField->getText().c_str()); #ifdef MANASERV_SUPPORT switch (mTypeField->getSelected()) { @@ -194,6 +191,10 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) #else serverInfo.type = ServerInfo::TMWATHENA; #endif + if (mPortField->getText().empty()) + serverInfo.port = ServerInfo::defaultPortForServerType(serverInfo.type); + else + serverInfo.port = (short) atoi(mPortField->getText().c_str()); // Tell the server has to be saved serverInfo.save = true; -- cgit v1.2.3-70-g09d2