summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-01-01 15:45:57 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-01-01 15:45:57 +0000
commitff8bd96e7e4266f7af344847afb6f0e7a295ba9b (patch)
tree94f46c8c642807d7842c2003f943ffe7dc938b72
parent83f7d9ff9f83cca80b5f72564ee3496e8a30cce3 (diff)
downloadmana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.gz
mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.bz2
mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.xz
mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.zip
Applied patch by pclouds that allows for a faster login sequence by providing
the username and password from the command line, and allowing the client to choose the default server and character.
-rw-r--r--ChangeLog7
-rw-r--r--NEWS3
-rw-r--r--src/Makefile.am2
-rw-r--r--src/main.cpp66
4 files changed, 69 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 64339565..5c0ba589 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-01-01 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/main.cpp: Applied patch by pclouds that allows for a faster
+ login sequence by providing the username and password from the command
+ line, and allowing the client to choose the default server and
+ character.
+
2005-12-30 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/gui/chat.cpp, src/gui/chat.h: Applied patch by pclouds to have
diff --git a/NEWS b/NEWS
index db214bec..7e23677b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+0.0.19 (WIP)
+- Added --username, --password and --defaults command line options
+
0.0.18.1 (30 December 2005)
- Fixed a drawing glitch with high tiles at the bottom of the screen
- Fixed glitches caused by fading out the damage display
diff --git a/src/Makefile.am b/src/Makefile.am
index 6a990a9f..8d446363 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -77,7 +77,7 @@ tmw_SOURCES = graphic/spriteset.cpp \
gui/progressbar.h \
gui/radiobutton.cpp \
gui/radiobutton.h \
- gui/register.cpp \
+ gui/register.cpp \
gui/register.h \
gui/requesttrade.cpp \
gui/requesttrade.h \
diff --git a/src/main.cpp b/src/main.cpp
index 3121f57f..9d5c628c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -58,6 +58,7 @@
#include "gui/ok_dialog.h"
#include "gui/register.h"
#include "gui/updatewindow.h"
+#include "gui/textfield.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
@@ -317,29 +318,51 @@ void exit_engine()
delete logger;
}
+/**
+ * A structure holding the values of various options that can be passed from
+ * the command line.
+ */
struct Options
{
- Options():printHelp(false),skipUpdate(false) {};
+ /**
+ * Constructor.
+ */
+ Options():
+ printHelp(false),
+ skipUpdate(false),
+ chooseDefault(false)
+ {};
bool printHelp;
bool skipUpdate;
+ bool chooseDefault;
+ std::string username;
+ std::string password;
};
void printHelp()
{
- std::cout << "tmw" << std::endl << std::endl;
- std::cout << "Options: " << std::endl;
- std::cout << " -h --help : Display this help" << std::endl;
- std::cout << " --skipupdate : Skip the update process" << std::endl;
+ std::cout
+ << "tmw" << std::endl << std::endl
+ << "Options: " << std::endl
+ << " -h --help : Display this help" << std::endl
+ << " -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;
}
void parseOptions(int argc, char *argv[], Options &options)
{
- const char *optstring = "h";
+ const char *optstring = "hU:P:D";
const struct option long_options[] = {
- { "help", no_argument, 0, 'h' },
- { "skipupdate", no_argument, 0, 'u' },
+ { "help", no_argument, 0, 'h' },
+ { "skipupdate", no_argument, 0, 'u' },
+ { "username", required_argument, 0, 'U' },
+ { "password", required_argument, 0, 'P' },
+ { "default", no_argument, 0, 'D' },
0
};
@@ -358,6 +381,15 @@ void parseOptions(int argc, char *argv[], Options &options)
case 'u':
options.skipUpdate = true;
break;
+ case 'U':
+ options.username = optarg;
+ break;
+ case 'P':
+ options.password = optarg;
+ break;
+ case 'D':
+ options.chooseDefault = true;
+ break;
}
}
}
@@ -465,22 +497,39 @@ int main(int argc, char *argv[])
logger->log("State: LOGIN");
currentDialog = new LoginDialog();
inputHandler = loginInputHandler;
+
+ if (!options.username.empty()) {
+ LoginDialog *loginDialog = (LoginDialog*)currentDialog;
+ loginDialog->userField->setText(options.username);
+ loginDialog->passField->setText(options.password);
+ loginDialog->action("ok");
+ }
break;
+
case REGISTER_STATE:
logger->log("State: REGISTER");
currentDialog = new RegisterDialog();
inputHandler = loginInputHandler;
break;
+
case CHAR_SERVER_STATE:
logger->log("State: CHAR_SERVER");
currentDialog = new ServerSelectDialog();
inputHandler = charServerInputHandler;
+ if (options.chooseDefault) {
+ ((ServerSelectDialog*)currentDialog)->action("ok");
+ }
break;
+
case CHAR_SELECT_STATE:
logger->log("State: CHAR_SELECT");
currentDialog = new CharSelectDialog();
inputHandler = charSelectInputHandler;
+ if (options.chooseDefault) {
+ ((CharSelectDialog*)currentDialog)->action("ok");
+ }
break;
+
case GAME_STATE:
sound.fadeOutMusic(1000);
@@ -492,6 +541,7 @@ int main(int argc, char *argv[])
logger->log("State: GAME");
game();
break;
+
case UPDATE_STATE:
logger->log("State: UPDATE");
currentDialog = new UpdaterWindow();