QTfrontend/newnetclient.cpp
changeset 573 e0cf483e68d6
parent 486 7ea71cd3acd5
child 574 1cafd9eb1a21
equal deleted inserted replaced
572:302ad5c3836d 573:e0cf483e68d6
   157     return;
   157     return;
   158   }
   158   }
   159 
   159 
   160   if (lst[0] == "CHAT_STRING") {
   160   if (lst[0] == "CHAT_STRING") {
   161     lst.pop_front();
   161     lst.pop_front();
   162     if(lst.size() < 2) return;
   162     if(lst.size() < 2)
       
   163     {
       
   164 	  qWarning("Net: Empty CHAT_STRING message");
       
   165 	  return;
       
   166     }
   163     emit chatStringFromNet(lst);
   167     emit chatStringFromNet(lst);
   164     return;
   168     return;
   165   }
   169   }
   166 
   170 
   167   if (lst[0] == "ADDTEAM:") {
   171   if (lst[0] == "ADDTEAM:") {
   169     emit AddNetTeam(lst);
   173     emit AddNetTeam(lst);
   170     return;
   174     return;
   171   }
   175   }
   172 
   176 
   173   if (lst[0] == "REMOVETEAM:") {
   177   if (lst[0] == "REMOVETEAM:") {
   174     if(lst.size()<3) return;
   178     if(lst.size() < 3)
       
   179     {
       
   180       qWarning("Net: Bad REMOVETEAM message");
       
   181       return;
       
   182     }
   175     m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt()));
   183     m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt()));
   176     return;
   184     return;
   177   }
   185   }
   178 
   186 
   179   if(lst[0]=="SLAVE") {
   187   if(lst[0]=="SLAVE") {
   181     m_pTeamSelWidget->setNonInteractive();
   189     m_pTeamSelWidget->setNonInteractive();
   182     return;
   190     return;
   183   }
   191   }
   184 
   192 
   185   if(lst[0]=="JOINED") {
   193   if(lst[0]=="JOINED") {
   186     if(lst.size()<2) return;
   194     if(lst.size() < 2)
       
   195     {
       
   196       qWarning("Net: Bad JOINED message");
       
   197       return;
       
   198     }
   187     emit nickAdded(lst[1]);
   199     emit nickAdded(lst[1]);
   188     return;
   200     return;
   189   }
   201   }
   190 
   202 
   191   if(lst[0]=="LEFT") {
   203   if(lst[0]=="LEFT") {
   192     if(lst.size()<2) return;
   204     if(lst.size() < 2)
       
   205     {
       
   206       qWarning("Net: Bad LEFT message");
       
   207       return;
       
   208     }
   193     emit nickRemoved(lst[1]);
   209     emit nickRemoved(lst[1]);
   194     return;
   210     return;
   195   }
   211   }
   196 
   212 
   197   if (lst[0] == "CONFIGASKED") {
   213   if (lst[0] == "CONFIGASKED") {
   205     return;
   221     return;
   206   }
   222   }
   207 
   223 
   208   if (lst[0] == "CONFIGURED") {
   224   if (lst[0] == "CONFIGURED") {
   209     lst.pop_front();
   225     lst.pop_front();
   210     if(lst.size()<5) return;
   226     if(lst.size() < 6)
       
   227     {
       
   228       qWarning("Net: Bad CONFIGURED message");
       
   229       return;
       
   230     }
   211     emit seedChanged(lst[0]);
   231     emit seedChanged(lst[0]);
   212     emit mapChanged(lst[1]);
   232     emit mapChanged(lst[1]);
   213     emit themeChanged(lst[2]);
   233     emit themeChanged(lst[2]);
   214     emit initHealthChanged(lst[3].toUInt());
   234     emit initHealthChanged(lst[3].toUInt());
   215     emit turnTimeChanged(lst[4].toUInt());
   235     emit turnTimeChanged(lst[4].toUInt());
   216     emit fortsModeChanged(lst[5].toInt() != 0);
   236     emit fortsModeChanged(lst[5].toInt() != 0);
   217     return;
   237     return;
   218   }
   238   }
   219 
   239 
   220   if(lst[0]=="TEAM_ACCEPTED") {
   240   if(lst[0]=="TEAM_ACCEPTED") {
       
   241     if(lst.size() < 3)
       
   242     {
       
   243       qWarning("Net: Bad TEAM_ACCEPTED message");
       
   244       return;
       
   245     }
   221     m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]);
   246     m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]);
   222     m_pTeamSelWidget->changeTeamStatus(lst[1]);
   247     m_pTeamSelWidget->changeTeamStatus(lst[1]);
   223     return;
   248     return;
   224   }
   249   }
   225 
   250 
   226   if (lst[0] == "CONFIG_PARAM") {
   251   if (lst[0] == "CONFIG_PARAM") {
       
   252     if(lst.size() < 3)
       
   253     {
       
   254       qWarning("Net: Bad CONFIG_PARAM message");
       
   255       return;
       
   256     }
   227   	if (lst[1] == "SEED") {
   257   	if (lst[1] == "SEED") {
   228 	  emit seedChanged(lst[2]);
   258 	  emit seedChanged(lst[2]);
   229 	  return;
   259 	  return;
   230   	}
   260   	}
   231   	if (lst[1] == "MAP") {
   261   	if (lst[1] == "MAP") {
   265 	  }
   295 	  }
   266 	  tmptm.numHedgehogs=lst[2].toUInt();
   296 	  tmptm.numHedgehogs=lst[2].toUInt();
   267 	  emit hhnumChanged(tmptm);
   297 	  emit hhnumChanged(tmptm);
   268 	  return;
   298 	  return;
   269   	}
   299   	}
       
   300     qWarning(QString("Net: Unknown 'CONFIG_PARAM' message: '%1'").arg(msg).toAscii().data());
   270     return;
   301     return;
   271   }
   302   }
   272 
   303 
   273 
   304 
   274   // should be kinda game states, which don't allow "GAMEMSG:" at configure step,
   305   // should be kinda game states, which don't allow "GAMEMSG:" at configure step,
   275   // "CONNECTED" at round phase, etc.
   306   // "CONNECTED" at round phase, etc.
   276   if (lst[0] == "GAMEMSG:") {
   307   if (lst[0] == "GAMEMSG:") {
       
   308     if(lst.size() < 2)
       
   309     {
       
   310       qWarning("Net: Bad LEFT message");
       
   311       return;
       
   312     }
   277     QByteArray em = QByteArray::fromBase64(lst[1].toAscii());
   313     QByteArray em = QByteArray::fromBase64(lst[1].toAscii());
   278     emit FromNet(em);
   314     emit FromNet(em);
   279     return;
   315     return;
   280   }
   316   }
       
   317 
       
   318   qWarning(QString("Net: Unknown message: '%1'").arg(msg).toAscii().data());
   281 }
   319 }
   282 
   320 
   283 
   321 
   284 void HWNewNet::ConfigAsked()
   322 void HWNewNet::ConfigAsked()
   285 {
   323 {