21 |
21 |
22 #include <QMessageBox> |
22 #include <QMessageBox> |
23 #include <QList> |
23 #include <QList> |
24 #include <QApplication> |
24 #include <QApplication> |
25 #include <QImage> |
25 #include <QImage> |
|
26 #include <QThread> |
26 |
27 |
27 #include "hwconsts.h" |
28 #include "hwconsts.h" |
|
29 |
|
30 #ifdef HWLIBRARY |
|
31 extern "C" void Game(char**arguments); |
|
32 |
|
33 //NOTE: most likely subclassing QThread is wrong |
|
34 class EngineThread : public QThread |
|
35 { |
|
36 protected: |
|
37 void run(); |
|
38 }; |
|
39 |
|
40 void EngineThread::run() |
|
41 { |
|
42 char *args[12]; |
|
43 args[0] = "1"; //cShowFPS |
|
44 args[1] = "65000"; //ipcPort |
|
45 args[2] = "1024"; //cScreenWidth |
|
46 args[3] = "768"; //cScreenHeight |
|
47 args[4] = "0"; //cReducedQuality |
|
48 args[5] = "en.txt"; //cLocaleFName |
|
49 args[6] = "koda"; //UserNick |
|
50 args[7] = "1"; //SetSound |
|
51 args[8] = "1"; //SetMusic |
|
52 args[9] = "0"; //cAltDamage |
|
53 args[10]= "../Resources/hedgewars/Data"; //cPathPrefix |
|
54 args[11]= NULL; //recordFileName |
|
55 Game(args); |
|
56 } |
|
57 #endif |
28 |
58 |
29 QList<TCPBase*> srvsList; |
59 QList<TCPBase*> srvsList; |
30 QPointer<QTcpServer> TCPBase::IPCServer(0); |
60 QPointer<QTcpServer> TCPBase::IPCServer(0); |
31 |
61 |
32 TCPBase::~TCPBase() |
62 TCPBase::~TCPBase() |
81 void TCPBase::RealStart() |
115 void TCPBase::RealStart() |
82 { |
116 { |
83 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
117 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
84 IPCSocket = 0; |
118 IPCSocket = 0; |
85 |
119 |
|
120 #ifdef HWLIBRARY |
|
121 EngineThread engineThread;// = new EngineThread(this); |
|
122 engineThread.start(); |
|
123 #else |
86 QProcess * process; |
124 QProcess * process; |
87 process = new QProcess(); |
125 process = new QProcess(); |
88 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
126 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
89 QStringList arguments=getArguments(); |
127 QStringList arguments=getArguments(); |
90 |
128 |
91 // redirect everything written on stdout/stderr |
129 // redirect everything written on stdout/stderr |
92 if(isDevBuild) |
130 if(isDevBuild) |
93 process->setProcessChannelMode(QProcess::ForwardedChannels); |
131 process->setProcessChannelMode(QProcess::ForwardedChannels); |
94 |
132 |
95 process->start(bindir->absolutePath() + "/hwengine", arguments); |
133 process->start(bindir->absolutePath() + "/hwengine", arguments); |
96 |
134 #endif |
97 m_hasStarted = true; |
135 m_hasStarted = true; |
98 } |
136 } |
99 |
137 |
100 void TCPBase::ClientDisconnect() |
138 void TCPBase::ClientDisconnect() |
101 { |
139 { |