author | unc0rr |
Sun, 03 Sep 2006 13:54:45 +0000 | |
changeset 133 | c79cb5e5b24a |
parent 128 | 223522298250 |
child 140 | 50ccde437ea1 |
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 |
{ |
|
41 | 76 |
SaveDemo("demo.hwd_1"); |
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())); |
25 | 93 |
SENDIPC("eaddteam"); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
94 |
LocalCFG(0); |
25 | 95 |
SENDIPC("ecolor 65535"); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
96 |
SENDIPC("eadd hh0 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
97 |
SENDIPC("eadd hh1 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
98 |
SENDIPC("eadd hh2 0"); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
99 |
SENDIPC("eadd hh3 0"); |
25 | 100 |
SENDIPC("eaddteam"); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
101 |
LocalCFG(2); |
25 | 102 |
SENDIPC("ecolor 16776960"); |
103 |
SENDIPC("eadd hh0 1"); |
|
104 |
SENDIPC("eadd hh1 1"); |
|
105 |
SENDIPC("eadd hh2 1"); |
|
106 |
SENDIPC("eadd hh3 1"); |
|
107 |
} |
|
108 |
||
43 | 109 |
void HWGame::ParseMessage(const QByteArray & msg) |
25 | 110 |
{ |
43 | 111 |
switch(msg.data()[1]) |
25 | 112 |
{ |
113 |
case '?': |
|
114 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
115 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
116 |
emit SendNet(QByteArray("\x01""?")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
117 |
else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
118 |
SENDIPC("!"); |
25 | 119 |
break; |
120 |
} |
|
121 |
case 'C': |
|
122 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
123 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
124 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
125 |
SENDIPC("TN"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
126 |
emit SendNet(QByteArray("\x01""C")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
127 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
128 |
else |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
129 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
130 |
if (gameType == gtLocal) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
131 |
SendConfig(); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
132 |
} |
25 | 133 |
break; |
134 |
} |
|
43 | 135 |
case 'E': |
136 |
{ |
|
137 |
QMessageBox::critical(0, |
|
138 |
"Hedgewars: error message", |
|
139 |
QString().append(msg.mid(2)).left(msg.size() - 6), |
|
140 |
QMessageBox::Ok, |
|
141 |
QMessageBox::NoButton, |
|
142 |
QMessageBox::NoButton); |
|
143 |
return; |
|
144 |
} |
|
25 | 145 |
case '+': |
146 |
{ |
|
36 | 147 |
if (gameType == gtNet) |
148 |
{ |
|
43 | 149 |
emit SendNet(msg); |
36 | 150 |
} |
25 | 151 |
break; |
152 |
} |
|
153 |
default: |
|
154 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
155 |
if (gameType == gtNet) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
156 |
{ |
43 | 157 |
emit SendNet(msg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
158 |
} |
43 | 159 |
demo->append(msg); |
25 | 160 |
} |
161 |
} |
|
162 |
} |
|
163 |
||
164 |
void HWGame::SendIPC(const char * msg, quint8 len) |
|
165 |
{ |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
166 |
SendIPC(QByteArray::fromRawData(msg, len)); |
25 | 167 |
} |
168 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
169 |
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
|
170 |
{ |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
171 |
SendIPC(QByteArray().append(buf)); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
172 |
} |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
173 |
|
25 | 174 |
void HWGame::SendIPC(const QByteArray & buf) |
175 |
{ |
|
28 | 176 |
if (buf.size() > MAXMSGCHARS) return; |
40 | 177 |
quint8 len = buf.size(); |
178 |
RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); |
|
25 | 179 |
} |
180 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
181 |
void HWGame::RawSendIPC(const QByteArray & buf) |
26 | 182 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
183 |
if (!IPCSocket) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
184 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
185 |
toSendBuf += buf; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
186 |
} else |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
187 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
188 |
if (toSendBuf.size() > 0) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
189 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
190 |
IPCSocket->write(toSendBuf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
191 |
demo->append(toSendBuf); |
40 | 192 |
toSendBuf.clear(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
193 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
194 |
IPCSocket->write(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
195 |
demo->append(buf); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
196 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
197 |
} |
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 |
void HWGame::FromNet(const QByteArray & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
200 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
201 |
RawSendIPC(msg); |
26 | 202 |
} |
203 |
||
25 | 204 |
void HWGame::ClientRead() |
205 |
{ |
|
43 | 206 |
readbuffer.append(IPCSocket->readAll()); |
207 |
quint8 msglen; |
|
208 |
quint32 bufsize; |
|
209 |
while (((bufsize = readbuffer.size()) > 0) && |
|
210 |
((msglen = readbuffer.data()[0]) < bufsize)) |
|
25 | 211 |
{ |
43 | 212 |
QByteArray msg = readbuffer.left(msglen + 1); |
213 |
readbuffer.remove(0, msglen + 1); |
|
214 |
ParseMessage(msg); |
|
25 | 215 |
} |
216 |
} |
|
217 |
||
26 | 218 |
void HWGame::Start() |
25 | 219 |
{ |
41 | 220 |
IPCServer = new QTcpServer(this); |
221 |
connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
|
222 |
IPCServer->setMaxPendingConnections(1); |
|
223 |
IPCSocket = 0; |
|
224 |
if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) |
|
225 |
{ |
|
226 |
QMessageBox::critical(0, tr("Error"), |
|
227 |
tr("Unable to start the server: %1.") |
|
228 |
.arg(IPCServer->errorString())); |
|
229 |
} |
|
230 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
52
diff
changeset
|
231 |
demo = new QByteArray; |
25 | 232 |
QProcess * process; |
233 |
QStringList arguments; |
|
234 |
process = new QProcess; |
|
110 | 235 |
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
84 | 236 |
arguments << resolutions[0][config->vid_Resolution()]; |
237 |
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
|
238 |
arguments << "16"; |
25 | 239 |
arguments << "46631"; |
84 | 240 |
arguments << (config->vid_Fullscreen() ? "1" : "0"); |
241 |
arguments << (config->isSoundEnabled() ? "1" : "0"); |
|
80 | 242 |
arguments << tr("en.txt"); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
243 |
process->start(bindir->absolutePath() + "/hwengine", arguments); |
25 | 244 |
} |
245 |
||
110 | 246 |
void HWGame::StartProcessError(QProcess::ProcessError error) |
247 |
{ |
|
248 |
QMessageBox::critical(0, tr("Error"), |
|
249 |
tr("Unable to run engine: %1 (") |
|
250 |
.arg(error) + bindir->absolutePath() + "/hwengine)"); |
|
251 |
} |
|
252 |
||
25 | 253 |
void HWGame::AddTeam(const QString & teamname) |
254 |
{ |
|
255 |
if (TeamCount == 5) return; |
|
256 |
teams[TeamCount] = teamname; |
|
257 |
TeamCount++; |
|
258 |
} |
|
259 |
||
260 |
void HWGame::SaveDemo(const QString & filename) |
|
261 |
{ |
|
262 |
QFile demofile(filename); |
|
263 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
264 |
{ |
|
28 | 265 |
QMessageBox::critical(0, |
25 | 266 |
tr("Error"), |
80 | 267 |
tr("Cannot save demo to file %1").arg(filename), |
25 | 268 |
tr("Quit")); |
269 |
return ; |
|
270 |
} |
|
271 |
QDataStream stream(&demofile); |
|
272 |
stream.writeRawData(demo->constData(), demo->size()); |
|
273 |
demofile.close(); |
|
26 | 274 |
delete demo; |
25 | 275 |
} |
26 | 276 |
|
277 |
void HWGame::PlayDemo(const QString & demofilename) |
|
278 |
{ |
|
279 |
gameType = gtDemo; |
|
280 |
QFile demofile(demofilename); |
|
281 |
if (!demofile.open(QIODevice::ReadOnly)) |
|
282 |
{ |
|
28 | 283 |
QMessageBox::critical(0, |
26 | 284 |
tr("Error"), |
80 | 285 |
tr("Cannot open demofile %1").arg(demofilename), |
26 | 286 |
tr("Quit")); |
287 |
return ; |
|
288 |
} |
|
289 |
||
290 |
// read demo |
|
291 |
QDataStream stream(&demofile); |
|
292 |
char buf[512]; |
|
293 |
quint32 readbytes; |
|
294 |
do |
|
295 |
{ |
|
296 |
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
|
297 |
toSendBuf.append(QByteArray((char *)&buf, readbytes)); |
26 | 298 |
|
299 |
} while (readbytes > 0); |
|
300 |
demofile.close(); |
|
301 |
||
302 |
// run engine |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
303 |
Start(); |
26 | 304 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
305 |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
87
diff
changeset
|
306 |
void HWGame::StartNet() |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
307 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
308 |
gameType = gtNet; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
309 |
demo = new QByteArray; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
310 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
311 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
312 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
313 |
void HWGame::StartLocal() |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
314 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
315 |
gameType = gtLocal; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
316 |
if (TeamCount < 2) return; |
127 | 317 |
seed = QUuid::createUuid().toString(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
318 |
Start(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
319 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
320 |
|
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
321 |
void HWGame::StartQuick() |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
322 |
{ |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
323 |
gameType = gtLocal; |
127 | 324 |
seed = QUuid::createUuid().toString(); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
325 |
Start(); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
326 |
} |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
327 |
|
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
328 |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
329 |
void HWGame::LocalCFG(const QString & teamname) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
330 |
{ |
116 | 331 |
HWTeam team(teamname); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
332 |
if (!team.LoadFromFile()) { |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
333 |
QMessageBox::critical(0, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
334 |
"Error", |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
335 |
QString("Cannot load team config ""%1""").arg(teamname), |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
336 |
QMessageBox::Ok, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
337 |
QMessageBox::NoButton, |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
338 |
QMessageBox::NoButton); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
339 |
return; |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
340 |
} |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
341 |
RawSendIPC(team.IPCTeamInfo()); |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
342 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
343 |
|
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
344 |
void HWGame::LocalCFG(quint8 num) |
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
345 |
{ |
116 | 346 |
HWTeam team(num); |
86
664b536a1c27
Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents:
85
diff
changeset
|
347 |
RawSendIPC(team.IPCTeamInfo()); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
28
diff
changeset
|
348 |
} |