--- a/QTfrontend/hwform.cpp Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/hwform.cpp Tue Oct 15 23:07:22 2013 +0400
@@ -1128,7 +1128,7 @@
//ForcedDisconnect(tr("No nickname supplied."));
bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
GoBack();
- if (retry) {
+ if (retry && hwnet) {
if (hwnet->m_private_game) {
QStringList list = hwnet->getHost().split(":");
NetConnectServer(list.at(0), list.at(1).toShort());
@@ -1138,7 +1138,8 @@
return;
}
- hwnet->NewNick(newNick);
+ if(hwnet)
+ hwnet->NewNick(newNick);
config->setValue("net/nick", newNick);
config->updNetNick();
@@ -1162,6 +1163,13 @@
}
}
+void HWForm::askRoomPassword()
+{
+ QString password = QInputDialog::getText(this, tr("Room password"), tr("The room is protected with password.\nPlease, enter the password:"));
+ if(hwnet && !password.isEmpty())
+ hwnet->roomPasswordEntered(password);
+}
+
bool HWForm::RetryDialog(const QString & title, const QString & label)
{
QMessageBox retryMsg(this);
@@ -1241,6 +1249,7 @@
connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)), Qt::QueuedConnection);
connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection);
//connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
+ connect(hwnet, SIGNAL(askForRoomPassword()), this, SLOT(askRoomPassword()), Qt::QueuedConnection);
ui.pageRoomsList->chatWidget->setUsersModel(hwnet->lobbyPlayersModel());
ui.pageNetGame->chatWidget->setUsersModel(hwnet->roomPlayersModel());
@@ -1257,8 +1266,8 @@
connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &, const QString &)),
hwnet, SLOT(CreateRoom(const QString&, const QString &)));
- connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)),
- hwnet, SLOT(JoinRoom(const QString&)));
+ connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &, const QString &)),
+ hwnet, SLOT(JoinRoom(const QString&, const QString &)));
// connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)),
// this, SLOT(NetGameMaster()));
// connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)),
--- a/QTfrontend/hwform.h Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/hwform.h Tue Oct 15 23:07:22 2013 +0400
@@ -111,6 +111,7 @@
void NetNickNotRegistered(const QString & nick);
void NetNickTaken(const QString & nick);
void NetAuthFailed();
+ void askRoomPassword();
bool RetryDialog(const QString & title, const QString & label);
void NetTeamAccepted(const QString& team);
void AddNetTeam(const HWTeam& team);
--- a/QTfrontend/net/newnetclient.cpp Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/net/newnetclient.cpp Tue Oct 15 23:07:22 2013 +0400
@@ -112,7 +112,7 @@
isChief = true;
}
-void HWNewNet::JoinRoom(const QString & room)
+void HWNewNet::JoinRoom(const QString & room, const QString &password)
{
if(netClientState != InLobby)
{
@@ -122,7 +122,11 @@
myroom = room;
- RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
+ if(password.isEmpty())
+ RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
+ else
+ RawSendNet(QString("JOIN_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
+
isChief = false;
}
@@ -1069,10 +1073,11 @@
switch(n)
{
case 0:
- {
emit NickTaken(mynick);
break;
- }
+ case 2:
+ emit askForRoomPassword();
+ break;
}
}
@@ -1090,3 +1095,9 @@
{
return m_roomPlayersModel;
}
+
+void HWNewNet::roomPasswordEntered(const QString &password)
+{
+ if(!myroom.isEmpty())
+ JoinRoom(myroom, password);
+}
--- a/QTfrontend/net/newnetclient.h Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/net/newnetclient.h Tue Oct 15 23:07:22 2013 +0400
@@ -76,6 +76,7 @@
PlayersListModel * m_playersModel;
QSortFilterProxyModel * m_lobbyPlayersModel;
QSortFilterProxyModel * m_roomPlayersModel;
+ QString m_lastRoom;
QStringList cmdbuf;
@@ -103,6 +104,7 @@
void adminAccess(bool);
void roomMaster(bool);
void roomNameUpdated(const QString & name);
+ void askForRoomPassword();
void netSchemeConfig(QStringList &);
void paramChanged(const QString & param, const QStringList & value);
@@ -153,7 +155,7 @@
void setLatestProtocolVar(int proto);
void askServerVars();
- void JoinRoom(const QString & room);
+ void JoinRoom(const QString & room, const QString & password);
void CreateRoom(const QString & room, const QString &password);
void updateRoomName(const QString &);
void askRoomsList();
@@ -173,6 +175,7 @@
void removeBan(const QString &);
void banIP(const QString & ip, const QString & reason, int seconds);
void banNick(const QString & nick, const QString & reason, int seconds);
+ void roomPasswordEntered(const QString & password);
private slots:
void ClientRead();
--- a/QTfrontend/ui/page/pageroomslist.cpp Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/ui/page/pageroomslist.cpp Tue Oct 15 23:07:22 2013 +0400
@@ -570,7 +570,7 @@
if (!gameInLobby)
emit askJoinConfirmation(roomName);
else
- emit askForJoinRoom(roomName);
+ emit askForJoinRoom(roomName, QString());
}
void PageRoomsList::onRefreshClick()
@@ -600,7 +600,7 @@
if (reallyJoinMsg.exec() == QMessageBox::Ok)
{
- emit askForJoinRoom(room);
+ emit askForJoinRoom(room, QString());
}
}
--- a/QTfrontend/ui/page/pageroomslist.h Tue Oct 15 22:38:32 2013 +0400
+++ b/QTfrontend/ui/page/pageroomslist.h Tue Oct 15 23:07:22 2013 +0400
@@ -71,7 +71,7 @@
signals:
void askForCreateRoom(const QString &, const QString &);
- void askForJoinRoom(const QString &);
+ void askForJoinRoom(const QString &, const QString &);
void askForRoomList();
void askJoinConfirmation(const QString &);