# HG changeset patch
# User unc0rr
# Date 1222726463 0
# Node ID c6fe8a4bfd344968170e048a92175ef21a553862
# Parent  22c03f69e142427e9367b3c4db6d611019aa0c8a
Fix a bug screwing team selection up in network game
(REMOVETEAM message doesn't have teamID, and after
removing the team QMap still contains old info, when
add and remove team with the same name, total hedgehogs
number will be decreased by first team hh number)

diff -r 22c03f69e142 -r c6fe8a4bfd34 QTfrontend/netconnectedclient.cpp
--- a/QTfrontend/netconnectedclient.cpp	Mon Sep 29 22:01:06 2008 +0000
+++ b/QTfrontend/netconnectedclient.cpp	Mon Sep 29 22:14:23 2008 +0000
@@ -62,7 +62,7 @@
 
 void HWConnectedClient::ParseCmd(const QStringList & lst)
 {
-qDebug() << "Server: Parsing:" << lst;
+//qDebug() << "Server: Parsing:" << lst;
   if(!lst.size())
   {
     qWarning("Net server: Bad message");
@@ -138,6 +138,7 @@
     tmp=QStringList("CONFIG_PARAM") << confstr << lst[3];
     m_hwserver->sendOthers(this, tmp.join(QString(delimeter)));
     m_hwserver->m_gameCfg[tmp[1]]=tmp.mid(2);
+qDebug() << QString("[%1] = %2").arg(tmp[1]).arg(tmp.mid(2)[0]);
     return;
   }
 
@@ -168,13 +169,13 @@
     tmp.insert(1, QString::number(++netTeamID));
 
     // hedgehogs num count
-    int maxAdd=18-m_hwserver->hhnum;
-    if (maxAdd<=0)
+    int maxAdd = 18 - m_hwserver->hhnum;
+    if (maxAdd <= 0)
     {
 	  qWarning("Net server: 'ADDTEAM' message: rejecting");
 	  return; // reject command
     }
-    int toAdd=maxAdd<4 ? maxAdd : 4;
+    int toAdd=maxAdd < 4 ? maxAdd : 4;
     m_hwserver->hhnum+=toAdd;
 qDebug() << "to add = " << toAdd << "m_hwserver->hhnum = " << m_hwserver->hhnum;
     // hedgehogs num config
@@ -190,7 +191,7 @@
     m_hwserver->m_gameCfg[colorCfg.split(delimeter)[1]]=colorCfg.split(delimeter).mid(2);
     m_hwserver->m_gameCfg[hhnumCfg.split(delimeter)[1]]=hhnumCfg.split(delimeter).mid(2);
     m_teamsCfg.push_back(tmp);
-
+qDebug() << QString("[%1] = %2").arg(hhnumCfg.split(delimeter)[1]).arg(hhnumCfg.split(delimeter).mid(2)[0]);
     m_hwserver->sendOthers(this, QString("ADDTEAM:")+delimeter+tmp.join(QString(delimeter)));
     RawSendNet(QString("TEAM_ACCEPTED%1%2%1%3").arg(delimeter).arg(tmp[0]).arg(tmp[1]));
     m_hwserver->sendAll(colorCfg);
@@ -213,6 +214,7 @@
         if(hhTmpList[1]==lst[1])
         {
 		  m_hwserver->hhnum-=it.value()[0].toUInt();
+		  m_hwserver->m_gameCfg.remove(it.key());
 qDebug() << "REMOVETEAM hhnum = " << m_hwserver->hhnum;
 		  break;
         }