Some further work on map optimizer
authorunc0rr
Thu, 05 Jun 2014 23:42:46 +0400
changeset 10256 b07288b729c4
parent 10255 fdc342ebdc31
child 10257 649f1231cd70
Some further work on map optimizer
QTfrontend/net/hwmapoptimizer.cpp
QTfrontend/net/hwmapoptimizer.h
project_files/hedgewars.pro
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/hwmapoptimizer.cpp	Thu Jun 05 23:42:46 2014 +0400
@@ -0,0 +1,54 @@
+#include "hwmapoptimizer.h"
+#include "hwconsts.h"
+
+HWMapOptimizer::HWMapOptimizer(QObject *parent) :
+    TCPBase(parent)
+{
+}
+
+bool HWMapOptimizer::couldBeRemoved()
+{
+    return !m_hasStarted;
+}
+
+void HWMapOptimizer::optimizeMap(const Paths &paths)
+{
+    m_paths = paths;
+
+    Start(true);
+}
+
+QStringList HWMapOptimizer::getArguments()
+{
+    QStringList arguments;
+    arguments << "--internal";
+    arguments << "--port";
+    arguments << QString("%1").arg(ipc_port);
+    arguments << "--user-prefix";
+    arguments << cfgdir->absolutePath();
+    arguments << "--prefix";
+    arguments << datadir->absolutePath();
+    arguments << "--landpreview";
+    return arguments;
+}
+
+void HWMapOptimizer::onClientDisconnect()
+{
+
+}
+
+void HWMapOptimizer::SendToClientFirst()
+{
+    SendIPC("e$mapgen 4");
+
+    /*QByteArray data = m_drawMapData;
+    while(data.size() > 0)
+    {
+        QByteArray tmp = data;
+        tmp.truncate(200);
+        SendIPC("edraw " + tmp);
+        data.remove(0, 200);
+    }
+
+    SendIPC("!");*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/hwmapoptimizer.h	Thu Jun 05 23:42:46 2014 +0400
@@ -0,0 +1,30 @@
+#ifndef HWMAPOPTIMIZER_H
+#define HWMAPOPTIMIZER_H
+
+#include "tcpBase.h"
+#include "drawmapscene.h"
+
+class HWMapOptimizer : public TCPBase
+{
+    Q_OBJECT
+public:
+    explicit HWMapOptimizer(QObject *parent = 0);
+
+    void optimizeMap(const Paths & paths);
+    bool couldBeRemoved();
+    
+signals:    
+    void optimizedMap(const Paths & paths);
+    
+public slots:
+
+protected:
+    QStringList getArguments();
+    void onClientDisconnect();
+    void SendToClientFirst();
+
+private:
+    Paths m_paths;
+};
+
+#endif // HWMAPOPTIMIZER_H
--- a/project_files/hedgewars.pro	Wed Jun 04 19:39:54 2014 +0200
+++ b/project_files/hedgewars.pro	Thu Jun 05 23:42:46 2014 +0400
@@ -116,7 +116,8 @@
     ../QTfrontend/ui/widget/lineeditcursor.h \
     ../QTfrontend/servermessages.h \
     ../QTfrontend/ui/widget/roomnameprompt.h \
-    ../QTfrontend/weapons.h
+    ../QTfrontend/weapons.h \
+    ../QTfrontend/net/hwmapoptimizer.h
 
 
 SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
@@ -214,7 +215,8 @@
     ../QTfrontend/util/MessageDialog.cpp \
     ../QTfrontend/ui/widget/feedbackdialog.cpp \
     ../QTfrontend/ui/widget/lineeditcursor.cpp \
-    ../QTfrontend/ui/widget/roomnameprompt.cpp
+    ../QTfrontend/ui/widget/roomnameprompt.cpp \
+    ../QTfrontend/net/hwmapoptimizer.cpp
 
 
 TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \