summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-03 13:57:34 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-03 13:57:34 +0000
commit9dc99e1888de6194c7ce555c33245e6bff586b3d (patch)
tree39b4159d2a56976474da4cc4659e5dd04f1cfa25 /src/main.cpp
parentf8d16a36db8f9d1f22f3a15d2fbee19b7c68ebef (diff)
downloadmana-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.gz
mana-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.bz2
mana-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.xz
mana-9dc99e1888de6194c7ce555c33245e6bff586b3d.zip
Made the login dialog work on LoginData only, without playing with the config, it's not its job to do so.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0ea554bf..3424e90a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -405,6 +405,7 @@ MapLoginHandler mapLoginHandler;
void accountLogin(Network *network, LoginData *loginData)
{
logger->log("Trying to connect to account server...");
+ logger->log("Username is %s", loginData->username.c_str());
network->connect(loginData->hostname.c_str(), loginData->port);
network->registerHandler(&loginHandler);
@@ -415,6 +416,14 @@ void accountLogin(Network *network, LoginData *loginData)
outMsg.writeString(loginData->username, 24);
outMsg.writeString(loginData->password, 24);
outMsg.writeInt8(0); // unknown
+
+ // TODO This is not the best place to save the config, but at least better
+ // than the login gui window
+ if (loginData->remember) {
+ config.setValue("host", loginData->hostname);
+ config.setValue("username", loginData->username);
+ }
+ config.setValue("remember", loginData->remember);
}
void charLogin(Network *network, const SERVER_INFO *si)
@@ -505,6 +514,19 @@ int main(int argc, char *argv[])
sound.playMusic(TMW_DATADIR "data/music/Magick - Real.ogg");
+ accountLoginData.username = options.username;
+ if (accountLoginData.username.empty()) {
+ if (config.getValue("remember", 0)) {
+ accountLoginData.username = config.getValue("username", "");
+ }
+ }
+ if (!options.password.empty()) {
+ accountLoginData.password = options.password;
+ }
+ accountLoginData.hostname = config.getValue("host", "animesites.de");
+ accountLoginData.port = (short)config.getValue("port", 0);
+ accountLoginData.remember = config.getValue("remember", 0);
+
SDLNet_Init();
Network *network = new Network();
while (state != EXIT_STATE)
@@ -577,18 +599,16 @@ int main(int argc, char *argv[])
if (currentDialog && state != ACCOUNT_STATE && state != CHAR_CONNECT_STATE) {
delete currentDialog;
+ currentDialog = NULL;
}
switch (state) {
case LOGIN_STATE:
logger->log("State: LOGIN");
- currentDialog = new LoginDialog(&accountLoginData);
-
- if (!options.username.empty()) {
- LoginDialog *loginDialog = (LoginDialog*)currentDialog;
- loginDialog->userField->setText(options.username);
- loginDialog->passField->setText(options.password);
- loginDialog->action("ok");
+ if (!accountLoginData.password.empty()) {
+ state = ACCOUNT_STATE;
+ } else {
+ currentDialog = new LoginDialog(&accountLoginData);
}
break;