--- a/QTfrontend/hwform.cpp Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/hwform.cpp Wed Jan 17 19:56:51 2007 +0000
@@ -244,6 +244,7 @@
connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam)));
+ connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&)));
connect(ui.pageNetGame->pGameCFG, SIGNAL(seedChanged(const QString &)), hwnet, SLOT(onSeedChanged(const QString &)));
connect(ui.pageNetGame->pGameCFG, SIGNAL(mapChanged(const QString &)), hwnet, SLOT(onMapChanged(const QString &)));
--- a/QTfrontend/netserver.cpp Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/netserver.cpp Wed Jan 17 19:56:51 2007 +0000
@@ -33,7 +33,7 @@
void HWNetServer::StartServer()
{
IPCServer = new QTcpServer(this);
- if (!IPCServer->listen(QHostAddress::LocalHost, ds_port)) {
+ if (!IPCServer->listen(QHostAddress::Any, ds_port)) {
QMessageBox::critical(0, tr("Error"),
tr("Unable to start the server: %1.")
.arg(IPCServer->errorString()));
@@ -242,9 +242,24 @@
return;
}
+ if(lst[0]=="REMOVETEAM:") {
+ if(lst.size()<2) return;
+ removeTeam(lst[1]);
+ }
+
m_hwserver->sendOthers(this, msg);
}
+void HWConnectedClient::removeTeam(const QString& tname)
+{
+ for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it) {
+ if((*it)[0]==tname) {
+ m_teamsCfg.erase(it);
+ break;
+ }
+ }
+}
+
QList<QStringList> HWConnectedClient::getTeamNames() const
{
return m_teamsCfg;
--- a/QTfrontend/netserver.h Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/netserver.h Wed Jan 17 19:56:51 2007 +0000
@@ -53,6 +53,7 @@
QString client_nick;
void ParseLine(const QByteArray & line);
+ void removeTeam(const QString& tname);
HWNetServer* m_hwserver;
QTcpSocket* m_client;
--- a/QTfrontend/newnetclient.cpp Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/newnetclient.cpp Wed Jan 17 19:56:51 2007 +0000
@@ -24,6 +24,7 @@
#include "gameuiconfig.h"
#include "game.h"
#include "gamecfgwidget.h"
+#include "teamselect.h"
char delimeter='\t';
@@ -65,6 +66,11 @@
team.HHName[5] + delimeter + team.HHName[6] + delimeter + team.HHName[7]);
}
+void HWNewNet::RemoveTeam(const HWTeam & team)
+{
+ RawSendNet(QString("REMOVETEAM:") + delimeter + team.TeamName);
+}
+
void HWNewNet::StartGame()
{
RawSendNet(QString("START:"));
@@ -161,6 +167,12 @@
return;
}
+ if (lst[0] == "REMOVETEAM:") {
+ if(lst.size()<2) return;
+ m_pTeamSelWidget->removeNetTeam(lst[1]);
+ return;
+ }
+
if (lst[0] == "CONFIGASKED") {
isChief=true;
ConfigAsked();
@@ -222,7 +234,6 @@
// "CONNECTED" at round phase, etc.
if (lst[0] == "GAMEMSG:") {
QByteArray em = QByteArray::fromBase64(lst[1].toAscii());
- qDebug() << "to engine:" << em;
emit FromNet(em);
return;
}
--- a/QTfrontend/newnetclient.h Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/newnetclient.h Wed Jan 17 19:56:51 2007 +0000
@@ -98,6 +98,7 @@
public slots:
void SendNet(const QByteArray & buf);
void AddTeam(const HWTeam & team);
+ void RemoveTeam(const HWTeam& team);
void onSeedChanged(const QString & seed);
void onMapChanged(const QString & map);
void onThemeChanged(const QString & theme);
--- a/QTfrontend/teamselect.cpp Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/teamselect.cpp Wed Jan 17 19:56:51 2007 +0000
@@ -31,6 +31,8 @@
if(team.netTeam) {
framePlaying->addTeam(team, true);
curPlayingTeams.push_back(team);
+ QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
+ this, SLOT(netTeamStatusChanged(const HWTeam&)));
} else {
frameDontPlaying->addTeam(team, false);
curDontPlayingTeams.push_back(team);
@@ -39,6 +41,19 @@
}
}
+void TeamSelWidget::removeNetTeam(const HWTeam& team)
+{
+ list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
+ framePlaying->removeTeam(team);
+ curPlayingTeams.erase(itPlay);
+}
+
+void TeamSelWidget::netTeamStatusChanged(const HWTeam& team)
+{
+ list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
+
+}
+
//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team)
//{
//curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
@@ -54,6 +69,7 @@
if(!willBePlaying) {
// playing team => dont playing
curDontPlayingTeams.push_back(*itPlay);
+ emit teamNotPlaying(*itPlay);
curPlayingTeams.erase(itPlay);
} else {
// return if max playing teams reached
--- a/QTfrontend/teamselect.h Tue Jan 16 22:13:58 2007 +0000
+++ b/QTfrontend/teamselect.h Wed Jan 17 19:56:51 2007 +0000
@@ -40,18 +40,20 @@
public:
TeamSelWidget(QWidget* parent=0);
- //void removeTeam(HWTeam team);
+ void removeNetTeam(const HWTeam& team);
void resetPlayingTeams(const QList<HWTeam>& teamslist);
bool isPlaying(HWTeam team) const;
list<HWTeam> getPlayingTeams() const;
public slots:
void addTeam(HWTeam team);
-
+ void netTeamStatusChanged(const HWTeam& team);
+
signals:
void NewTeam();
void teamWillPlay(HWTeam team);
-
+ void teamNotPlaying(const HWTeam& team);
+
private slots:
void changeTeamStatus(HWTeam team);
void newTeamClicked();