start all clients
authordisplacer
Thu, 11 Jan 2007 22:04:08 +0000
changeset 317 e95340dbfc1d
parent 316 57d50189ad86
child 318 46a43b02bbb3
start all clients
QTfrontend/netserver.cpp
QTfrontend/netserver.h
--- a/QTfrontend/netserver.cpp	Thu Jan 11 20:45:59 2007 +0000
+++ b/QTfrontend/netserver.cpp	Thu Jan 11 22:04:08 2007 +0000
@@ -73,6 +73,14 @@
   return ds_port;
 }
 
+bool HWNetServer::isCheefClient(HWConnectedClient* cl) const
+{
+  for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
+    if((*it)->getClientNick()!="" && *it==cl)  return true;
+  }
+  return false;
+}
+
 bool HWNetServer::haveNick(const QString& nick) const
 {
   for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
@@ -123,6 +131,13 @@
   return msg;
 }
 
+void HWNetServer::startAll(QString gameCfg)
+{
+  for(QList<HWConnectedClient*>::iterator it=connclients.begin(); it!=connclients.end(); ++it) {
+    (*it)->RawSendNet(gameCfg);
+  }
+}
+
 HWConnectedClient::HWConnectedClient(HWNetServer* hwserver, QTcpSocket* client) :
   readyToStart(false),
   m_hwserver(hwserver),
@@ -172,6 +187,7 @@
     qDebug() << "send connected";
     RawSendNet(QString("CONNECTED"));
     m_hwserver->teamChanged();
+    if(m_hwserver->isCheefClient(this)) RawSendNet(QString("CONFIGASKED"));
     return;
   }
   if(client_nick=="") return;
@@ -180,14 +196,14 @@
     readyToStart=true;
     if(m_hwserver->shouldStart(this)) {
       // start
-      RawSendNet(QString("CONFIGASKED"));
+      m_hwserver->startAll(QString("CONFIGURED")+delimeter+m_hwserver->prepareConfig(gameCfg)+delimeter+"!"+delimeter);
     }
     return;
   }
 
   if(lst[0]=="CONFIGANSWER") {
     lst.pop_front();
-    RawSendNet(QString("CONFIGURED")+QString(delimeter)+m_hwserver->prepareConfig(lst)+delimeter+"!"+delimeter);
+    gameCfg=lst;
     return;
   }
 
--- a/QTfrontend/netserver.h	Thu Jan 11 20:45:59 2007 +0000
+++ b/QTfrontend/netserver.h	Thu Jan 11 22:04:08 2007 +0000
@@ -32,7 +32,9 @@
 {
   Q_OBJECT
 
- public:
+ friend class HWNetServer;
+
+ private:
   HWConnectedClient(HWNetServer* hwserver, QTcpSocket* client);
   ~HWConnectedClient();
   QString getClientNick() const;
@@ -44,8 +46,8 @@
 
   QString getHedgehogsDescription() const;
 
- private:
   bool readyToStart;
+  QStringList gameCfg;
   class ShouldDisconnectException {};
   
   QString client_nick;
@@ -75,6 +77,8 @@
  public:
   void StartServer();
   void StopServer();
+  bool isCheefClient(HWConnectedClient* cl) const;
+  void startAll(QString gameCfg);
   bool haveNick(const QString& nick) const;
   QString getRunningHostName() const;
   quint16 getRunningPort() const;