484 if (lst[0] == "RUN_GAME") { |
484 if (lst[0] == "RUN_GAME") { |
485 netClientState = 5; |
485 netClientState = 5; |
486 emit AskForRunGame(); |
486 emit AskForRunGame(); |
487 return; |
487 return; |
488 } |
488 } |
|
489 |
|
490 if (lst[0] == "BYE") { |
|
491 if (lst[1] == "Authentication failed") |
|
492 { |
|
493 // Set the password blank if case the user tries to join and enter his password again |
|
494 config->setValue("net/passwordlength", 0); |
|
495 config->setNetPasswordLength(0); |
|
496 } |
|
497 // return early so the user won't get an unknown error message dialog (the user already gets a server connection is lost one) |
|
498 return; |
|
499 } |
489 |
500 |
490 if (lst[0] == "ASKPASSWORD") { |
501 if (lst[0] == "ASKPASSWORD") { |
491 bool ok = false; |
502 bool ok = false; |
492 int passLength = config->value("net/passwordlength", 0).toInt(); |
503 int passLength = config->value("net/passwordlength", 0).toInt(); |
493 QString hash = config->value("net/passwordhash", "").toString(); |
504 QString hash = config->value("net/passwordhash", "").toString(); |
494 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
505 |
495 |
506 // If the password is blank, ask the user to enter one in |
496 if (!ok) { |
507 if (passLength == 0) |
497 Disconnect(); |
508 { |
498 emit Disconnected(); |
509 QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
499 return; |
510 |
500 } |
511 if (!ok) { |
501 |
512 Disconnect(); |
502 if (!passLength || password!=QString(passLength, '\0')) { |
513 emit Disconnected(); |
|
514 return; |
|
515 } |
|
516 |
503 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
517 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
504 config->setValue("net/passwordhash", hash); |
518 config->setValue("net/passwordhash", hash); |
505 config->setValue("net/passwordlength", password.size()); |
519 config->setValue("net/passwordlength", password.size()); |
|
520 config->setNetPasswordLength(password.size()); |
506 } |
521 } |
507 |
522 |
508 RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash)); |
523 RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash)); |
509 return; |
524 return; |
510 } |
525 } |