diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-24 01:57:39 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-24 01:57:39 +0000 |
commit | d5e8513e085b6fc8da2ea4bb7151ac8e98be74c8 (patch) | |
tree | 0990fc8565e99c321344283139eb419829769d7a | |
parent | a34741f590ed24c2a6e0c0ebbde832572c606b94 (diff) | |
download | mana-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.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/gui/login.cpp | 1 | ||||
-rw-r--r-- | src/gui/register.cpp | 5 | ||||
-rw-r--r-- | src/logindata.h | 4 | ||||
-rw-r--r-- | src/main.cpp | 30 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/loginhandler.cpp | 5 |
7 files changed, 36 insertions, 21 deletions
@@ -4,6 +4,13 @@ logic, in order to prevent an incoming character delete message from deleting the player character that was about to be drawn. * src/gui/char_select.cpp: Removed useless lock/unlock calls. + * src/logindata.h, src/main.cpp, src/gui/login.cpp: Go back to login + or register state on error, depending on what the user was doing. + * src/gui/register.cpp: Actually use the server that is filled in. + * src/net/loginhandler.cpp: Fixed error message. + * src/net/charserverhandler.cpp: Fixed crash since now logic is called + after non-selected characters are deleted, by properly setting deleted + instances to 0 and going back to initial selection. 2007-03-23 Bjørn Lindeijer <bjorn@lindeijer.nl> diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 00b99e72..4e4c5b34 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -125,6 +125,7 @@ LoginDialog::action(const gcn::ActionEvent &event) mLoginData->username = mUserField->getText(); mLoginData->password = mPassField->getText(); mLoginData->remember = mKeepCheck->isMarked(); + mLoginData->registerLogin = false; mOkButton->setEnabled(false); mRegisterButton->setEnabled(false); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 4a8a32d9..ad3a6388 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -224,9 +224,8 @@ RegisterDialog::action(const gcn::ActionEvent &event) // No errors detected, register the new user. mRegisterButton->setEnabled(false); - mLoginData->hostname = config.getValue( - "host", "server.themanaworld.org"); - mLoginData->port = (short)config.getValue("port", 0); + mLoginData->hostname = mServerField->getText(); + mLoginData->port = (short) config.getValue("port", 0); mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); mLoginData->username += mFemaleButton->isMarked() ? "_F" : "_M"; diff --git a/src/logindata.h b/src/logindata.h index 82623ba5..1ee9927d 100644 --- a/src/logindata.h +++ b/src/logindata.h @@ -36,8 +36,8 @@ struct LoginData int session_ID2; char sex; - bool remember; - bool registerLogin; + bool remember; /**< Whether to store the username and host. */ + bool registerLogin; /**< Whether an account is being registered. */ }; #endif 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); diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 01a8756b..a54a17de 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -134,6 +134,7 @@ void CharServerHandler::handleMessage(MessageIn *msg) case 0x0071: player_node = mCharInfo->getEntry(); + slot = mCharInfo->getPos(); msg->skip(4); // CharID, must be the same as player_node->charID map_path = msg->readString(16); mLoginData->hostname = iptostring(msg->readInt32()); @@ -145,10 +146,14 @@ void CharServerHandler::handleMessage(MessageIn *msg) { LocalPlayer *tmp = mCharInfo->getEntry(); if (tmp != player_node) + { delete tmp; + mCharInfo->setEntry(0); + } mCharInfo->next(); } while (mCharInfo->getPos()); + mCharInfo->select(slot); state = CONNECTING_STATE; break; diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 195e54e9..ab788e41 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -53,7 +53,8 @@ void LoginHandler::handleMessage(MessageIn *msg) msg->skip(2); n_server = (msg->getLength() - 47) / 32; - server_info = (SERVER_INFO**)malloc(sizeof(SERVER_INFO*) * n_server); + server_info = + (SERVER_INFO**) malloc(sizeof(SERVER_INFO*) * n_server); mLoginData->session_ID1 = msg->readInt32(); mLoginData->account_ID = msg->readInt32(); @@ -103,7 +104,7 @@ void LoginHandler::handleMessage(MessageIn *msg) errorMessage = "You have been banned for 5 minutes"; break; case 9: - errorMessage = "This account is already logged in"; + errorMessage = "This user name is already taken"; break; default: errorMessage = "Unknown error"; |