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 |
32 extern "C" void GenLandPreview(int port); |
33 //NOTE: most likely subclassing QThread is wrong |
33 |
34 class EngineThread : public QThread |
34 |
35 { |
35 EngineInstance::EngineInstance(QObject *parent) |
36 protected: |
36 : QObject(parent) |
37 void run(); |
37 { |
38 }; |
38 port = 0; |
39 |
39 } |
40 void EngineThread::run() |
40 |
41 { |
41 EngineInstance::~EngineInstance() |
42 char *args[12]; |
42 { |
43 args[0] = "1"; //cShowFPS |
43 } |
44 args[1] = "65000"; //ipcPort |
44 |
45 args[2] = "1024"; //cScreenWidth |
45 void EngineInstance::start() |
46 args[3] = "768"; //cScreenHeight |
46 { |
47 args[4] = "0"; //cReducedQuality |
47 #if 0 |
48 args[5] = "en.txt"; //cLocaleFName |
48 char *args[11]; |
49 args[6] = "koda"; //UserNick |
49 args[0] = "65000"; //ipcPort |
50 args[7] = "1"; //SetSound |
50 args[1] = "1024"; //cScreenWidth |
51 args[8] = "1"; //SetMusic |
51 args[2] = "768"; //cScreenHeight |
52 args[9] = "0"; //cAltDamage |
52 args[3] = "0"; //cReducedQuality |
53 args[10]= "../Resources/hedgewars/Data"; //cPathPrefix |
53 args[4] = "en.txt"; //cLocaleFName |
54 args[11]= NULL; //recordFileName |
54 args[5] = "koda"; //UserNick |
|
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); |
56 } |
61 #endif |
|
62 GenLandPreview(port); |
|
63 } |
|
64 |
57 #endif |
65 #endif |
58 |
66 |
59 QList<TCPBase*> srvsList; |
67 QList<TCPBase*> srvsList; |
60 QPointer<QTcpServer> TCPBase::IPCServer(0); |
68 QPointer<QTcpServer> TCPBase::IPCServer(0); |
61 |
69 |
116 { |
122 { |
117 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
123 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
118 IPCSocket = 0; |
124 IPCSocket = 0; |
119 |
125 |
120 #ifdef HWLIBRARY |
126 #ifdef HWLIBRARY |
121 EngineThread engineThread;// = new EngineThread(this); |
127 QThread *thread = new QThread; |
122 engineThread.start(); |
128 EngineInstance *instance = new EngineInstance; |
|
129 instance->port = IPCServer->serverPort(); |
|
130 |
|
131 instance->moveToThread(thread); |
|
132 |
|
133 connect(thread, SIGNAL(started()), instance, SLOT(start(void))); |
|
134 connect(instance, SIGNAL(finished()), thread, SLOT(quit())); |
|
135 connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater())); |
|
136 connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater())); |
|
137 thread->start(); |
123 #else |
138 #else |
124 QProcess * process; |
139 QProcess * process; |
125 process = new QProcess(); |
140 process = new QProcess(); |
126 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
141 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
127 QStringList arguments=getArguments(); |
142 QStringList arguments=getArguments(); |