QTfrontend/newnetclient.cpp
changeset 697 44f167938201
parent 660 7c155e849602
child 703 424297e3165a
equal deleted inserted replaced
696:d6f32ed6edc8 697:44f167938201
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  */
    17  */
    18 
    18 
    19 #include <QMessageBox>
    19 #include <QMessageBox>
    20 
    20 
       
    21 #include "hwconsts.h"
    21 #include "newnetclient.h"
    22 #include "newnetclient.h"
    22 #include "proto.h"
    23 #include "proto.h"
    23 #include "gameuiconfig.h"
    24 #include "gameuiconfig.h"
    24 #include "game.h"
    25 #include "game.h"
    25 #include "gamecfgwidget.h"
    26 #include "gamecfgwidget.h"
   280   	}
   281   	}
   281   	if (lst[1] == "FORTSMODE") {
   282   	if (lst[1] == "FORTSMODE") {
   282 	  emit fortsModeChanged(lst[2].toInt() != 0);
   283 	  emit fortsModeChanged(lst[2].toInt() != 0);
   283 	  return;
   284 	  return;
   284   	}
   285   	}
       
   286 	if (lst[1] == "AMMO") {
       
   287 	  emit ammoChanged(lst[2]);
       
   288 	  return;
       
   289 	}
   285 	QStringList hhTmpList=lst[1].split('+');
   290 	QStringList hhTmpList=lst[1].split('+');
   286   	if (hhTmpList[0] == "TEAM_COLOR") {
   291   	if (hhTmpList[0] == "TEAM_COLOR") {
   287 	  HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
   292 	  HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt());
   288 	  if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
   293 	  if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) {
   289 	    tmptm=HWTeam(hhTmpList[1]); // local team should be changed
   294 	    tmptm=HWTeam(hhTmpList[1]); // local team should be changed
   332   onSeedChanged(m_pGameCFGWidget->getCurrentSeed());
   337   onSeedChanged(m_pGameCFGWidget->getCurrentSeed());
   333   onThemeChanged(m_pGameCFGWidget->getCurrentTheme());
   338   onThemeChanged(m_pGameCFGWidget->getCurrentTheme());
   334   onInitHealthChanged(m_pGameCFGWidget->getInitHealth());
   339   onInitHealthChanged(m_pGameCFGWidget->getInitHealth());
   335   onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
   340   onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
   336   onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1);
   341   onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1);
       
   342   // always initialize with default ammo (also avoiding complicated cross-class dependencies)
       
   343   onWeaponsNameChanged(cDefaultAmmoStore->mid(10)); 
   337 }
   344 }
   338 
   345 
   339 void HWNewNet::RunGame()
   346 void HWNewNet::RunGame()
   340 {
   347 {
   341   emit AskForRunGame();
   348   emit AskForRunGame();
   383 void HWNewNet::onFortsModeChanged(bool value)
   390 void HWNewNet::onFortsModeChanged(bool value)
   384 {
   391 {
   385   RawSendNet(QString("CONFIG_PARAM%1FORTSMODE%1%2").arg(delimeter).arg(value));
   392   RawSendNet(QString("CONFIG_PARAM%1FORTSMODE%1%2").arg(delimeter).arg(value));
   386 }
   393 }
   387 
   394 
       
   395 void HWNewNet::onWeaponsNameChanged(const QString& ammo)
       
   396 {
       
   397   RawSendNet(QString("CONFIG_PARAM%1AMMO%1%2").arg(delimeter).arg(ammo));
       
   398 }
       
   399 
   388 void HWNewNet::chatLineToNet(const QString& str)
   400 void HWNewNet::chatLineToNet(const QString& str)
   389 {
   401 {
   390   if(str!="") {
   402   if(str!="") {
   391     RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str);
   403     RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str);
   392     emit(chatStringFromNet(QStringList(mynick) << str));
   404     emit(chatStringFromNet(QStringList(mynick) << str));