QTfrontend/net/tcpBase.cpp
branchflibqtfrontend
changeset 8363 0b4ac686fc44
parent 8092 08960209db8c
parent 8310 a98c349bc06b
equal deleted inserted replaced
8306:50fe80adbfcb 8363:0b4ac686fc44
    27 
    27 
    28 #include "hwconsts.h"
    28 #include "hwconsts.h"
    29 
    29 
    30 #ifdef HWLIBRARY
    30 #ifdef HWLIBRARY
    31 extern "C" void Game(char**arguments);
    31 extern "C" void Game(char**arguments);
       
    32 extern "C" void GenLandPreview(int port);
    32 
    33 
    33 //NOTE: most likely subclassing QThread is wrong
    34 
    34 class EngineThread : public QThread
    35 EngineInstance::EngineInstance(QObject *parent)
       
    36     : QObject(parent)
    35 {
    37 {
    36 protected:
    38     port = 0;
    37     void run();
    39 }
    38 };
       
    39 
    40 
    40 void EngineThread::run()
    41 EngineInstance::~EngineInstance()
    41 {
    42 {
    42     char *args[12];
    43 }
    43     args[0] = "1";      //cShowFPS
    44 
    44     args[1] = "65000";  //ipcPort
    45 void EngineInstance::start()
    45     args[2] = "1024";   //cScreenWidth
    46 {
    46     args[3] = "768";    //cScreenHeight
    47 #if 0
    47     args[4] = "0";      //cReducedQuality
    48     char *args[11];
    48     args[5] = "en.txt"; //cLocaleFName
    49     args[0] = "65000";  //ipcPort
    49     args[6] = "koda";   //UserNick
    50     args[1] = "1024";   //cScreenWidth
    50     args[7] = "1";      //SetSound
    51     args[2] = "768";    //cScreenHeight
    51     args[8] = "1";      //SetMusic
    52     args[3] = "0";      //cReducedQuality
    52     args[9] = "0";      //cAltDamage
    53     args[4] = "en.txt"; //cLocaleFName
    53     args[10]= "../Resources/hedgewars/Data";   //cPathPrefix
    54     args[5] = "koda";   //UserNick
    54     args[11]= NULL;     //recordFileName
    55     args[6] = "1";      //SetSound
       
    56     args[7] = "1";      //SetMusic
       
    57     args[8] = "0";      //cAltDamage
       
    58     args[9]= datadir->absolutePath().toAscii().data(); //cPathPrefix
       
    59     args[10]= NULL;     //recordFileName
    55     Game(args);
    60     Game(args);
       
    61 #endif
       
    62     GenLandPreview(port);
    56 }
    63 }
       
    64 
    57 #endif
    65 #endif
    58 
    66 
    59 QList<TCPBase*> srvsList;
    67 QList<TCPBase*> srvsList;
    60 
    68 
    61 TCPBase::~TCPBase()
    69 TCPBase::~TCPBase()
    74 void TCPBase::RealStart()
    82 void TCPBase::RealStart()
    75 {
    83 {
    76     onEngineStart();
    84     onEngineStart();
    77 
    85 
    78 #ifdef HWLIBRARY
    86 #ifdef HWLIBRARY
    79     EngineThread engineThread;// = new EngineThread(this);
    87     QThread *thread = new QThread;
    80     engineThread.start();
    88     EngineInstance *instance = new EngineInstance;
       
    89     instance->port = IPCServer->serverPort();
       
    90 
       
    91     instance->moveToThread(thread);
       
    92 
       
    93     connect(thread, SIGNAL(started()), instance, SLOT(start(void)));
       
    94     connect(instance, SIGNAL(finished()), thread, SLOT(quit()));
       
    95     connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater()));
       
    96     connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater()));
       
    97     thread->start();
    81 #else
    98 #else
    82     QProcess * process;
    99     QProcess * process;
    83 
   100 
    84     process = new QProcess();
   101     process = new QProcess();
    85     QStringList arguments = getArguments();
   102     QStringList arguments = getArguments();