QTfrontend/netserver.cpp
changeset 335 751348947fce
parent 334 85eacbd9827f
child 338 d1e75dcd285f
equal deleted inserted replaced
334:85eacbd9827f 335:751348947fce
    85 bool HWNetServer::isChiefClient(HWConnectedClient* cl) const
    85 bool HWNetServer::isChiefClient(HWConnectedClient* cl) const
    86 {
    86 {
    87   return getChiefClient()==cl;
    87   return getChiefClient()==cl;
    88 }
    88 }
    89 
    89 
    90 QStringList HWNetServer::getGameCfg() const
    90 QMap<QString, QString> HWNetServer::getGameCfg() const
    91 {
    91 {
    92   for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
    92   for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
    93     if(isChiefClient(*it)) return (*it)->gameCfg;
    93     if(isChiefClient(*it)) {
       
    94       return (*it)->m_gameCfg;
       
    95     }
    94   }
    96   }
    95   // error happened if we are here
    97   // error happened if we are here
    96   return QStringList();
    98   return QMap<QString, QString>();
    97 }
    99 }
    98 
   100 
    99 bool HWNetServer::haveNick(const QString& nick) const
   101 bool HWNetServer::haveNick(const QString& nick) const
   100 {
   102 {
   101   for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
   103   for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
   210     client_nick=lst[1];
   212     client_nick=lst[1];
   211     qDebug() << "send connected";
   213     qDebug() << "send connected";
   212     RawSendNet(QString("CONNECTED"));
   214     RawSendNet(QString("CONNECTED"));
   213     m_hwserver->teamChanged();
   215     m_hwserver->teamChanged();
   214     if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED"));
   216     if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED"));
   215     else RawSendNet(QString("CONFIGURED")+delimeter+m_hwserver->getGameCfg().join(QString(delimeter)));
   217     else {
       
   218       QMap<QString, QString> conf=m_hwserver->getGameCfg();
       
   219       for(QMap<QString, QString>::iterator it=conf.begin(); it!=conf.end(); ++it) {
       
   220 	RawSendNet(QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value());
       
   221       }
       
   222     }
   216     return;
   223     return;
   217   }
   224   }
   218   if(client_nick=="") return;
   225   if(client_nick=="") return;
   219 
   226 
   220   if (lst[0]=="START:") {
   227   if (lst[0]=="START:") {
   223       // start
   230       // start
   224     }
   231     }
   225     return;
   232     return;
   226   }
   233   }
   227 
   234 
   228   if(lst[0]=="CONFIGANSWER") {
   235   if(lst[0]=="CONFIG_PARAM") {
   229     lst.pop_front();
   236     if(!m_hwserver->isChiefClient(this) || lst.size()<3) return; // error or permission denied :)
   230     gameCfg=lst;
   237     else m_gameCfg[lst[1]]=lst[2];
   231     return;
       
   232   }
   238   }
   233 
   239 
   234   if(lst[0]=="ADDTEAM:") {
   240   if(lst[0]=="ADDTEAM:") {
   235     if(lst.size()<10) return;
   241     if(lst.size()<10) return;
   236     lst.pop_front();
   242     lst.pop_front();