diff -r b018f6117fc1 -r 148d581b17ab QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sat Jun 04 16:09:12 2011 -0400 +++ b/QTfrontend/gameuiconfig.cpp Wed Jun 08 03:36:54 2011 -0400 @@ -22,6 +22,7 @@ #include #include #include +#include #include "gameuiconfig.h" #include "hwform.h" @@ -66,6 +67,9 @@ QDir::home().dirName()); Form->ui.pageOptions->editNetNick->setText(netNick); + + int passLength = value("net/passwordlength", 0).toInt(); + setNetPasswordLength(passLength); delete netHost; netHost = new QString(value("net/ip", "").toString()); @@ -138,6 +142,11 @@ setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); setValue("net/nick", netNick()); + if (netPasswordIsValid()) + { + setValue("net/passwordhash", netPasswordHash()); + setValue("net/passwordlength", netPasswordLength()); + } setValue("net/ip", *netHost); setValue("net/port", netPort); setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text()); @@ -145,7 +154,7 @@ setValue("fps/show", isShowFPSEnabled()); setValue("fps/limit", Form->ui.pageOptions->fpsedit->value()); - + setValue("misc/altdamage", isAltDamageEnabled()); setValue("misc/appendTimeToRecords", appendDateTimeToRecordName()); setValue("misc/locale", language()); @@ -296,6 +305,33 @@ return Form->ui.pageOptions->editNetNick->text(); } +QByteArray GameUIConfig::netPasswordHash() +{ + return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toLatin1(), QCryptographicHash::Md5).toHex(); +} + +int GameUIConfig::netPasswordLength() +{ + return Form->ui.pageOptions->editNetPassword->text().size(); +} + +bool GameUIConfig::netPasswordIsValid() +{ + return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '\0')); +} + +void GameUIConfig::setNetPasswordLength(int passwordLength) +{ + if (passwordLength > 0) + { + Form->ui.pageOptions->editNetPassword->setText(QString(passwordLength, '\0')); + } + else + { + Form->ui.pageOptions->editNetPassword->setText(""); + } +} + quint8 GameUIConfig::volume() { return Form->ui.pageOptions->volumeBox->value() * 128 / 100;