- Send initial room config
authorunc0rr
Mon, 09 Mar 2009 10:54:44 +0000
changeset 1875 189370d394db
parent 1874 1b145e099b75
child 1876 b13dd4e6e98e
- Send initial room config
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
--- a/QTfrontend/gamecfgwidget.cpp	Sun Mar 08 20:22:52 2009 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Mon Mar 09 10:54:44 2009 +0000
@@ -127,55 +127,25 @@
 	return result;
 }
 
-QString GameCFGWidget::getCurrentSeed() const
-{
-  return pMapContainer->getCurrentSeed();
-}
-
-QString GameCFGWidget::getCurrentMap() const
-{
-  return pMapContainer->getCurrentMap();
-}
-
-QString GameCFGWidget::getCurrentTheme() const
-{
-  return pMapContainer->getCurrentTheme();
-}
-
 quint32 GameCFGWidget::getInitHealth() const
 {
 	return SB_InitHealth->value();
 }
 
-quint32 GameCFGWidget::getTurnTime() const
-{
-	return SB_TurnTime->value();
-}
-
-quint32 GameCFGWidget::getSuddenDeathTurns() const
-{
-	return SB_SuddenDeath->value();
-}
-
-quint32 GameCFGWidget::getCaseProbability() const
-{
-	return SB_CaseProb->value();
-}
-
 QStringList GameCFGWidget::getFullConfig() const
 {
 	QStringList sl;
-	sl.append("eseed " + getCurrentSeed());
+	sl.append("eseed " + pMapContainer->getCurrentSeed());
 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
-	sl.append(QString("e$turntime %1").arg(getTurnTime() * 1000));
-	sl.append(QString("e$sd_turns %1").arg(getSuddenDeathTurns()));
-	sl.append(QString("e$casefreq %1").arg(getCaseProbability()));
+	sl.append(QString("e$turntime %1").arg(SB_TurnTime->value() * 1000));
+	sl.append(QString("e$sd_turns %1").arg(SB_SuddenDeath->value()));
+	sl.append(QString("e$casefreq %1").arg(SB_CaseProb->value()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
 
-	QString currentMap = getCurrentMap();
+	QString currentMap = pMapContainer->getCurrentMap();
 	if (currentMap.size() > 0)
 		sl.append("emap " + currentMap);
-	sl.append("etheme " + getCurrentTheme());
+	sl.append("etheme " + pMapContainer->getCurrentTheme());
 	return sl;
 }
 
@@ -194,6 +164,27 @@
 	}
 }
 
+void GameCFGWidget::fullNetConfig()
+{
+	ammoChanged(WeaponsName->currentIndex());
+	
+	borderChanged(CB_border->isChecked());
+	caseProbabilityChanged(SB_CaseProb->value());
+	fortsModeChanged(CB_mode_Forts->isChecked());
+	initHealthChanged(SB_CaseProb->value());
+	seedChanged(pMapContainer->getCurrentSeed());
+	solidChanged(CB_solid->isChecked());
+	suddenDeathTurnsChanged(SB_SuddenDeath->value());
+	teamsDivideChanged(CB_teamsDivide->isChecked());
+	themeChanged(pMapContainer->getCurrentTheme());
+	turnTimeChanged(SB_TurnTime->value());
+
+	// map must be the last
+	QString map = pMapContainer->getCurrentMap();
+	if (map.size())
+		mapChanged(map);
+}
+
 void GameCFGWidget::setParam(const QString & param, const QStringList & slValue)
 {
 	if (slValue.size() == 1)
@@ -258,7 +249,6 @@
 	}
 }
 
