author | unc0rr |
Sun, 03 Sep 2006 15:39:53 +0000 | |
changeset 138 | 00e8d3693e90 |
parent 127 | ca70467bd0a8 |
child 183 | 57c2ef19f719 |
permissions | -rw-r--r-- |
28 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
127 | 3 |
* Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
28 | 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> |
|
127 | 35 |
#include <QUuid> |
28 | 36 |
#include "netclient.h" |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
37 |
#include "game.h" |
127 | 38 |
#include "gameuiconfig.h" |
28 | 39 |
|
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
40 |
HWNet::HWNet(GameUIConfig * config) |
28 | 41 |
: QObject() |
42 |
{ |
|
84 | 43 |
this->config = config; |
28 | 44 |
state = nsDisconnected; |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
45 |
IRCmsg_cmd_text = new QRegExp("^[A-Z]+ :.+$"); |
28 | 46 |
IRCmsg_number_param = new QRegExp("^:\\S+ [0-9]{3} .+$"); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
47 |
IRCmsg_who_cmd_target = new QRegExp("^:\\S+ [A-Z]+ \\S+$"); // last \\S should mean 'the 1st char is not ":"' |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
48 |
IRCmsg_who_cmd_text = new QRegExp("^:\\S+ [A-Z]+ :.+$"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
49 |
IRCmsg_who_cmd_target_text = new QRegExp("^:\\S+ [A-Z]+ \\S+ :.+$"); |
29 | 50 |
isOp = false; |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
51 |
teamsCount = 0; |
28 | 52 |
|
53 |
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
|
54 |
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); |
|
55 |
connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); |
|
56 |
connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, |
|
57 |
SLOT(displayError(QAbstractSocket::SocketError))); |
|
58 |
} |
|
59 |
||
60 |
void HWNet::ClientRead() |
|
61 |
{ |
|
62 |
while (NetSocket.canReadLine()) |
|
63 |
{ |
|
64 |
ParseLine(NetSocket.readLine().trimmed()); |
|
65 |
} |
|
66 |
} |
|
67 |
||
68 |
void HWNet::displayError(QAbstractSocket::SocketError socketError) |
|
69 |
{ |
|
70 |
switch (socketError) |
|
71 |
{ |
|
72 |
case QAbstractSocket::RemoteHostClosedError: |
|
73 |
break; |
|
74 |
case QAbstractSocket::HostNotFoundError: |
|
75 |
QMessageBox::information(0, tr("Error"), |
|
76 |
tr("The host was not found. Please check the host name and port settings.")); |
|
77 |
break; |
|
78 |
case QAbstractSocket::ConnectionRefusedError: |
|
79 |
QMessageBox::information(0, tr("Error"), |
|
80 |
tr("Connection refused")); |
|
81 |
break; |
|
82 |
default: |
|
83 |
QMessageBox::information(0, tr("Error"), |
|
84 |
NetSocket.errorString()); |
|
85 |
} |
|
86 |
} |
|
87 |
||
29 | 88 |
void HWNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
28 | 89 |
{ |
90 |
state = nsConnecting; |
|
91 |
NetSocket.connectToHost(hostName, port); |
|
29 | 92 |
mynick = nick; |
93 |
opnick = ""; |
|
94 |
opCount = 0; |
|
28 | 95 |
} |
96 |
||
97 |
||
98 |
void HWNet::OnConnect() |
|
99 |
{ |
|
100 |
state = nsConnected; |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
101 |
RawSendNet(QString("USER hwgame 1 2 Hedgewars game")); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
102 |
RawSendNet(QString("NICK %1").arg(mynick)); |
28 | 103 |
} |
104 |
||
105 |
void HWNet::OnDisconnect() |
|
106 |
{ |
|
107 |
state = nsDisconnected; |
|
108 |
} |
|
109 |
||
110 |
void HWNet::Perform() |
|
111 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
112 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
113 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
114 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
115 |
void HWNet::JoinGame(const QString & game) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
116 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
117 |
state = nsJoining; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
118 |
RawSendNet(QString("JOIN %1").arg(game)); |
28 | 119 |
} |
120 |
||
121 |
void HWNet::Disconnect() |
|
122 |
{ |
|
123 |
switch (state) |
|
124 |
{ |
|
125 |
case nsDisconnected: |
|
126 |
{ |
|
127 |
break; |
|
128 |
} |
|
129 |
case nsConnecting: |
|
130 |
case nsQuitting: |
|
131 |
{ |
|
132 |
NetSocket.disconnect(); |
|
133 |
break; |
|
134 |
} |
|
135 |
default: |
|
136 |
{ |
|
137 |
state = nsQuitting; |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
138 |
RawSendNet(QString("QUIT :oops")); |
28 | 139 |
} |
140 |
} |
|
141 |
} |
|
142 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
143 |
void HWNet::RawSendNet(const QString & str) |
28 | 144 |
{ |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
145 |
RawSendNet(str.toUtf8()); |
28 | 146 |
} |
147 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
148 |
void HWNet::RawSendNet(const QByteArray & buf) |
28 | 149 |
{ |
150 |
if (buf.size() > 510) return; |
|
151 |
NetSocket.write(buf); |
|
152 |
NetSocket.write("\x0d\x0a", 2); |
|
153 |
} |
|
154 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
155 |
void HWNet::SendNet(const QByteArray & buf) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
156 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
157 |
if ((state == nsGaming) || (state == nsStarting)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
158 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
159 |
QString msg = QString(buf.toBase64()); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
160 |
if ((msg == "AUM=") && (mynick == opnick)) |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
161 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
162 |
ConfigAsked(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
163 |
} else |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
164 |
if (msg == "AT8=") |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
165 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
166 |
// its ping ("?") |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
167 |
} else |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
168 |
{ |
36 | 169 |
if (state == nsGaming) |
170 |
{ |
|
171 |
NetBuffer += buf; |
|
172 |
} else |
|
173 |
{ |
|
174 |
RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, msg)); |
|
175 |
} |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
176 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
177 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
178 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
179 |
|
36 | 180 |
void HWNet::FlushNetBuf() |
181 |
{ |
|
182 |
if (NetBuffer.size() > 0) |
|
183 |
{ |
|
184 |
RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, QString(NetBuffer.toBase64()))); |
|
185 |
NetBuffer.clear(); |
|
186 |
} |
|
187 |
} |
|
188 |
||
125 | 189 |
void HWNet::ParseLine(const QByteArray & line) |
28 | 190 |
{ |
125 | 191 |
QString msg = QString::fromUtf8 (line.data(), line.size()); |
29 | 192 |
//QMessageBox::information(0, "", msg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
193 |
if (IRCmsg_cmd_text->exactMatch(msg)) |
28 | 194 |
{ |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
195 |
msgcmd_textHandler(msg); |
28 | 196 |
} else |
197 |
if (IRCmsg_number_param->exactMatch(msg)) |
|
198 |
{ |
|
199 |
msgnumber_paramHandler(msg); |
|
29 | 200 |
} else |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
201 |
if (IRCmsg_who_cmd_text->exactMatch(msg)) |
29 | 202 |
{ |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
203 |
msgwho_cmd_textHandler(msg); |
29 | 204 |
} else |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
205 |
if (IRCmsg_who_cmd_target->exactMatch(msg)) |
29 | 206 |
{ |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
207 |
msgwho_cmd_targetHandler(msg); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
208 |
} else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
209 |
if (IRCmsg_who_cmd_target_text->exactMatch(msg)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
210 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
211 |
msgwho_cmd_target_textHandler(msg); |
28 | 212 |
} |
213 |
} |
|
214 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
215 |
void HWNet::msgcmd_textHandler(const QString & msg) |
28 | 216 |
{ |
217 |
QStringList list = msg.split(" :"); |
|
218 |
if (list[0] == "PING") |
|
219 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
220 |
RawSendNet(QString("PONG %1").arg(list[1])); |
28 | 221 |
} |
222 |
} |
|
223 |
||
224 |
void HWNet::msgnumber_paramHandler(const QString & msg) |
|
225 |
{ |
|
29 | 226 |
int pos = msg.indexOf(" :"); |
227 |
QString text = msg.mid(pos + 2); |
|
228 |
QStringList list = msg.mid(0, pos).split(" "); |
|
28 | 229 |
bool ok; |
230 |
quint16 number = list[1].toInt(&ok); |
|
231 |
if (!ok) |
|
232 |
return ; |
|
233 |
switch (number) |
|
234 |
{ |
|
235 |
case 001 : |
|
236 |
{ |
|
237 |
Perform(); |
|
238 |
emit Connected(); |
|
239 |
break; |
|
240 |
} |
|
29 | 241 |
case 322 : // RPL_LIST |
28 | 242 |
{ |
243 |
emit AddGame(list[3]); |
|
29 | 244 |
break; |
245 |
} |
|
246 |
case 353 : // RPL_NAMREPLY |
|
247 |
{ |
|
248 |
QStringList ops = text.split(" ").filter(QRegExp("^@\\S+$")); |
|
249 |
opCount += ops.size(); |
|
250 |
if (ops.size() == 1) |
|
251 |
{ |
|
252 |
opnick = ops[0].mid(1); |
|
253 |
} |
|
254 |
break; |
|
255 |
} |
|
256 |
case 366 : // RPL_ENDOFNAMES |
|
257 |
{ |
|
258 |
if (opCount != 1) |
|
259 |
{ |
|
260 |
opnick = ""; |
|
261 |
} |
|
262 |
opCount = 0; |
|
263 |
break; |
|
264 |
} |
|
265 |
case 432 : // ERR_ERRONEUSNICKNAME |
|
266 |
case 433 : // ERR_NICKNAMEINUSE |
|
267 |
{ |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
268 |
QMessageBox::information(0, "Your net nickname is in use or cannot be used", msg); |
29 | 269 |
// ask for another nick |
28 | 270 |
} |
271 |
} |
|
272 |
} |
|
29 | 273 |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
274 |
void HWNet::msgwho_cmd_targetHandler(const QString & msg) |
29 | 275 |
{ |
276 |
QStringList list = msg.split(" "); |
|
277 |
QString who = list[0].mid(1).split("!")[0]; |
|
278 |
if (list[1] == "NICK") |
|
279 |
{ |
|
280 |
if (mynick == who) |
|
281 |
mynick = list[2]; |
|
282 |
if (opnick == who) |
|
283 |
opnick = list[2]; |
|
284 |
} |
|
285 |
} |
|
286 |
||
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
287 |
void HWNet::msgwho_cmd_textHandler(const QString & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
288 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
289 |
int pos = msg.indexOf(" :"); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
290 |
QString text = msg.mid(pos + 2); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
291 |
QStringList list = msg.mid(0, pos).split(" "); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
292 |
QString who = list[0].mid(1).split("!")[0]; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
293 |
if (list[1] == "JOIN") |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
294 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
295 |
if (who == mynick) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
296 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
297 |
channel = text; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
298 |
state = nsJoined; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
299 |
emit EnteredGame(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
300 |
RawSendNet(QString("PRIVMSG %1 :Hello!").arg(channel)); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
301 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
302 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
303 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
304 |
void HWNet::msgwho_cmd_target_textHandler(const QString & msg) |
29 | 305 |
{ |
306 |
int pos = msg.indexOf(" :"); |
|
307 |
QString text = msg.mid(pos + 2); |
|
308 |
QStringList list = msg.mid(0, pos).split(" "); |
|
309 |
QString who = list[0].mid(1).split("!")[0]; |
|
310 |
if (list[1] == "PRIVMSG") |
|
311 |
{ |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
312 |
if (list[2] == opnick) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
313 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
314 |
hwp_opmsg(who, text); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
315 |
} else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
316 |
if (list[2] == channel) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
317 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
318 |
hwp_chanmsg(who, text); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
319 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
320 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
321 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
322 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
323 |
void HWNet::hwp_opmsg(const QString & who, const QString & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
324 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
325 |
if (state != nsJoined) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
326 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
327 |
if (!msg.startsWith(MAGIC_CHAR)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
328 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
329 |
QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
330 |
if (list[0] == "A") |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
331 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
332 |
list.removeFirst(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
333 |
if (list.size() != 9) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
334 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
335 |
if (teamsCount < 5) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
336 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
337 |
teams[teamsCount].nick = who; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
338 |
teams[teamsCount].hhs = list; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
339 |
teamsCount++; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
340 |
QString teamnames; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
341 |
for(int i = 0; i < teamsCount; i++) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
342 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
343 |
teamnames += MAGIC_CHAR; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
344 |
teamnames += teams[i].hhs[0]; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
345 |
} |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
346 |
QString tmsg = QString(MAGIC_CHAR"=%2").arg(teamnames); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
347 |
RawSendNet(QString("PRIVMSG %1 :").arg(channel) + tmsg); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
348 |
hwp_chanmsg(mynick, tmsg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
349 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
350 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
351 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
352 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
353 |
void HWNet::ConfigAsked() |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
354 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
355 |
configasks++; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
356 |
if (configasks == playerscnt) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
357 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
358 |
quint32 color = 65535; |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
359 |
#define ADD(a) { \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
360 |
QByteArray strmsg; \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
361 |
strmsg.append(a); \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
362 |
quint8 sz = strmsg.size(); \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
363 |
cache.append(QByteArray((char *)&sz, 1)); \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
364 |
cache.append(strmsg); \ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
365 |
} |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
366 |
{ |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
367 |
QByteArray cache; |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
368 |
ADD("eseed " + seed); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
369 |
ADD("e$gmflags 0"); |
127 | 370 |
ADD(QString("etheme %1").arg(config->GetRandomTheme())); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
371 |
QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
372 |
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
373 |
hwp_chanmsg(mynick, _msg); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
374 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
375 |
for (int i = 0; i < teamsCount; i++) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
376 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
377 |
QString msg; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
378 |
msg = MAGIC_CHAR "T" MAGIC_CHAR + teams[i].nick + MAGIC_CHAR + teams[i].hhs.join(MAGIC_CHAR); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
379 |
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
380 |
hwp_chanmsg(mynick, msg); |
36 | 381 |
QByteArray cache; |
382 |
ADD(QString("ecolor %1").arg(color)); |
|
383 |
ADD("eadd hh0 0"); |
|
384 |
ADD("eadd hh1 0"); |
|
385 |
ADD("eadd hh2 0"); |
|
386 |
ADD("eadd hh3 0"); |
|
387 |
ADD("eadd hh4 0"); |
|
388 |
#undef ADD |
|
389 |
QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
390 |
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); |
36 | 391 |
hwp_chanmsg(mynick, _msg); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
392 |
color <<= 8; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
393 |
} |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
394 |
SENDCFGSTRNET("!"); |
29 | 395 |
} |
396 |
} |
|
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
397 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
398 |
void HWNet::hwp_chanmsg(const QString & who, const QString & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
399 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
400 |
if ((state < nsJoined) || (state > nsGaming)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
401 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
402 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
403 |
} |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
404 |
if (state == nsJoined) |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
405 |
{ |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
406 |
if (msg.startsWith(MAGIC_CHAR"Start!") && (who == opnick)) |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
407 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
408 |
state = nsStarting; |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
409 |
RunGame(); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
410 |
return ; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
411 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
412 |
if (msg.startsWith(MAGIC_CHAR"="MAGIC_CHAR) && (who == opnick)) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
413 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
414 |
emit ChangeInTeams(msg.mid(3).split(MAGIC_CHAR)); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
415 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
416 |
} |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
417 |
if (state == nsStarting) |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
418 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
419 |
if (msg == MAGIC_CHAR MAGIC_CHAR "AUM=") |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
420 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
421 |
if (mynick == opnick) ConfigAsked(); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
422 |
return ; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
423 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
424 |
if (msg == MAGIC_CHAR MAGIC_CHAR "ASE=") |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
425 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
426 |
state = nsGaming; |
36 | 427 |
TimerFlusher = new QTimer(); |
428 |
connect(TimerFlusher, SIGNAL(timeout()), this, SLOT(FlushNetBuf())); |
|
429 |
TimerFlusher->start(2000); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
430 |
} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
431 |
if (msg.startsWith(MAGIC_CHAR"T"MAGIC_CHAR)) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
432 |
{ |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
433 |
NetTeamAdded(msg.mid(3)); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
434 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
435 |
} |
36 | 436 |
if ((state < nsStarting) || (state > nsGaming)) |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
437 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
438 |
return; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
439 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
440 |
if (msg.startsWith(MAGIC_CHAR MAGIC_CHAR)) // HWP message |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
441 |
{ |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
442 |
QByteArray em = QByteArray::fromBase64(msg.mid(2).toAscii()); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
443 |
emit FromNet(em); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
444 |
} else // smth other |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
445 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
446 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
447 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
448 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
449 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
450 |
void HWNet::NetTeamAdded(const QString & msg) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
451 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
452 |
QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
453 |
if (list.size() != 10) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
454 |
return ; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
455 |
SENDCFGSTRLOC("eaddteam"); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
456 |
if (list[0] == mynick) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
457 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
458 |
emit LocalCFG(list[1]); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
459 |
} else |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
460 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
461 |
SENDCFGSTRLOC("erdriven"); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
462 |
SENDCFGSTRLOC(QString("ename team %1").arg(list[1])); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
463 |
for (int i = 0; i < 8; i++) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
464 |
{ |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
465 |
SENDCFGSTRLOC(QString("ename hh%1 ").arg(i) + list[i + 2]); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
466 |
} |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
31
diff
changeset
|
467 |
} |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
468 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
469 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
470 |
void HWNet::AddTeam(const HWTeam & team) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
471 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
472 |
if (state != nsJoined) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
473 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
474 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
475 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
476 |
RawSendNet(QString("PRIVMSG %1 :").arg(opnick) + MAGIC_CHAR "A" MAGIC_CHAR + |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
477 |
team.TeamName + MAGIC_CHAR + team.HHName[0] + MAGIC_CHAR + team.HHName[1] + MAGIC_CHAR + |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
478 |
team.HHName[2] + MAGIC_CHAR + team.HHName[3] + MAGIC_CHAR + team.HHName[4] + MAGIC_CHAR + |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
479 |
team.HHName[5] + MAGIC_CHAR + team.HHName[6] + MAGIC_CHAR + team.HHName[7]); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
480 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
481 |
|
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
482 |
void HWNet::StartGame() |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
483 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
484 |
if ((opnick != mynick) || (state != nsJoined)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
485 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
486 |
return ; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
487 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
488 |
QStringList players; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
489 |
for (int i = 0; i < teamsCount; i++) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
490 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
491 |
if (!players.contains(teams[i].nick)) |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
492 |
{ |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
493 |
players.append(teams[i].nick); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
494 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
495 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
496 |
playerscnt = players.size(); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
497 |
configasks = 0; |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
498 |
|
127 | 499 |
seed = QUuid::createUuid().toString(); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
500 |
QString msg = QString(MAGIC_CHAR"Start!"); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
501 |
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
502 |
hwp_chanmsg(mynick, msg); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
503 |
} |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
504 |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
505 |
void HWNet::RunGame() |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
506 |
{ |
85
44d9045b26ff
New GameCFGWidget. Now it's possible to set forts mode from ui
unc0rr
parents:
84
diff
changeset
|
507 |
HWGame * game = new HWGame(config, 0); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
508 |
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
509 |
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
510 |
connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &))); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
85
diff
changeset
|
511 |
game->StartNet(); |
31
99888245a4e8
Now net game is near available, but exception occurs...
unc0rr
parents:
29
diff
changeset
|
512 |
} |