some colors and network protocol fixes
authordisplacer
Tue, 06 Feb 2007 21:46:33 +0000
changeset 401 bcebe3921740
parent 400 450ff6326084
child 402 db88644ecf4b
some colors and network protocol fixes
QTfrontend/netserver.cpp
QTfrontend/newnetclient.cpp
--- a/QTfrontend/netserver.cpp	Tue Feb 06 21:33:19 2007 +0000
+++ b/QTfrontend/netserver.cpp	Tue Feb 06 21:46:33 2007 +0000
@@ -228,8 +228,10 @@
       }
       // send config
       QMap<QString, QStringList> conf=m_hwserver->getGameCfg();
+      qDebug() << "Config:";
       for(QMap<QString, QStringList>::iterator it=conf.begin(); it!=conf.end(); ++it) {
 	RawSendNet(QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter)));
+	qDebug() << QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter));
       }
     }
     return;
@@ -249,6 +251,7 @@
   if(lst[0]=="CONFIG_PARAM") {
     if(!m_hwserver->isChiefClient(this) || lst.size()<3) return; // error or permission denied :)
     else m_gameCfg[lst[1]]=lst.mid(2);
+    qDebug() << msg;
   }
 
   if(lst[0]=="ADDTEAM:") {
@@ -256,8 +259,8 @@
     lst.pop_front();
     
     // add team ID
-    static unsigned int netTeamID=1;
-    lst.insert(1, QString::number(netTeamID++));
+    static unsigned int netTeamID=0;
+    lst.insert(1, QString::number(++netTeamID));
 
     // hedgehogs num count
     int maxAdd=18-m_hwserver->hhnum;
@@ -270,7 +273,7 @@
       .arg(toAdd);
     
     // creating color config for new team
-    QString colorCfg=QString("CONFIG_PARAM%1TEAM_COLOR%1%2%1%3%1%4").arg(delimeter).arg(lst[0])\
+    QString colorCfg=QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(lst[0])\
       .arg(netTeamID)\
       .arg(lst.takeAt(2));
     qDebug() << "color config:" << colorCfg;
@@ -302,6 +305,7 @@
 
     unsigned int netID=removeTeam(lst[1]);
     m_hwserver->sendOthers(this, QString("REMOVETEAM:")+delimeter+lst[1]+delimeter+QString::number(netID));
+    qDebug() << QString("REMOVETEAM:")+delimeter+lst[1]+delimeter+QString::number(netID);
     return;
   }
 
--- a/QTfrontend/newnetclient.cpp	Tue Feb 06 21:33:19 2007 +0000
+++ b/QTfrontend/newnetclient.cpp	Tue Feb 06 21:46:33 2007 +0000
@@ -72,6 +72,7 @@
 void HWNewNet::RemoveTeam(const HWTeam & team)
 {
   RawSendNet(QString("REMOVETEAM:") + delimeter + team.TeamName);
+  m_networkToLocalteams.remove(m_networkToLocalteams.key(team.TeamName));
 }
 
 void HWNewNet::StartGame()
@@ -197,6 +198,7 @@
   }
 
   if(lst[0]=="TEAM_ACCEPTED") {
+    qDebug() << "accepted " << lst[2].toUInt() << " team";
     m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]);
     m_pTeamSelWidget->changeTeamStatus(lst[1]);
     return;
@@ -227,17 +229,17 @@
 	  emit fortsModeChanged(lst[2].toInt() != 0);
 	  return;
   	}
-  	if (lst[1] == "TEAM_COLOR") {
-	  HWTeam tmptm(lst[2], lst[3].toUInt());
-	  if(m_networkToLocalteams.find(lst[3].toUInt())!=m_networkToLocalteams.end()) {
-	    tmptm=HWTeam(lst[2]); // local team should be changed
+	QStringList hhTmpList=lst[1].split('+');
+  	if (hhTmpList[0] == "TEAM_COLOR") {
+	  HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
+	  if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
+	    tmptm=HWTeam(hhTmpList[1]); // local team should be changed
 	  }
-	  tmptm.teamColor=QColor(lst[4]);
+	  tmptm.teamColor=QColor(lst[2]);
 	  emit teamColorChanged(tmptm);
 	  return;
   	}
-	QStringList hhTmpList;
-  	if ((hhTmpList=lst[1].split('+'))[0] == "HHNUM") {
+  	if (hhTmpList[0] == "HHNUM") {
 	  qDebug() << "NEW HHNUM!";
 	  HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
 	  if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
@@ -294,7 +296,7 @@
 void HWNewNet::onTeamColorChanged(const HWTeam& team)
 {
   qDebug() << team.getNetID() << ":" << team.teamColor.name();
-  RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR%1%2%1%3%1%4").arg(delimeter).arg(team.TeamName)\
+  RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\
 	     .arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\
 	     .arg(team.teamColor.name()));
 }