From 32e3bd7584cf241027dd8824c936f4c60cff418f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 2 Sep 2006 19:03:28 +0000 Subject: Fixed crash when using short versions of server and port command line options and made sure cancelling the account server connect shows the server dialog. --- ChangeLog | 6 ++++++ src/gui/serverdialog.cpp | 40 ++++++++++++++++++++-------------------- src/main.cpp | 16 +++++++++++----- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f148845..56d6478b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-02 Bjørn Lindeijer + + * src/gui/serverdialog.cpp, src/main.cpp: Fixed crash when using short + versions of server and port command line options and made sure + cancelling the account server connect shows the server dialog. + 2006-09-02 Guillaume Melquiond * src/localplayer.cpp, src/beingmanager.h, src/beingmanager.cpp, diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 36b4a7a0..944b0ae0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -22,25 +22,25 @@ */ #include "serverdialog.h" - + #include -#include - -// TODO : Replace the dropdown by our own skinned one. -#include -#include - -#include "button.h" -#include "listbox.h" -#include "ok_dialog.h" -#include "scrollarea.h" -#include "textfield.h" - -#include "../configuration.h" -#include "../log.h" +#include + +// TODO : Replace the dropdown by our own skinned one. +#include +#include + +#include "button.h" +#include "listbox.h" +#include "ok_dialog.h" +#include "scrollarea.h" +#include "textfield.h" + +#include "../configuration.h" +#include "../log.h" #include "../logindata.h" -#include "../main.h" - +#include "../main.h" + #include "../utils/tostring.h" const short MAX_SERVERLIST = 5; @@ -238,9 +238,9 @@ ServerDialog::action(const std::string &eventId, gcn::Widget *widget) config.setValue(currentConfig, toString(currentServer.port)); } logger->log("Trying to connect to account server..."); - Network::connect(Network::ACCOUNT, - mLoginData->hostname, mLoginData->port); - state = STATE_CONNECT_ACCOUNT; + Network::connect(Network::ACCOUNT, + mLoginData->hostname, mLoginData->port); + state = STATE_CONNECT_ACCOUNT; } } else if (eventId == "cancel") diff --git a/src/main.cpp b/src/main.cpp index 469a2c47..9d2a1e64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -347,7 +347,8 @@ void printHelp() << " -u --skipupdate : Skip the update process" << std::endl << " -U --username : Login with this username" << std::endl << " -P --password : Login with this password" << std::endl - << " -D --default : Bypass the login process with default settings" << std::endl + << " -D --default : Bypass the login process with default settings" + << std::endl << " -s --server : Login Server name or IP" << std::endl << " -o --port : Login Server Port" << std::endl << " -p --playername : Login with this player" << std::endl; @@ -355,7 +356,7 @@ void printHelp() void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "huU:P:Dp:so"; + const char *optstring = "huU:P:Dp:s:o:"; const struct option long_options[] = { { "help", no_argument, 0, 'h' }, @@ -666,18 +667,23 @@ int main(int argc, char *argv[]) logger->log("State: CHOOSE_SERVER"); // Allow changing this using a server choice dialog - // We show the dialog box only if the command-line options weren't set. + // We show the dialog box only if the command-line options + // weren't set. if (options.serverName.empty() && options.serverPort == 0) { currentDialog = new ServerDialog(&loginData); } else { logger->log("Trying to connect to account server..."); Network::connect(Network::ACCOUNT, - loginData.hostname, loginData.port); + loginData.hostname, loginData.port); state = STATE_CONNECT_ACCOUNT; + + // Reset options so that cancelling or connect timeout + // will show the server dialog + options.serverName = ""; + options.serverPort = 0; } break; - case STATE_CONNECT_ACCOUNT: logger->log("State: CONNECT_ACCOUNT"); currentDialog = new ConnectionDialog(STATE_CHOOSE_SERVER); -- cgit v1.2.3-70-g09d2