summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-24 01:57:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-24 01:57:39 +0000
commitd5e8513e085b6fc8da2ea4bb7151ac8e98be74c8 (patch)
tree0990fc8565e99c321344283139eb419829769d7a /src/main.cpp
parenta34741f590ed24c2a6e0c0ebbde832572c606b94 (diff)
downloadmana-d5e8513e085b6fc8da2ea4bb7151ac8e98be74c8.tar.gz
mana-d5e8513e085b6fc8da2ea4bb7151ac8e98be74c8.tar.bz2
mana-d5e8513e085b6fc8da2ea4bb7151ac8e98be74c8.tar.xz
mana-d5e8513e085b6fc8da2ea4bb7151ac8e98be74c8.zip
Go back to login or register state on error, depending on what the user was
doing, and fixed the error message when registering an account that already exists. Also another crash fix following from previous commit.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 78b967e2..79275e15 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -104,16 +104,6 @@ Music *bgm;
Configuration config; /**< XML file configuration reader */
Logger *logger; /**< Log object */
-namespace {
- struct ErrorListener : public gcn::ActionListener
- {
- void action(const gcn::ActionEvent &event)
- {
- state = LOGIN_STATE;
- }
- } errorListener;
-}
-
/**
* A structure holding the values of various options that can be passed from
* the command line.
@@ -446,6 +436,16 @@ LoginHandler loginHandler;
LockedArray<LocalPlayer*> charInfo(MAX_SLOT + 1);
MapLoginHandler mapLoginHandler;
+namespace {
+ struct ErrorListener : public gcn::ActionListener
+ {
+ void action(const gcn::ActionEvent &event)
+ {
+ state = loginData.registerLogin ? REGISTER_STATE : LOGIN_STATE;
+ }
+ } errorListener;
+}
+
// TODO Find some nice place for these functions
void accountLogin(Network *network, LoginData *loginData)
{
@@ -469,13 +469,14 @@ void accountLogin(Network *network, LoginData *loginData)
// Remove _M or _F from username after a login for registration purpose
if (loginData->registerLogin)
{
- loginData->registerLogin = false;
- loginData->username = loginData->username.substr(0,
- loginData->username.length() - 2);
+ loginData->username =
+ loginData->username.substr(0, loginData->username.length() - 2);
}
+
// TODO This is not the best place to save the config, but at least better
// than the login gui window
- if (loginData->remember) {
+ if (loginData->remember)
+ {
config.setValue("host", loginData->hostname);
config.setValue("username", loginData->username);
}
@@ -713,6 +714,7 @@ int main(int argc, char *argv[])
logger->log("State: LOGIN");
if (!loginData.password.empty()) {
+ loginData.registerLogin = false;
state = ACCOUNT_STATE;
} else {
currentDialog = new LoginDialog(&loginData);