Start new hedgewars server instead of old one
authorunc0rr
Sat, 18 Oct 2008 13:43:30 +0000
changeset 1375 c95c6887b289
parent 1374 f33fa81e583d
child 1376 6c82ad758a80
Start new hedgewars server instead of old one
QTfrontend/game.h
QTfrontend/netserver.cpp
QTfrontend/netserver.h
--- a/QTfrontend/game.h	Sat Oct 18 13:37:03 2008 +0000
+++ b/QTfrontend/game.h	Sat Oct 18 13:43:30 2008 +0000
@@ -69,12 +69,12 @@
 	void FromNetChat(const QString & msg);
 
 private:
-    enum GameType {
-        gtLocal    = 1,
-        gtQLocal   = 2,
-        gtDemo     = 3,
-        gtNet      = 4,
-	gtTraining = 5
+	enum GameType {
+		gtLocal    = 1,
+		gtQLocal   = 2,
+		gtDemo     = 3,
+		gtNet      = 4,
+		gtTraining = 5
     };
 	char msgbuf[MAXMSGCHARS];
 	QString teams[5];
--- a/QTfrontend/netserver.cpp	Sat Oct 18 13:37:03 2008 +0000
+++ b/QTfrontend/netserver.cpp	Sat Oct 18 13:43:30 2008 +0000
@@ -18,17 +18,30 @@
  */
 
 #include <QMessageBox>
+
+#include "hwconsts.h"
 #include "netserver.h"
 
+HWNetServer::~HWNetServer()
+{
+	StopServer();
+}
+
 bool HWNetServer::StartServer(quint16 port)
 {
 	ds_port = port;
 
-	return true;
+	QStringList params;
+	params << QString("--port=%1").arg(port);
+	
+	process.start(bindir->absolutePath() + "/hedgewars-server", params);
+
+	return process.waitForStarted(5000);
 }
 
 void HWNetServer::StopServer()
 {
+	process.close();
 }
 
 
--- a/QTfrontend/netserver.h	Sat Oct 18 13:37:03 2008 +0000
+++ b/QTfrontend/netserver.h	Sat Oct 18 13:43:30 2008 +0000
@@ -20,12 +20,14 @@
 #define _NETSERVER_INCLUDED
 
 #include <QObject>
+#include <QProcess>
 
 class HWNetServer : public QObject
 {
 	Q_OBJECT
 
 public:
+	~HWNetServer();
 	bool StartServer(quint16 port);
 	void StopServer();
 	QString getRunningHostName() const;
@@ -33,6 +35,7 @@
 
 private:
 	quint16 ds_port;
+	QProcess process;
 };
 
 #endif // _NETSERVER_INCLUDED