Game config commands are generated by GameCFGWidget
authorunc0rr
Thu, 11 Jan 2007 23:19:18 +0000
changeset 318 46a43b02bbb3
parent 317 e95340dbfc1d
child 319 7f3bd9e31f18
Game config commands are generated by GameCFGWidget
QTfrontend/game.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
--- a/QTfrontend/game.cpp	Thu Jan 11 22:04:08 2007 +0000
+++ b/QTfrontend/game.cpp	Thu Jan 11 23:19:18 2007 +0000
@@ -54,18 +54,10 @@
 
 void HWGame::commonConfig()
 {
-	SendIPC(QString("eseed %1").arg(seed).toAscii());
-	try {
-	  QString currentMap=gamecfg->getCurrentMap();
-	  SendIPC((QString("emap ")+currentMap).toAscii());
-	  SendIPC(QString("etheme %1").arg(gamecfg->getCurrentTheme()).toAscii());
-	}
-	catch(const MapFileErrorException& e) {
-	  SendIPC(QString("etheme %1").arg(config->GetRandomTheme()).toAscii());
-	}
-	SendIPC("TL");
-	SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii());
-	SendIPC(QString("e$turntime %1").arg(gamecfg->getTurnTime() * 1000).toAscii());
+	QByteArray buf;
+	HWProto::addStringListToBuffer(buf, gamecfg->getFullConfig());
+	HWProto::addStringToBuffer(buf, "TL");
+	RawSendIPC(buf);
 }
 
 void HWGame::SendConfig()
--- a/QTfrontend/gamecfgwidget.cpp	Thu Jan 11 22:04:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Thu Jan 11 23:19:18 2007 +0000
@@ -69,7 +69,7 @@
 	mainLayout.addWidget(new QWidget, 100);
 }
 
-quint32 GameCFGWidget::getGameFlags()
+quint32 GameCFGWidget::getGameFlags() const
 {
 	quint32 result = 0;
 	if (CB_mode_Forts->isChecked())
@@ -101,3 +101,20 @@
 {
 	return SB_TurnTime->value();
 }
+
+QStringList GameCFGWidget::getFullConfig() const
+{
+	QStringList sl;
+	sl.append("eseed " + getCurrentSeed());
+	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
+	sl.append(QString("e$turntime %1").arg(getTurnTime() * 1000));
+	try {
+		QString currentMap = getCurrentMap();
+		sl.append("emap " + currentMap);
+		sl.append("etheme " + getCurrentTheme());
+	}
+	catch(const MapFileErrorException& e) {
+		sl.append(QString("etheme %1").arg("steel"));
+	}
+	return sl;
+}
--- a/QTfrontend/gamecfgwidget.h	Thu Jan 11 22:04:08 2007 +0000
+++ b/QTfrontend/gamecfgwidget.h	Thu Jan 11 23:19:18 2007 +0000
@@ -20,6 +20,7 @@
 #define GAMECONFIGWIDGET_H
 
 #include <QWidget>
+#include <QStringList>
 
 #include "mapContainer.h"
 
@@ -33,13 +34,14 @@
 	Q_OBJECT
 
 public:
-	GameCFGWidget(QWidget* parent=0);
-	quint32 getGameFlags();
+	GameCFGWidget(QWidget* parent);
+	quint32 getGameFlags() const;
 	QString getCurrentSeed() const;
 	QString getCurrentMap() const;
 	QString getCurrentTheme() const;
 	quint32 getInitHealth() const;
 	quint32 getTurnTime() const;
+	QStringList getFullConfig() const;
 
 private slots: