author | unc0rr |
Wed, 27 Sep 2006 20:52:22 +0000 | |
changeset 175 | d226d976d836 |
parent 174 | 0b2c5b22f644 |
child 177 | c67c15e6fae3 |
permissions | -rw-r--r-- |
25 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
128 | 3 |
* Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
25 | 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> |
|
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
39 |
#include <QFile> |
25 | 40 |
#include <QTextStream> |
127 | 41 |
#include <QUuid> |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
42 |
|
25 | 43 |
#include "game.h" |
44 |
#include "hwconsts.h" |
|
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
45 |
#include "gameuiconfig.h" |
87 | 46 |
#include "gamecfgwidget.h" |
25 | 47 |
|
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
48 |
HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg) |
25 | 49 |
{ |
84 | 50 |
this->config = config; |
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
51 |
this->gamecfg = gamecfg; |
25 | 52 |
TeamCount = 0; |
26 | 53 |
seed = ""; |
25 | 54 |
} |
55 |
||
56 |
void HWGame::NewConnection() |
|
57 |
{ |
|
41 | 58 |
QTcpSocket * client = IPCServer->nextPendingConnection(); |
25 | 59 |
if(!IPCSocket) |
60 |
{ |
|
41 | 61 |
IPCServer->close(); |
25 | 62 |
IPCSocket = client; |
63 |
connect(client, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); |
|
64 |
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
|
65 |
if (toSendBuf.size() > 0) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
66 |
SENDIPC("?"); |
25 | 67 |
} else |
68 |
{ |
|
41 | 69 |
qWarning("2nd IPC client?!"); |
25 | 70 |
client->disconnectFromHost(); |
71 |
} |
|
72 |
} |
|
73 |
||
74 |
void HWGame::ClientDisconnect() |
|
75 |
{ |
|
157 | 76 |
SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_1"); |
41 | 77 |
IPCSocket->deleteLater(); |
25 | 78 |
IPCSocket = 0; |
41 | 79 |
deleteLater(); |
25 | 80 |
} |
81 |
||
82 |
void HWGame::SendTeamConfig(int index) |
|
83 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
84 |
LocalCFG(teams[index]); |
25 | 85 |
} |
86 |
||
87 |
void HWGame::SendConfig() |
|
88 |
{ |
|
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
89 |
SendIPC(QString("eseed %1").arg(seed)); |
127 | 90 |
SendIPC(QString("etheme %1").arg(config->GetRandomTheme())); |
25 | 91 |
SENDIPC("TL"); |
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
92 |
SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags())); |
141 | 93 |
|
94 |
for (int i = 0; i < TeamCount; i++) |
|
95 |
{ |
|
96 |
SENDIPC("eaddteam"); |
|
97 |
LocalCFG(teams[i]); |
|
98 |
SendIPC(QString("ecolor %1").arg(65535 << i * 8)); |
|
99 |
for (int t = 0; t < hdNum[teams[i]]; t++) |
|
149 | 100 |
SendIPC(QString("eadd hh%1 0").arg(t)); |
141 | 101 |
} |
102 |
} |
|
103 |
||
104 |
void HWGame::SendQuickConfig() |
|
105 |
{ |
|
106 |
SendIPC(QString("eseed %1").arg(seed)); |
|
107 |
SendIPC(QString("etheme %1").arg(config->GetRandomTheme())); |
|
108 |
SENDIPC("TL"); |
|
109 |
SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags())); |
|
25 | 110 |
SENDIPC("eaddteam"); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
111 |
LocalCFG(0); |
25 | 112 |
SENDIPC("ecolor 65535"); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
113 |
SENDIPC("eadd hh0 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
114 |
SENDIPC("eadd hh1 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
115 |
SENDIPC("eadd hh2 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
116 |
SENDIPC("eadd hh3 0"); |
25 | 117 |
SENDIPC("eaddteam"); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
118 |
LocalCFG(2); |
25 | 119 |
SENDIPC("ecolor 16776960"); |
120 |
SENDIPC("eadd hh0 1"); |
|
121 |
SENDIPC("eadd hh1 1"); |
|
122 |
SENDIPC("eadd hh2 1"); |
|
123 |
SENDIPC("eadd hh3 1"); |
|
124 |
} |
|
125 |
||
43 | 126 |
void HWGame::ParseMessage(const QByteArray & msg) |
25 | 127 |
{ |
141 | 128 |
switch(msg.data()[1]) { |
129 |
case '?': { |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
130 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
131 |
emit SendNet(QByteArray("\x01""?")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
132 |
else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
133 |
SENDIPC("!"); |
25 | 134 |
break; |
135 |
} |
|
141 | 136 |
case 'C': { |
137 |
switch (gameType) { |
|
142 | 138 |
case gtLocal: { |
139 |
SendConfig(); |
|
140 |
break; |
|
141 |
} |
|
141 | 142 |
case gtQLocal: { |
142 | 143 |
SendQuickConfig(); |
141 | 144 |
break; |
145 |
} |
|
146 |
case gtDemo: break; |
|
147 |
case gtNet: { |
|
148 |
SENDIPC("TN"); |
|
149 |
emit SendNet(QByteArray("\x01""C")); |
|
150 |
break; |
|
151 |
} |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
152 |
} |
25 | 153 |
break; |
154 |
} |
|
141 | 155 |
case 'E': { |
43 | 156 |
QMessageBox::critical(0, |
157 |
"Hedgewars: error message", |
|
158 |
QString().append(msg.mid(2)).left(msg.size() - 6), |
|
159 |
QMessageBox::Ok, |
|
160 |
QMessageBox::NoButton, |
|
161 |
QMessageBox::NoButton); |
|
162 |
return; |
|
163 |
} |
|
141 | 164 |
case '+': { |
36 | 165 |
if (gameType == gtNet) |
166 |
{ |
|
43 | 167 |
emit SendNet(msg); |
36 | 168 |
} |
25 | 169 |
break; |
170 |
} |
|
141 | 171 |
default: { |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
172 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
173 |
{ |
43 | 174 |
emit SendNet(msg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
175 |
} |
43 | 176 |
demo->append(msg); |
25 | 177 |
} |
178 |
} |
|
179 |
} |
|
180 |
||
181 |
void HWGame::SendIPC(const char * msg, quint8 len) |
|
182 |
{ |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
183 |
SendIPC(QByteArray::fromRawData(msg, len)); |
25 | 184 |
} |
185 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
186 |
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
|
187 |
{ |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
188 |
SendIPC(QByteArray().append(buf)); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
189 |
} |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
190 |
|
25 | 191 |
void HWGame::SendIPC(const QByteArray & buf) |
192 |
{ |
|
28 | 193 |
if (buf.size() > MAXMSGCHARS) return; |
40 | 194 |
quint8 len = buf.size(); |
195 |
RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); |
|
25 | 196 |
} |
197 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
198 |
void HWGame::RawSendIPC(const QByteArray & buf) |
26 | 199 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
200 |
if (!IPCSocket) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
201 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
202 |
toSendBuf += buf; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
203 |
} else |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
204 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
205 |
if (toSendBuf.size() > 0) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
206 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
207 |
IPCSocket->write(toSendBuf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
208 |
demo->append(toSendBuf); |
40 | 209 |
toSendBuf.clear(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
210 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
211 |
IPCSocket->write(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
212 |
demo->append(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
213 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
214 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
215 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
216 |
void HWGame::FromNet(const QByteArray & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
217 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
218 |
RawSendIPC(msg); |
26 | 219 |
} |
220 |
||
25 | 221 |
void HWGame::ClientRead() |
222 |
{ |
|
43 | 223 |
readbuffer.append(IPCSocket->readAll()); |
224 |
quint8 msglen; |
|
225 |
quint32 bufsize; |
|
226 |
while (((bufsize = readbuffer.size()) > 0) && |
|
227 |
((msglen = readbuffer.data()[0]) < bufsize)) |
|
25 | 228 |
{ |
43 | 229 |
QByteArray msg = readbuffer.left(msglen + 1); |
230 |
readbuffer.remove(0, msglen + 1); |
|
231 |
ParseMessage(msg); |
|
25 | 232 |
} |
233 |
} |
|
234 |
||
26 | 235 |
void HWGame::Start() |
25 | 236 |
{ |
41 | 237 |
IPCServer = new QTcpServer(this); |
238 |
connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
|
239 |
IPCServer->setMaxPendingConnections(1); |
|
240 |
IPCSocket = 0; |
|
241 |
if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) |
|
242 |
{ |
|
243 |
QMessageBox::critical(0, tr("Error"), |
|
244 |
tr("Unable to start the server: %1.") |
|
245 |
.arg(IPCServer->errorString())); |
|
246 |
} |
|
247 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
248 |
demo = new QByteArray; |
25 | 249 |
QProcess * process; |
250 |
QStringList arguments; |
|
251 |
process = new QProcess; |
|
110 | 252 |
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
84 | 253 |
arguments << resolutions[0][config->vid_Resolution()]; |
254 |
arguments << resolutions[1][config->vid_Resolution()]; |
|
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
255 |
arguments << "16"; |
25 | 256 |
arguments << "46631"; |
84 | 257 |
arguments << (config->vid_Fullscreen() ? "1" : "0"); |
258 |
arguments << (config->isSoundEnabled() ? "1" : "0"); |
|
80 | 259 |
arguments << tr("en.txt"); |
174 | 260 |
arguments << "128"; |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
261 |
process->start(bindir->absolutePath() + "/hwengine", arguments); |
25 | 262 |
} |
263 |
||
110 | 264 |
void HWGame::StartProcessError(QProcess::ProcessError error) |
265 |
{ |
|
266 |
QMessageBox::critical(0, tr("Error"), |
|
267 |
tr("Unable to run engine: %1 (") |
|
268 |
.arg(error) + bindir->absolutePath() + "/hwengine)"); |
|
269 |
} |
|
270 |
||
140
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
128
diff
changeset
|
271 |
void HWGame::AddTeam(const QString & teamname, unsigned char numHedgedogs) |
25 | 272 |
{ |
273 |
if (TeamCount == 5) return; |
|
274 |
teams[TeamCount] = teamname; |
|
275 |
TeamCount++; |
|
140
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
128
diff
changeset
|
276 |
hdNum[teamname]=numHedgedogs; |
25 | 277 |
} |
278 |
||
279 |
void HWGame::SaveDemo(const QString & filename) |
|
280 |
{ |
|
157 | 281 |
demo->replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
282 |
demo->replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
|
283 |
||
25 | 284 |
QFile demofile(filename); |
285 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
286 |
{ |
|
28 | 287 |
QMessageBox::critical(0, |
25 | 288 |
tr("Error"), |
80 | 289 |
tr("Cannot save demo to file %1").arg(filename), |
25 | 290 |
tr("Quit")); |
291 |
return ; |
|
292 |
} |
|
293 |
QDataStream stream(&demofile); |
|
294 |
stream.writeRawData(demo->constData(), demo->size()); |
|
295 |
demofile.close(); |
|
26 | 296 |
delete demo; |
25 | 297 |
} |
26 | 298 |
|
299 |
void HWGame::PlayDemo(const QString & demofilename) |
|
300 |
{ |
|
301 |
gameType = gtDemo; |
|
302 |
QFile demofile(demofilename); |
|
303 |
if (!demofile.open(QIODevice::ReadOnly)) |
|
304 |
{ |
|
28 | 305 |
QMessageBox::critical(0, |
26 | 306 |
tr("Error"), |
80 | 307 |
tr("Cannot open demofile %1").arg(demofilename), |
26 | 308 |
tr("Quit")); |
309 |
return ; |
|
310 |
} |
|
311 |
||
312 |
// read demo |
|
313 |
QDataStream stream(&demofile); |
|
314 |
char buf[512]; |
|
142 | 315 |
int readbytes; |
26 | 316 |
do |
317 |
{ |
|
318 |
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
|
319 |
toSendBuf.append(QByteArray((char *)&buf, readbytes)); |
26 | 320 |
|
321 |
} while (readbytes > 0); |
|
322 |
demofile.close(); |
|
323 |
||
324 |
// run engine |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
325 |
Start(); |
26 | 326 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
327 |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
328 |
void HWGame::StartNet() |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
329 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
330 |
gameType = gtNet; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
331 |
demo = new QByteArray; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
332 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
333 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
334 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
335 |
void HWGame::StartLocal() |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
336 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
337 |
gameType = gtLocal; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
338 |
if (TeamCount < 2) return; |
172 | 339 |
seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
340 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
341 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
342 |
|
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
343 |
void HWGame::StartQuick() |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
344 |
{ |
141 | 345 |
gameType = gtQLocal; |
172 | 346 |
seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
347 |
Start(); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
348 |
} |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
349 |
|
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
350 |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
351 |
void HWGame::LocalCFG(const QString & teamname) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
352 |
{ |
116 | 353 |
HWTeam team(teamname); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
354 |
if (!team.LoadFromFile()) { |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
355 |
QMessageBox::critical(0, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
356 |
"Error", |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
357 |
QString("Cannot load team config ""%1""").arg(teamname), |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
358 |
QMessageBox::Ok, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
359 |
QMessageBox::NoButton, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
360 |
QMessageBox::NoButton); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
361 |
return; |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
362 |
} |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
363 |
RawSendIPC(team.IPCTeamInfo()); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
364 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
365 |
|
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
366 |
void HWGame::LocalCFG(quint8 num) |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
367 |
{ |
116 | 368 |
HWTeam team(num); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
369 |
RawSendIPC(team.IPCTeamInfo()); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
370 |
} |