summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-27 19:51:17 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-27 19:51:17 +0300
commit9412cd204e95c3c6e38d37a25ac32682f3729a32 (patch)
tree00f88fc81e1c72769b28fdba99481ca250be7902 /src
parent58308ca69ff7aeb99f47ca8ff62a8d16b61314eb (diff)
downloadmanaplus-9412cd204e95c3c6e38d37a25ac32682f3729a32.tar.gz
manaplus-9412cd204e95c3c6e38d37a25ac32682f3729a32.tar.bz2
manaplus-9412cd204e95c3c6e38d37a25ac32682f3729a32.tar.xz
manaplus-9412cd204e95c3c6e38d37a25ac32682f3729a32.zip
Fix incorrect map loading on first run for server.
Diffstat (limited to 'src')
-rw-r--r--src/gui/logindialog.cpp112
-rw-r--r--src/gui/logindialog.h2
2 files changed, 59 insertions, 55 deletions
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 6adaaad5d..c8304a61e 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -249,60 +249,8 @@ void LoginDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "login" && canSubmit())
{
- mLoginData->username = mUserField->getText();
- mLoginData->password = mPassField->getText();
- mLoginData->remember = mKeepCheck->isSelected();
- int updateType = mUpdateTypeDropDown->getSelected();
-
- if (mCustomUpdateHost->isSelected()
- && mUpdateHostText->getText().empty())
- {
- updateType |= LoginData::Upd_Custom;
- serverConfig.setValue("customUpdateHost",
- mUpdateHostText->getText());
-
- if (checkPath(mUpdateHostText->getText()))
- {
- mLoginData->updateHost = mUpdateHostText->getText();
- *mUpdateHost = mUpdateHostText->getText();
- }
- else
- {
- mLoginData->updateHost.clear();
- (*mUpdateHost).clear();
- }
- }
- else if (mUpdateHostDropDown)
- {
- const std::string str = mUpdateHostDropDown->getSelectedString();
- serverConfig.setValue("updateHost2", str);
- if (!str.empty() && checkPath(str))
- {
- mLoginData->updateHost = str;
- *mUpdateHost = str;
- }
- else
- {
- mLoginData->updateHost.clear();
- (*mUpdateHost).clear();
- }
- }
-
- mLoginData->updateType = updateType;
- serverConfig.setValue("updateType", updateType);
-
+ prepareUpdate();
mLoginData->registerLogin = false;
-
- mRegisterButton->setEnabled(false);
- mServerButton->setEnabled(false);
- mLoginButton->setEnabled(false);
-
- LoginDialog::savedPassword = mPassField->getText();
- if (mLoginData->remember)
- LoginDialog::savedPasswordKey = mServerName;
- else
- LoginDialog::savedPasswordKey = "-";
-
Client::setState(STATE_LOGIN_ATTEMPT);
}
else if (event.getId() == "server")
@@ -313,8 +261,7 @@ void LoginDialog::action(const gcn::ActionEvent &event)
{
if (Net::getLoginHandler()->isRegistrationEnabled())
{
- mLoginData->username = mUserField->getText();
- mLoginData->password = mPassField->getText();
+ prepareUpdate();
Client::setState(STATE_REGISTER_PREP);
}
else if (!mLoginData->registerUrl.empty())
@@ -368,3 +315,58 @@ bool LoginDialog::canSubmit() const
!mPassField->getText().empty() &&
Client::getState() == STATE_LOGIN;
}
+
+void LoginDialog::prepareUpdate()
+{
+ mLoginData->username = mUserField->getText();
+ mLoginData->password = mPassField->getText();
+ mLoginData->remember = mKeepCheck->isSelected();
+ int updateType = mUpdateTypeDropDown->getSelected();
+
+ if (mCustomUpdateHost->isSelected()
+ && mUpdateHostText->getText().empty())
+ {
+ updateType |= LoginData::Upd_Custom;
+ serverConfig.setValue("customUpdateHost",
+ mUpdateHostText->getText());
+
+ if (checkPath(mUpdateHostText->getText()))
+ {
+ mLoginData->updateHost = mUpdateHostText->getText();
+ *mUpdateHost = mUpdateHostText->getText();
+ }
+ else
+ {
+ mLoginData->updateHost.clear();
+ (*mUpdateHost).clear();
+ }
+ }
+ else if (mUpdateHostDropDown)
+ {
+ const std::string str = mUpdateHostDropDown->getSelectedString();
+ serverConfig.setValue("updateHost2", str);
+ if (!str.empty() && checkPath(str))
+ {
+ mLoginData->updateHost = str;
+ *mUpdateHost = str;
+ }
+ else
+ {
+ mLoginData->updateHost.clear();
+ (*mUpdateHost).clear();
+ }
+ }
+
+ mLoginData->updateType = updateType;
+ serverConfig.setValue("updateType", updateType);
+
+ mRegisterButton->setEnabled(false);
+ mServerButton->setEnabled(false);
+ mLoginButton->setEnabled(false);
+
+ LoginDialog::savedPassword = mPassField->getText();
+ if (mLoginData->remember)
+ LoginDialog::savedPasswordKey = mServerName;
+ else
+ LoginDialog::savedPasswordKey = "-";
+}
diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h
index cadb6b925..bf22e01e6 100644
--- a/src/gui/logindialog.h
+++ b/src/gui/logindialog.h
@@ -82,6 +82,8 @@ class LoginDialog final : public Window, public gcn::ActionListener,
*/
bool canSubmit() const;
+ void prepareUpdate();
+
LoginData *mLoginData;
TextField *mUserField;