lotsa hackery to get frontend somehow link libengine...
authorkoda
Wed, 21 Nov 2012 01:48:10 +0100
changeset 8082 675372256a01
parent 8081 5a7ff368cf01
child 8083 2edbd01a04a0
child 8084 e723e95c11f1
lotsa hackery to get frontend somehow link libengine...
CMakeLists.txt
QTfrontend/CMakeLists.txt
QTfrontend/net/tcpBase.cpp
hedgewars/CMakeLists.txt
--- a/CMakeLists.txt	Tue Nov 20 22:08:08 2012 +0100
+++ b/CMakeLists.txt	Wed Nov 21 01:48:10 2012 +0100
@@ -263,7 +263,7 @@
 endif()
 
 #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
-if(NOT (BUILD_ENGINE_LIBRARY OR ANDROID))
+if(NOT ANDROID)
     add_subdirectory(bin)
     add_subdirectory(QTfrontend)
     add_subdirectory(share)
--- a/QTfrontend/CMakeLists.txt	Tue Nov 20 22:08:08 2012 +0100
+++ b/QTfrontend/CMakeLists.txt	Wed Nov 21 01:48:10 2012 +0100
@@ -59,7 +59,6 @@
     endif()
 endif()
 
-
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
 
 file(GLOB NetCpp net/*.cpp)
@@ -158,6 +157,12 @@
     endif()
 endif()
 
+if(BUILD_ENGINE_LIBRARY)
+    add_definitions(-DHWLIBRARY)
+    set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS})
+    link_directories(${EXECUTABLE_OUTPUT_PATH})
+endif()
+
 
 add_executable(hedgewars WIN32
     ${hwfr_src}
--- a/QTfrontend/net/tcpBase.cpp	Tue Nov 20 22:08:08 2012 +0100
+++ b/QTfrontend/net/tcpBase.cpp	Wed Nov 21 01:48:10 2012 +0100
@@ -23,9 +23,39 @@
 #include <QList>
 #include <QApplication>
 #include <QImage>
+#include <QThread>
 
 #include "hwconsts.h"
 
+#ifdef HWLIBRARY
+extern "C" void Game(char**arguments);
+
+//NOTE: most likely subclassing QThread is wrong
+class EngineThread : public QThread
+{
+protected:
+    void run();
+};
+
+void EngineThread::run()
+{
+    char *args[12];
+    args[0] = "1";      //cShowFPS
+    args[1] = "65000";  //ipcPort
+    args[2] = "1024";   //cScreenWidth
+    args[3] = "768";    //cScreenHeight
+    args[4] = "0";      //cReducedQuality
+    args[5] = "en.txt"; //cLocaleFName
+    args[6] = "koda";   //UserNick
+    args[7] = "1";      //SetSound
+    args[8] = "1";      //SetMusic
+    args[9] = "0";      //cAltDamage
+    args[10]= "../Resources/hedgewars/Data";   //cPathPrefix
+    args[11]= NULL;     //recordFileName
+    Game(args);
+}
+#endif
+
 QList<TCPBase*> srvsList;
 QPointer<QTcpServer> TCPBase::IPCServer(0);
 
@@ -60,7 +90,11 @@
             exit(0); // FIXME - should be graceful exit here (lower Critical -> Warning above when implemented)
         }
     }
+#ifdef HWLIBRARY
+    ipc_port=65000; //HACK
+#else
     ipc_port=IPCServer->serverPort();
+#endif
 }
 
 void TCPBase::NewConnection()
@@ -83,6 +117,10 @@
     connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
     IPCSocket = 0;
 
+#ifdef HWLIBRARY
+    EngineThread engineThread;// = new EngineThread(this);
+    engineThread.start();
+#else
     QProcess * process;
     process = new QProcess();
     connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError)));
@@ -93,7 +131,7 @@
         process->setProcessChannelMode(QProcess::ForwardedChannels);
 
     process->start(bindir->absolutePath() + "/hwengine", arguments);
-
+#endif
     m_hasStarted = true;
 }
 
--- a/hedgewars/CMakeLists.txt	Tue Nov 20 22:08:08 2012 +0100
+++ b/hedgewars/CMakeLists.txt	Wed Nov 21 01:48:10 2012 +0100
@@ -95,8 +95,8 @@
         set(pascal_flags "-k-no_order_inits" ${pascal_flags})
     endif()
 
-    if (APPLE)
-        set(engine_output_name "hwengine.dylib")
+    if(APPLE)
+        set(engine_output_name "libhwengine.dylib")
     endif (APPLE)
 endif(BUILD_ENGINE_LIBRARY)
 
@@ -151,8 +151,9 @@
             set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
         endif()
 
-        set(pascal_flags "-k${SDLMAIN_LIB}" "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
+        set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags})
     endif()
+    set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
 endif(APPLE)