QTfrontend/netserver.cpp
changeset 352 4665bfe25470
parent 350 c3ccec3834e8
child 354 60e4af0a4375
equal deleted inserted replaced
351:29bc9c36ad5f 352:4665bfe25470
   239   }
   239   }
   240 
   240 
   241   if(lst[0]=="ADDTEAM:") {
   241   if(lst[0]=="ADDTEAM:") {
   242     if(lst.size()<10) return;
   242     if(lst.size()<10) return;
   243     lst.pop_front();
   243     lst.pop_front();
       
   244     // add team ID
       
   245     static unsigned int netTeamID=1;
       
   246     lst.insert(1, QString::number(netTeamID++));
       
   247 
   244     m_teamsCfg.push_back(lst);
   248     m_teamsCfg.push_back(lst);
   245     m_hwserver->sendOthers(this, msg);
   249     m_hwserver->sendOthers(this, QString("ADDTEAM:")+delimeter+lst.join(QString(delimeter)));
   246     return;
   250     return;
   247   }
   251   }
   248 
   252 
   249   if(lst[0]=="REMOVETEAM:") {
   253   if(lst[0]=="REMOVETEAM:") {
   250     if(lst.size()<2) return;
   254     if(lst.size()<2) return;
   251     removeTeam(lst[1]);
   255     unsigned int netID=removeTeam(lst[1]);
       
   256     m_hwserver->sendOthers(this, QString("REMOVETEAM:")+delimeter+lst[1]+delimeter+QString::number(netID));
       
   257     return;
   252   }
   258   }
   253 
   259 
   254   m_hwserver->sendOthers(this, msg);
   260   m_hwserver->sendOthers(this, msg);
   255 }
   261 }
   256 
   262 
   257 void HWConnectedClient::removeTeam(const QString& tname)
   263 unsigned int HWConnectedClient::removeTeam(const QString& tname)
   258 {
   264 {
       
   265   unsigned int netID=0;
   259   for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it) {
   266   for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it) {
   260     if((*it)[0]==tname) {
   267     if((*it)[0]==tname) {
       
   268       netID=(*it)[1].toUInt();
   261       m_teamsCfg.erase(it);
   269       m_teamsCfg.erase(it);
   262       break;
   270       break;
   263     }
   271     }
   264   }
   272   }
       
   273   return netID;
   265 }
   274 }
   266 
   275 
   267 QList<QStringList> HWConnectedClient::getTeamNames() const
   276 QList<QStringList> HWConnectedClient::getTeamNames() const
   268 {
   277 {
   269   return m_teamsCfg;
   278   return m_teamsCfg;