--- a/QTfrontend/hwform.cpp Sun Apr 21 01:36:08 2013 +0200
+++ b/QTfrontend/hwform.cpp Wed May 29 22:52:37 2013 +0400
@@ -153,7 +153,7 @@
config = new GameUIConfig(this, DataManager::instance().settingsFileName());
frontendEffects = config->value("frontend/effects", true).toBool();
- playerHash = QString(QCryptographicHash::hash(config->value("net/nick","").toString().toUtf8(), QCryptographicHash::Md5).toHex());
+ playerHash = QString(QCryptographicHash::hash(config->value("net/nick",tr("Guest")+QString("%1").arg(rand())).toString().toUtf8(), QCryptographicHash::Md5).toHex());
ui.pageRoomsList->setSettings(config);
ui.pageNetGame->setSettings(config);
@@ -319,8 +319,6 @@
connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet()));
connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
- connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
-
connect(ui.pageVideos, SIGNAL(goBack()), config, SLOT(SaveVideosOptions()));
ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
@@ -472,7 +470,7 @@
if(teamslist.empty())
{
- QString currentNickName = config->value("net/nick","").toString().toUtf8();
+ QString currentNickName = config->value("net/nick",tr("Guest")+QString("%1").arg(rand())).toString().toUtf8();
QString teamName;
if (currentNickName.isEmpty())
@@ -598,6 +596,10 @@
#endif
qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
+ if (lastid == ID_PAGE_MAIN)
+ {
+ ui.pageMain->resetNetworkChoice();
+ }
// pageEnter and pageLeave events
((AbstractPage*)ui.Pages->widget(lastid))->triggerPageLeave();
@@ -1373,13 +1375,11 @@
connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig()));
//nick and pass stuff
- QString nickname = config->value("net/nick", "").toString();
+ hwnet->m_private_game = !(hostName == NETGAME_DEFAULT_SERVER && port == NETGAME_DEFAULT_PORT);
+ if (hwnet->m_private_game == false && AskForNickAndPwd() != 0)
+ return;
- hwnet->m_private_game = !(hostName == NETGAME_DEFAULT_SERVER && port == NETGAME_DEFAULT_PORT);
- if (hwnet->m_private_game == false)
- if (AskForNickAndPwd() != 0)
- return;
-
+ QString nickname = config->value("net/nick",tr("Guest")+QString("%1").arg(rand())).toString();
ui.pageRoomsList->setUser(nickname);
ui.pageNetGame->setUser(nickname);
@@ -1392,16 +1392,18 @@
config->clearTempHash();
//initialize
- QString hash = config->passwordHash();
- QString temphash = config->tempHash();
- QString nickname = config->value("net/nick", "").toString();
+ QString hash;
+ QString temphash;
+ QString nickname;
QString password;
- //if something from login is missing, start dialog loop
- if (nickname.isEmpty() || hash.isEmpty())
- {
- while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing
- {
+ do {
+ nickname = config->value("net/nick",tr("Guest")+QString("%1").arg(rand())).toString();
+ hash = config->passwordHash();
+ temphash = config->tempHash();
+
+ //if something from login is missing, start dialog loop
+ if (nickname.isEmpty() || hash.isEmpty()) {
//open dialog
HWPasswordDialog * pwDialog = new HWPasswordDialog(this);
// make the "new account" button dialog open a browser with the registration page
@@ -1418,62 +1420,54 @@
if (pwDialog->exec() != QDialog::Accepted) {
delete pwDialog;
GoBack();
- return -1;
+ break;
}
//set nick and pass from the dialog
nickname = pwDialog->leNickname->text();
password = pwDialog->lePassword->text();
+ bool save = pwDialog->cbSave->isChecked();
+ //clean up
+ delete pwDialog;
//check the nickname variable
if (nickname.isEmpty()) {
int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
GoBack();
- delete pwDialog;
if (retry) {
if (hwnet->m_private_game) {
QStringList list = hwnet->getHost().split(":");
NetConnectServer(list.at(0), list.at(1).toShort());
} else
NetConnectOfficialServer();
- }
- return -1;
+ }
+ break; //loop restart
+ } else {
+ //update nickname if it's fine
+ config->setValue("net/nick", nickname);
+ config->updNetNick();
}
- if (!password.isEmpty()) {
+ //check the password variable
+ if (password.isEmpty()) {
+ config->clearPasswordHash();
+ break;
+ } else {
//calculate temphash and set it into config
temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
config->setTempHash(temphash);
//if user wants to save password
- bool save = pwDialog->cbSave->isChecked();
config->setValue("net/savepassword", save);
- if (save) // user wants to save password
- {
+ if (save) {
+ // user wants to save password
ui.pageOptions->CBSavePassword->setChecked(true);
config->setPasswordHash(temphash);
}
}
- else {
- delete pwDialog;
- config->setValue("net/nick", nickname);
- config->updNetNick();
- config->clearPasswordHash();
- break;
- }
-
- delete pwDialog;
+ }
+ } while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())); //while a nickname, or both hashes are missing
- //update nickname
- config->setValue("net/nick", nickname);
- config->updNetNick();
-
- //and all the variables
- hash = config->passwordHash();
- temphash = config->tempHash();
- nickname = config->value("net/nick", "").toString();
- }
- }
return 0;
}
@@ -1546,7 +1540,7 @@
if (retry) {
if (hwnet->m_private_game) {
QStringList list = hwnet->getHost().split(":");
- NetConnectServer(list.at(0), list.at(1).toShort());
+ NetConnectServer(list.at(0), list.at(1).toUInt());
} else
NetConnectOfficialServer();
}