QTfrontend/newnetclient.cpp
changeset 1324 4b48ae1f0f53
parent 1322 c624b04699fb
child 1325 c8994d47f41d
equal deleted inserted replaced
1323:d166f9069c2b 1324:4b48ae1f0f53
   105 }
   105 }
   106 
   106 
   107 void HWNewNet::RemoveTeam(const HWTeam & team)
   107 void HWNewNet::RemoveTeam(const HWTeam & team)
   108 {
   108 {
   109   RawSendNet(QString("REMOVETEAM") + delimeter + team.TeamName);
   109   RawSendNet(QString("REMOVETEAM") + delimeter + team.TeamName);
   110   m_networkToLocalteams.remove(m_networkToLocalteams.key(team.TeamName));
       
   111 }
   110 }
   112 
   111 
   113 void HWNewNet::Ready()
   112 void HWNewNet::Ready()
   114 {
   113 {
   115   RawSendNet(QString("READY"));
   114   RawSendNet(QString("READY"));
   305     if(lst.size() < 3)
   304     if(lst.size() < 3)
   306     {
   305     {
   307       qWarning("Net: Bad TEAM_ACCEPTED message");
   306       qWarning("Net: Bad TEAM_ACCEPTED message");
   308       return;
   307       return;
   309     }
   308     }
   310     m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]);
       
   311     m_pTeamSelWidget->changeTeamStatus(lst[1]);
   309     m_pTeamSelWidget->changeTeamStatus(lst[1]);
   312     return;
   310     return;
   313   }
   311   }
   314 
   312 
   315 	if (lst[0] == "CONFIG_PARAM") {
   313 	if (lst[0] == "CONFIG_PARAM") {
   345 		if (lst[1] == "AMMO") {
   343 		if (lst[1] == "AMMO") {
   346 			if(lst.size() < 4) return;
   344 			if(lst.size() < 4) return;
   347 			emit ammoChanged(lst[3], lst[2]);
   345 			emit ammoChanged(lst[3], lst[2]);
   348 			return;
   346 			return;
   349 		}
   347 		}
   350 		QStringList hhTmpList=lst[1].split('+');
   348 		QStringList hhTmpList = lst[1].split('+');
   351 		if (hhTmpList[0] == "TEAM_COLOR") {
   349 		if (hhTmpList[0] == "TEAM_COLOR") {
   352 			HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
   350 			HWTeam tmptm(hhTmpList[1]);
   353 			if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
   351 			tmptm.teamColor = QColor(lst[2]);
   354 				tmptm=HWTeam(hhTmpList[1]); // local team should be changed
       
   355 			}
       
   356 			tmptm.teamColor=QColor(lst[2]);
       
   357 			emit teamColorChanged(tmptm);
   352 			emit teamColorChanged(tmptm);
   358 			return;
   353 			return;
   359 		}
   354 		}
   360 		if (hhTmpList[0] == "HHNUM") {
   355 		if (hhTmpList[0] == "HHNUM") {
   361 			HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
   356 			HWTeam tmptm(hhTmpList[1]);
   362 			if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
   357 			tmptm.numHedgehogs = lst[2].toUInt();
   363 				tmptm=HWTeam(hhTmpList[1]); // local team should be changed
       
   364 			}
       
   365 			tmptm.numHedgehogs=lst[2].toUInt();
       
   366 			emit hhnumChanged(tmptm);
   358 			emit hhnumChanged(tmptm);
   367 			return;
   359 			return;
   368 		}
   360 		}
   369 		qWarning() << "Net: Unknown 'CONFIG_PARAM' message:" << lst;
   361 		qWarning() << "Net: Unknown 'CONFIG_PARAM' message:" << lst;
   370 		return;
   362 		return;
   408 	emit AskForRunGame();
   400 	emit AskForRunGame();
   409 }
   401 }
   410 
   402 
   411 void HWNewNet::onHedgehogsNumChanged(const HWTeam& team)
   403 void HWNewNet::onHedgehogsNumChanged(const HWTeam& team)
   412 {
   404 {
   413 	RawSendNet(QString("HHNUM%1%2%1%3%1%4").arg(delimeter).arg(team.TeamName)
   405 	RawSendNet(QString("HHNUM%1%2%1%3")
   414 			.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))
   406 			.arg(delimeter)
       
   407 			.arg(team.TeamName)
   415 			.arg(team.numHedgehogs));
   408 			.arg(team.numHedgehogs));
   416 }
   409 }
   417 
   410 
   418 void HWNewNet::onTeamColorChanged(const HWTeam& team)
   411 void HWNewNet::onTeamColorChanged(const HWTeam& team)
   419 {
   412 {
   420 	RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)
   413 	RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR%1%2%1%3")
   421 			.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))
   414 			.arg(delimeter)
       
   415 			.arg(team.TeamName)
   422 			.arg(team.teamColor.name()));
   416 			.arg(team.teamColor.name()));
   423 }
   417 }
   424 
   418 
   425 void HWNewNet::onSeedChanged(const QString & seed)
   419 void HWNewNet::onSeedChanged(const QString & seed)
   426 {
   420 {