author | unc0rr |
Sat, 21 Jan 2006 16:18:19 +0000 | |
changeset 55 | e09f7c952a40 |
parent 52 | ae2950c5465c |
child 74 | 42257fee61ae |
permissions | -rw-r--r-- |
25 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*/ |
|
33 |
||
34 |
#include <QMessageBox> |
|
35 |
#include <QProcess> |
|
36 |
#include <QTimer> |
|
37 |
#include <QString> |
|
38 |
#include <QByteArray> |
|
39 |
#include <QTextStream> |
|
40 |
#include <QFile> |
|
41 |
#include "game.h" |
|
42 |
#include "hwconsts.h" |
|
43 |
||
26 | 44 |
HWGame::HWGame(int Resolution, bool Fullscreen) |
25 | 45 |
{ |
26 | 46 |
vid_Resolution = Resolution; |
47 |
vid_Fullscreen = Fullscreen; |
|
25 | 48 |
TeamCount = 0; |
26 | 49 |
seed = ""; |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
50 |
cfgdir.setPath(cfgdir.homePath()); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
51 |
cfgdir.cd(".hedgewars"); |
25 | 52 |
} |
53 |
||
54 |
void HWGame::NewConnection() |
|
55 |
{ |
|
41 | 56 |
QTcpSocket * client = IPCServer->nextPendingConnection(); |
25 | 57 |
if(!IPCSocket) |
58 |
{ |
|
41 | 59 |
IPCServer->close(); |
25 | 60 |
IPCSocket = client; |
61 |
connect(client, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); |
|
62 |
connect(client, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
63 |
if (toSendBuf.size() > 0) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
64 |
SENDIPC("?"); |
25 | 65 |
} else |
66 |
{ |
|
41 | 67 |
qWarning("2nd IPC client?!"); |
25 | 68 |
client->disconnectFromHost(); |
69 |
} |
|
70 |
} |
|
71 |
||
72 |
void HWGame::ClientDisconnect() |
|
73 |
{ |
|
41 | 74 |
SaveDemo("demo.hwd_1"); |
75 |
IPCSocket->deleteLater(); |
|
25 | 76 |
IPCSocket = 0; |
41 | 77 |
deleteLater(); |
25 | 78 |
} |
79 |
||
80 |
void HWGame::SendTeamConfig(int index) |
|
81 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
82 |
LocalCFG(teams[index]); |
25 | 83 |
} |
84 |
||
85 |
void HWGame::SendConfig() |
|
86 |
{ |
|
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
87 |
SendIPC(QString("eseed %1").arg(seed)); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
88 |
SendIPC(QString("etheme %1").arg(GetThemeBySeed())); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
89 |
//SENDIPC("emap test"); |
25 | 90 |
SENDIPC("TL"); |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
91 |
SENDIPC("e$gmflags 0"); |
25 | 92 |
SENDIPC("eaddteam"); |
93 |
SendTeamConfig(0); |
|
94 |
SENDIPC("ecolor 65535"); |
|
95 |
SENDIPC("eadd hh0 0"); |
|
96 |
SENDIPC("eadd hh1 0"); |
|
97 |
SENDIPC("eadd hh2 0"); |
|
98 |
SENDIPC("eadd hh3 0"); |
|
28 | 99 |
SENDIPC("eadd hh4 0"); |
25 | 100 |
SENDIPC("eaddteam"); |
101 |
SendTeamConfig(1); |
|
102 |
SENDIPC("ecolor 16776960"); |
|
103 |
SENDIPC("eadd hh0 1"); |
|
104 |
SENDIPC("eadd hh1 1"); |
|
105 |
SENDIPC("eadd hh2 1"); |
|
106 |
SENDIPC("eadd hh3 1"); |
|
28 | 107 |
SENDIPC("eadd hh4 1"); |
25 | 108 |
} |
109 |
||
43 | 110 |
void HWGame::ParseMessage(const QByteArray & msg) |
25 | 111 |
{ |
43 | 112 |
switch(msg.data()[1]) |
25 | 113 |
{ |
114 |
case '?': |
|
115 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
116 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
117 |
emit SendNet(QByteArray("\x01""?")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
118 |
else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
119 |
SENDIPC("!"); |
25 | 120 |
break; |
121 |
} |
|
122 |
case 'C': |
|
123 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
124 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
125 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
126 |
SENDIPC("TN"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
127 |
emit SendNet(QByteArray("\x01""C")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
128 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
129 |
else |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
130 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
131 |
if (gameType == gtLocal) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
132 |
SendConfig(); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
133 |
} |
25 | 134 |
break; |
135 |
} |
|
43 | 136 |
case 'E': |
137 |
{ |
|
138 |
QMessageBox::critical(0, |
|
139 |
"Hedgewars: error message", |
|
140 |
QString().append(msg.mid(2)).left(msg.size() - 6), |
|
141 |
QMessageBox::Ok, |
|
142 |
QMessageBox::NoButton, |
|
143 |
QMessageBox::NoButton); |
|
144 |
return; |
|
145 |
} |
|
25 | 146 |
case '+': |
147 |
{ |
|
36 | 148 |
if (gameType == gtNet) |
149 |
{ |
|
43 | 150 |
emit SendNet(msg); |
36 | 151 |
} |
25 | 152 |
break; |
153 |
} |
|
154 |
default: |
|
155 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
156 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
157 |
{ |
43 | 158 |
emit SendNet(msg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
159 |
} |
43 | 160 |
demo->append(msg); |
25 | 161 |
} |
162 |
} |
|
163 |
} |
|
164 |
||
165 |
void HWGame::SendIPC(const char * msg, quint8 len) |
|
166 |
{ |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
167 |
SendIPC(QByteArray::fromRawData(msg, len)); |
25 | 168 |
} |
169 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
170 |
void HWGame::SendIPC(const QString & buf) |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
171 |
{ |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
172 |
SendIPC(QByteArray().append(buf)); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
173 |
} |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
174 |
|
25 | 175 |
void HWGame::SendIPC(const QByteArray & buf) |
176 |
{ |
|
28 | 177 |
if (buf.size() > MAXMSGCHARS) return; |
40 | 178 |
quint8 len = buf.size(); |
179 |
RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); |
|
25 | 180 |
} |
181 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
182 |
void HWGame::RawSendIPC(const QByteArray & buf) |
26 | 183 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
184 |
if (!IPCSocket) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
185 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
186 |
toSendBuf += buf; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
187 |
} else |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
188 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
189 |
if (toSendBuf.size() > 0) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
190 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
191 |
IPCSocket->write(toSendBuf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
192 |
demo->append(toSendBuf); |
40 | 193 |
toSendBuf.clear(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
194 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
195 |
IPCSocket->write(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
196 |
demo->append(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
197 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
198 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
199 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
200 |
void HWGame::FromNet(const QByteArray & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
201 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
202 |
RawSendIPC(msg); |
26 | 203 |
} |
204 |
||
25 | 205 |
void HWGame::ClientRead() |
206 |
{ |
|
43 | 207 |
readbuffer.append(IPCSocket->readAll()); |
208 |
quint8 msglen; |
|
209 |
quint32 bufsize; |
|
210 |
while (((bufsize = readbuffer.size()) > 0) && |
|
211 |
((msglen = readbuffer.data()[0]) < bufsize)) |
|
25 | 212 |
{ |
43 | 213 |
QByteArray msg = readbuffer.left(msglen + 1); |
214 |
readbuffer.remove(0, msglen + 1); |
|
215 |
ParseMessage(msg); |
|
25 | 216 |
} |
217 |
} |
|
218 |
||
26 | 219 |
void HWGame::Start() |
25 | 220 |
{ |
41 | 221 |
IPCServer = new QTcpServer(this); |
222 |
connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
|
223 |
IPCServer->setMaxPendingConnections(1); |
|
224 |
IPCSocket = 0; |
|
225 |
if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) |
|
226 |
{ |
|
227 |
QMessageBox::critical(0, tr("Error"), |
|
228 |
tr("Unable to start the server: %1.") |
|
229 |
.arg(IPCServer->errorString())); |
|
230 |
} |
|
231 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
232 |
demo = new QByteArray; |
25 | 233 |
QProcess * process; |
234 |
QStringList arguments; |
|
235 |
process = new QProcess; |
|
26 | 236 |
arguments << resolutions[0][vid_Resolution]; |
237 |
arguments << resolutions[1][vid_Resolution]; |
|
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
238 |
arguments << "16"; |
25 | 239 |
arguments << "46631"; |
26 | 240 |
arguments << (vid_Fullscreen ? "1" : "0"); |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
241 |
arguments << "1"; |
52
ae2950c5465c
- Rename frontend to hedgewars and compile it to engine directory
unc0rr
parents:
43
diff
changeset
|
242 |
process->start("./hwengine", arguments); |
25 | 243 |
} |
244 |
||
245 |
void HWGame::AddTeam(const QString & teamname) |
|
246 |
{ |
|
247 |
if (TeamCount == 5) return; |
|
248 |
teams[TeamCount] = teamname; |
|
249 |
TeamCount++; |
|
250 |
} |
|
251 |
||
252 |
QString HWGame::GetThemeBySeed() |
|
253 |
{ |
|
26 | 254 |
QFile themesfile(QString(DATA_PATH) + "/Themes/themes.cfg"); |
25 | 255 |
QStringList themes; |
256 |
if (themesfile.open(QIODevice::ReadOnly)) |
|
257 |
{ |
|
258 |
QTextStream stream(&themesfile); |
|
259 |
QString str; |
|
260 |
while (!stream.atEnd()) |
|
261 |
{ |
|
262 |
themes << stream.readLine(); |
|
263 |
} |
|
264 |
themesfile.close(); |
|
265 |
} |
|
266 |
quint32 len = themes.size(); |
|
267 |
if (len == 0) |
|
268 |
{ |
|
28 | 269 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg or bad data", "OK"); |
25 | 270 |
return "avematan"; |
271 |
} |
|
272 |
if (seed.isEmpty()) |
|
273 |
{ |
|
28 | 274 |
QMessageBox::critical(0, "Error", "seed not defined", "OK"); |
25 | 275 |
return "avematan"; |
276 |
} |
|
277 |
quint32 k = 0; |
|
278 |
for (int i = 0; i < seed.length(); i++) |
|
279 |
{ |
|
41 | 280 |
k += seed[i].cell(); |
25 | 281 |
} |
282 |
return themes[k % len]; |
|
283 |
} |
|
284 |
||
285 |
void HWGame::SaveDemo(const QString & filename) |
|
286 |
{ |
|
287 |
QFile demofile(filename); |
|
288 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
289 |
{ |
|
28 | 290 |
QMessageBox::critical(0, |
25 | 291 |
tr("Error"), |
292 |
tr("Cannot save demo to file %s").arg(filename), |
|
293 |
tr("Quit")); |
|
294 |
return ; |
|
295 |
} |
|
296 |
QDataStream stream(&demofile); |
|
297 |
stream.writeRawData(demo->constData(), demo->size()); |
|
298 |
demofile.close(); |
|
26 | 299 |
delete demo; |
25 | 300 |
} |
26 | 301 |
|
302 |
void HWGame::PlayDemo(const QString & demofilename) |
|
303 |
{ |
|
304 |
gameType = gtDemo; |
|
305 |
QFile demofile(demofilename); |
|
306 |
if (!demofile.open(QIODevice::ReadOnly)) |
|
307 |
{ |
|
28 | 308 |
QMessageBox::critical(0, |
26 | 309 |
tr("Error"), |
310 |
tr("Cannot open demofile %s").arg(demofilename), |
|
311 |
tr("Quit")); |
|
312 |
return ; |
|
313 |
} |
|
314 |
||
315 |
// read demo |
|
316 |
QDataStream stream(&demofile); |
|
317 |
char buf[512]; |
|
318 |
quint32 readbytes; |
|
319 |
do |
|
320 |
{ |
|
321 |
readbytes = stream.readRawData((char *)&buf, 512); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
322 |
toSendBuf.append(QByteArray((char *)&buf, readbytes)); |
26 | 323 |
|
324 |
} while (readbytes > 0); |
|
325 |
demofile.close(); |
|
326 |
||
327 |
// run engine |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
328 |
Start(); |
26 | 329 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
330 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
331 |
void HWGame::StartNet(const QString & netseed) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
332 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
333 |
gameType = gtNet; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
334 |
seed = netseed; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
335 |
demo = new QByteArray; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
336 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
337 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
338 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
339 |
void HWGame::StartLocal() |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
340 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
341 |
gameType = gtLocal; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
342 |
if (TeamCount < 2) return; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
343 |
seedgen.GenRNDStr(seed, 10); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
344 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
345 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
346 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
347 |
void HWGame::LocalCFG(const QString & teamname) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
348 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
349 |
QFile teamcfg(cfgdir.absolutePath() + "/" + teamname + ".cfg"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
350 |
if (!teamcfg.open(QIODevice::ReadOnly)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
351 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
352 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
353 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
354 |
QTextStream stream(&teamcfg); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
355 |
stream.setCodec("UTF-8"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
356 |
QString str; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
357 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
358 |
while (!stream.atEnd()) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
359 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
360 |
str = stream.readLine(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
361 |
if (str.startsWith(";") || (str.length() > 254)) continue; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
362 |
str.prepend("e"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
363 |
SendIPC(str.toLocal8Bit()); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
364 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
365 |
teamcfg.close(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
366 |
} |