-
 void GameCFGWidget::ammoChanged(int index)
 {
 	if (index >= 0)
--- a/QTfrontend/gamecfgwidget.h	Sun Mar 08 20:22:52 2009 +0000
+++ b/QTfrontend/gamecfgwidget.h	Mon Mar 09 10:54:44 2009 +0000
@@ -59,19 +59,14 @@
 public:
 	GameCFGWidget(QWidget* parent, bool externalControl=false);
 	quint32 getGameFlags() const;
-	QString getCurrentSeed() const;
-	QString getCurrentMap() const;
-	QString getCurrentTheme() const;
 	quint32 getInitHealth() const;
-	quint32 getTurnTime() const;
-	quint32 getSuddenDeathTurns() const;
-	quint32 getCaseProbability() const;
 	QStringList getFullConfig() const;
-	QComboBox* WeaponsName;
+	QComboBox * WeaponsName;
 	HWMapContainer* pMapContainer;
 
 public slots:
 	void setParam(const QString & param, const QStringList & value);
+	void fullNetConfig();
 
 signals:
 	void paramChanged(const QString & param, const QStringList & value);
--- a/QTfrontend/hwform.cpp	Sun Mar 08 20:22:52 2009 +0000
+++ b/QTfrontend/hwform.cpp	Mon Mar 09 10:54:44 2009 +0000
@@ -569,6 +569,7 @@
 // config stuff
 	connect(hwnet, SIGNAL(paramChanged(const QString &, const QStringList &)), ui.pageNetGame->pGameCFG, SLOT(setParam(const QString &, const QStringList &)));
 	connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &)));
+	connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig()));
 
 
 	connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection);
--- a/QTfrontend/newnetclient.cpp	Sun Mar 08 20:22:52 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Mon Mar 09 10:54:44 2009 +0000
@@ -171,9 +171,8 @@
 
 void HWNewNet::OnDisconnect()
 {
-  //emit ChangeInTeams(QStringList());
-  if(m_game_connected) emit Disconnected();
-  m_game_connected = false;
+	if(m_game_connected) emit Disconnected();
+	m_game_connected = false;
 }
 
 void HWNewNet::displayError(QAbstractSocket::SocketError socketError)
@@ -359,7 +358,7 @@
 				emit EnteredGame();
 				emit roomMaster(isChief);
 				if (isChief)
-					ConfigAsked();
+					emit configAsked();
 			}
 			emit nickAdded(lst[i]);
 			emit chatStringFromNet(QString(tr("*** %1 joined")).arg(lst[i]));
@@ -526,32 +525,6 @@
 	qWarning() << "Net: Unknown message:" << lst;
 }
 
-
-void HWNewNet::ConfigAsked()
-{
-/*	QString map = m_pGameCFGWidget->getCurrentMap();
-	if (map.size())
-		onMapChanged(map);
-
-	onSuddenDeathTurnsChanged(m_pGameCFGWidget->getSuddenDeathTurns());
-	onCaseProbabilityChanged(m_pGameCFGWidget->getCaseProbability());
-	onSeedChanged(m_pGameCFGWidget->getCurrentSeed());
-	onThemeChanged(m_pGameCFGWidget->getCurrentTheme());
-	onInitHealthChanged(m_pGameCFGWidget->getInitHealth());
-	onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
-	onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1);
-	onTeamsDivideChanged(m_pGameCFGWidget->getGameFlags() & 0x10);
-	onSolidChanged(m_pGameCFGWidget->getGameFlags() & 0x04);
-	onBorderChanged(m_pGameCFGWidget->getGameFlags() & 0x08);
-	// always initialize with default ammo (also avoiding complicated cross-class dependencies)
-	QString name = m_pGameCFGWidget->WeaponsName->currentText();
-	QString ammo = m_pGameCFGWidget->WeaponsName->itemData(
-			m_pGameCFGWidget->WeaponsName->currentIndex()
-			).toString();
-	onWeaponsNameChanged(name, ammo);
-	onTemplateFilterChanged(m_pGameCFGWidget->pMapContainer->getTemplateFilter());*/
-}
-
 void HWNewNet::RunGame()
 {
 	emit AskForRunGame();
--- a/QTfrontend/newnetclient.h	Sun Mar 08 20:22:52 2009 +0000
+++ b/QTfrontend/newnetclient.h	Mon Mar 09 10:54:44 2009 +0000
@@ -56,7 +56,6 @@
   QString seed;
   bool m_game_connected;
 
-  void ConfigAsked();
   void RunGame();
 
   template <typename T>
@@ -103,7 +102,8 @@
   void roomMaster(bool);
 
   void paramChanged(const QString & param, const QStringList & value);
-  
+  void configAsked();
+
   void AddNetTeam(const HWTeam&);
   void hhnumChanged(const HWTeam&);
   void teamColorChanged(const HWTeam&);