QTfrontend/netconnectedclient.cpp
changeset 1302 4290ba4a14ca
parent 1301 c6fe8a4bfd34
child 1303 f90bf2276639
equal deleted inserted replaced
1301:c6fe8a4bfd34 1302:4290ba4a14ca
   173     if (maxAdd <= 0)
   173     if (maxAdd <= 0)
   174     {
   174     {
   175 	  qWarning("Net server: 'ADDTEAM' message: rejecting");
   175 	  qWarning("Net server: 'ADDTEAM' message: rejecting");
   176 	  return; // reject command
   176 	  return; // reject command
   177     }
   177     }
       
   178     if (netIDbyTeamName(tmp[0]) > 0)
       
   179     {
       
   180 	  qWarning("Net server: 'ADDTEAM' message: rejecting (have team with same name)");
       
   181 	  return; // reject command
       
   182 
       
   183     }
   178     int toAdd=maxAdd < 4 ? maxAdd : 4;
   184     int toAdd=maxAdd < 4 ? maxAdd : 4;
   179     m_hwserver->hhnum+=toAdd;
   185     m_hwserver->hhnum+=toAdd;
   180 qDebug() << "to add = " << toAdd << "m_hwserver->hhnum = " << m_hwserver->hhnum;
   186 qDebug() << "to add = " << toAdd << "m_hwserver->hhnum = " << m_hwserver->hhnum;
   181     // hedgehogs num config
   187     // hedgehogs num config
   182     QString hhnumCfg=QString("CONFIG_PARAM%1HHNUM+%2+%3%1%4").arg(delimeter).arg(tmp[0])\
   188     QString hhnumCfg=QString("CONFIG_PARAM%1HHNUM+%2+%3%1%4").arg(delimeter).arg(tmp[0])\
   227   }
   233   }
   228 
   234 
   229   m_hwserver->sendOthers(this, lst.join(QString(delimeter)));
   235   m_hwserver->sendOthers(this, lst.join(QString(delimeter)));
   230 }
   236 }
   231 
   237 
       
   238 unsigned int HWConnectedClient::netIDbyTeamName(const QString& tname)
       
   239 {
       
   240     qDebug() << "Check exist" << tname;
       
   241 
       
   242 	for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it)
       
   243 		if((*it)[0]==tname)
       
   244 			return (*it)[1].toUInt();
       
   245 
       
   246 	return 0;
       
   247 }
       
   248 
   232 unsigned int HWConnectedClient::removeTeam(const QString& tname)
   249 unsigned int HWConnectedClient::removeTeam(const QString& tname)
   233 {
   250 {
   234 	unsigned int netID=0;
   251 	unsigned int netID = netIDbyTeamName(tname);
   235 	for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it) {
   252 	
   236 		if((*it)[0]==tname) {
       
   237 			netID=(*it)[1].toUInt();
       
   238 			m_teamsCfg.erase(it);
       
   239 			break;
       
   240 		}
       
   241 	}
       
   242 	if (netID == 0)
   253 	if (netID == 0)
   243 		qDebug() << QString("removeTeam: team '%1' not found").arg(tname);
   254 		qDebug() << QString("removeTeam: team '%1' not found").arg(tname);
   244 
   255 
   245 	return netID;
   256 	return netID;
   246 }
   257 }