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