author | unc0rr |
Sun, 30 Sep 2007 14:43:15 +0000 | |
changeset 616 | 00928b3cf505 |
parent 574 | 1cafd9eb1a21 |
child 655 | e58a77556878 |
permissions | -rw-r--r-- |
315 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
486 | 3 |
* Copyright (c) 2006-2007 Ulyanov Igor <iulyanov@gmail.com> |
315 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QMessageBox> |
|
20 |
||
21 |
#include "newnetclient.h" |
|
22 |
#include "proto.h" |
|
23 |
#include "gameuiconfig.h" |
|
24 |
#include "game.h" |
|
334 | 25 |
#include "gamecfgwidget.h" |
347 | 26 |
#include "teamselect.h" |
315 | 27 |
|
28 |
char delimeter='\t'; |
|
29 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
30 |
HWNewNet::HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget) : |
334 | 31 |
config(config), |
32 |
m_pGameCFGWidget(pGameCFGWidget), |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
33 |
m_pTeamSelWidget(pTeamSelWidget), |
383 | 34 |
isChief(false), |
35 |
m_game_connected(false) |
|
315 | 36 |
{ |
37 |
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
|
38 |
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); |
|
39 |
connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); |
|
40 |
connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, |
|
41 |
SLOT(displayError(QAbstractSocket::SocketError))); |
|
42 |
} |
|
43 |
||
44 |
void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
|
45 |
{ |
|
46 |
NetSocket.connectToHost(hostName, port); |
|
47 |
mynick = nick; |
|
48 |
} |
|
49 |
||
50 |
void HWNewNet::Disconnect() |
|
51 |
{ |
|
407 | 52 |
m_game_connected=false; |
383 | 53 |
NetSocket.disconnectFromHost(); |
315 | 54 |
} |
55 |
||
56 |
void HWNewNet::JoinGame(const QString & game) |
|
57 |
{ |
|
58 |
RawSendNet(QString("JOIN %1").arg(game)); |
|
59 |
} |
|
60 |
||
61 |
void HWNewNet::AddTeam(const HWTeam & team) |
|
62 |
{ |
|
63 |
RawSendNet(QString("ADDTEAM:") + delimeter + |
|
382
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
64 |
team.TeamName + delimeter + |
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
65 |
team.teamColor.name() + delimeter + |
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
66 |
team.Grave + delimeter + |
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
67 |
team.Fort + delimeter + |
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
68 |
QString::number(team.difficulty) + delimeter + |
382
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
69 |
team.HHName[0] + delimeter + team.HHName[1] + delimeter + |
315 | 70 |
team.HHName[2] + delimeter + team.HHName[3] + delimeter + team.HHName[4] + delimeter + |
71 |
team.HHName[5] + delimeter + team.HHName[6] + delimeter + team.HHName[7]); |
|
72 |
} |
|
73 |
||
347 | 74 |
void HWNewNet::RemoveTeam(const HWTeam & team) |
75 |
{ |
|
76 |
RawSendNet(QString("REMOVETEAM:") + delimeter + team.TeamName); |
|
401 | 77 |
m_networkToLocalteams.remove(m_networkToLocalteams.key(team.TeamName)); |
347 | 78 |
} |
79 |
||
315 | 80 |
void HWNewNet::StartGame() |
81 |
{ |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
82 |
RawSendNet(QString("START:")); |
315 | 83 |
} |
84 |
||
85 |
void HWNewNet::SendNet(const QByteArray & buf) |
|
86 |
{ |
|
87 |
QString msg = QString(buf.toBase64()); |
|
88 |
||
89 |
//NetBuffer += buf; |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
90 |
RawSendNet(QString("GAMEMSG:%1%2").arg(delimeter).arg(msg)); |
315 | 91 |
} |
92 |
||
93 |
void HWNewNet::RawSendNet(const QString & str) |
|
94 |
{ |
|
95 |
RawSendNet(str.toUtf8()); |
|
96 |
} |
|
97 |
||
98 |
void HWNewNet::RawSendNet(const QByteArray & buf) |
|
99 |
{ |
|
100 |
NetSocket.write(buf); |
|
101 |
NetSocket.write("\n", 1); |
|
102 |
} |
|
103 |
||
104 |
void HWNewNet::ClientRead() |
|
105 |
{ |
|
106 |
while (NetSocket.canReadLine()) { |
|
107 |
ParseLine(NetSocket.readLine().trimmed()); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
void HWNewNet::OnConnect() |
|
112 |
{ |
|
113 |
RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
|
114 |
} |
|
115 |
||
116 |
void HWNewNet::OnDisconnect() |
|
117 |
{ |
|
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
118 |
//emit ChangeInTeams(QStringList()); |
383 | 119 |
if(m_game_connected) emit Disconnected(); |
120 |
m_game_connected=false; |
|
315 | 121 |
} |
122 |
||
123 |
void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
|
124 |
{ |
|
125 |
switch (socketError) { |
|
126 |
case QAbstractSocket::RemoteHostClosedError: |
|
127 |
break; |
|
128 |
case QAbstractSocket::HostNotFoundError: |
|
129 |
QMessageBox::information(0, tr("Error"), |
|
130 |
tr("The host was not found. Please check the host name and port settings.")); |
|
131 |
break; |
|
132 |
case QAbstractSocket::ConnectionRefusedError: |
|
133 |
QMessageBox::information(0, tr("Error"), |
|
134 |
tr("Connection refused")); |
|
135 |
break; |
|
136 |
default: |
|
137 |
QMessageBox::information(0, tr("Error"), |
|
138 |
NetSocket.errorString()); |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
void HWNewNet::ParseLine(const QByteArray & line) |
|
143 |
{ |
|
144 |
QString msg = QString::fromUtf8 (line.data(), line.size()); |
|
320 | 145 |
|
315 | 146 |
QStringList lst = msg.split(delimeter); |
147 |
if (lst[0] == "ERRONEUSNICKNAME") { |
|
148 |
QMessageBox::information(0, 0, "Your net nickname is in use or cannot be used"); |
|
149 |
return; |
|
150 |
} |
|
151 |
||
152 |
if (lst[0] == "CONNECTED") { |
|
383 | 153 |
m_game_connected=true; |
315 | 154 |
emit Connected(); |
155 |
emit EnteredGame(); |
|
156 |
return; |
|
157 |
} |
|
158 |
||
453 | 159 |
if (lst[0] == "CHAT_STRING") { |
160 |
lst.pop_front(); |
|
573 | 161 |
if(lst.size() < 2) |
162 |
{ |
|
163 |
qWarning("Net: Empty CHAT_STRING message"); |
|
164 |
return; |
|
165 |
} |
|
453 | 166 |
emit chatStringFromNet(lst); |
167 |
return; |
|
168 |
} |
|
169 |
||
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
170 |
if (lst[0] == "ADDTEAM:") { |
574 | 171 |
if(lst.size() < 14) |
172 |
{ |
|
173 |
qWarning("Net: Too short ADDTEAM message"); |
|
174 |
return; |
|
175 |
} |
|
315 | 176 |
lst.pop_front(); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
177 |
emit AddNetTeam(lst); |
315 | 178 |
return; |
179 |
} |
|
180 |
||
347 | 181 |
if (lst[0] == "REMOVETEAM:") { |
573 | 182 |
if(lst.size() < 3) |
183 |
{ |
|
184 |
qWarning("Net: Bad REMOVETEAM message"); |
|
185 |
return; |
|
186 |
} |
|
352 | 187 |
m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt())); |
347 | 188 |
return; |
189 |
} |
|
190 |
||
349 | 191 |
if(lst[0]=="SLAVE") { |
192 |
m_pGameCFGWidget->setEnabled(false); |
|
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
356
diff
changeset
|
193 |
m_pTeamSelWidget->setNonInteractive(); |
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
194 |
return; |
349 | 195 |
} |
196 |
||
455 | 197 |
if(lst[0]=="JOINED") { |
573 | 198 |
if(lst.size() < 2) |
199 |
{ |
|
200 |
qWarning("Net: Bad JOINED message"); |
|
201 |
return; |
|
202 |
} |
|
465 | 203 |
emit nickAdded(lst[1]); |
455 | 204 |
return; |
205 |
} |
|
206 |
||
461 | 207 |
if(lst[0]=="LEFT") { |
573 | 208 |
if(lst.size() < 2) |
209 |
{ |
|
210 |
qWarning("Net: Bad LEFT message"); |
|
211 |
return; |
|
212 |
} |
|
465 | 213 |
emit nickRemoved(lst[1]); |
461 | 214 |
return; |
215 |
} |
|
216 |
||
315 | 217 |
if (lst[0] == "CONFIGASKED") { |
334 | 218 |
isChief=true; |
315 | 219 |
ConfigAsked(); |
220 |
return; |
|
221 |
} |
|
320 | 222 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
223 |
if (lst[0] == "RUNGAME") { |
396 | 224 |
RunGame(); |
225 |
return; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
226 |
} |
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
227 |
|
315 | 228 |
if (lst[0] == "CONFIGURED") { |
229 |
lst.pop_front(); |
|
573 | 230 |
if(lst.size() < 6) |
231 |
{ |
|
232 |
qWarning("Net: Bad CONFIGURED message"); |
|
233 |
return; |
|
234 |
} |
|
334 | 235 |
emit seedChanged(lst[0]); |
236 |
emit mapChanged(lst[1]); |
|
237 |
emit themeChanged(lst[2]); |
|
238 |
emit initHealthChanged(lst[3].toUInt()); |
|
239 |
emit turnTimeChanged(lst[4].toUInt()); |
|
444 | 240 |
emit fortsModeChanged(lst[5].toInt() != 0); |
315 | 241 |
return; |
242 |
} |
|
243 |
||
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
244 |
if(lst[0]=="TEAM_ACCEPTED") { |
573 | 245 |
if(lst.size() < 3) |
246 |
{ |
|
247 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
|
248 |
return; |
|
249 |
} |
|
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
250 |
m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]); |
373 | 251 |
m_pTeamSelWidget->changeTeamStatus(lst[1]); |
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
252 |
return; |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
253 |
} |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
254 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
255 |
if (lst[0] == "CONFIG_PARAM") { |
573 | 256 |
if(lst.size() < 3) |
257 |
{ |
|
258 |
qWarning("Net: Bad CONFIG_PARAM message"); |
|
259 |
return; |
|
260 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
261 |
if (lst[1] == "SEED") { |
332 | 262 |
emit seedChanged(lst[2]); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
263 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
264 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
265 |
if (lst[1] == "MAP") { |
332 | 266 |
emit mapChanged(lst[2]); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
267 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
268 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
269 |
if (lst[1] == "THEME") { |
332 | 270 |
emit themeChanged(lst[2]); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
271 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
272 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
273 |
if (lst[1] == "HEALTH") { |
332 | 274 |
emit initHealthChanged(lst[2].toUInt()); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
275 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
276 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
277 |
if (lst[1] == "TURNTIME") { |
332 | 278 |
emit turnTimeChanged(lst[2].toUInt()); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
279 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
280 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
281 |
if (lst[1] == "FORTSMODE") { |
332 | 282 |
emit fortsModeChanged(lst[2].toInt() != 0); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
283 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
284 |
} |
401 | 285 |
QStringList hhTmpList=lst[1].split('+'); |
286 |
if (hhTmpList[0] == "TEAM_COLOR") { |
|
287 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
|
288 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
289 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
372 | 290 |
} |
401 | 291 |
tmptm.teamColor=QColor(lst[2]); |
372 | 292 |
emit teamColorChanged(tmptm); |
293 |
return; |
|
294 |
} |
|
401 | 295 |
if (hhTmpList[0] == "HHNUM") { |
399 | 296 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
297 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
298 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
299 |
} |
|
300 |
tmptm.numHedgehogs=lst[2].toUInt(); |
|
301 |
emit hhnumChanged(tmptm); |
|
302 |
return; |
|
303 |
} |
|
573 | 304 |
qWarning(QString("Net: Unknown 'CONFIG_PARAM' message: '%1'").arg(msg).toAscii().data()); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
305 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
306 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
307 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
308 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
309 |
// should be kinda game states, which don't allow "GAMEMSG:" at configure step, |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
310 |
// "CONNECTED" at round phase, etc. |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
311 |
if (lst[0] == "GAMEMSG:") { |
573 | 312 |
if(lst.size() < 2) |
313 |
{ |
|
314 |
qWarning("Net: Bad LEFT message"); |
|
315 |
return; |
|
316 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
317 |
QByteArray em = QByteArray::fromBase64(lst[1].toAscii()); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
318 |
emit FromNet(em); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
319 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
320 |
} |
573 | 321 |
|
322 |
qWarning(QString("Net: Unknown message: '%1'").arg(msg).toAscii().data()); |
|
315 | 323 |
} |
324 |
||
325 |
||
326 |
void HWNewNet::ConfigAsked() |
|
327 |
{ |
|
574 | 328 |
QString map = m_pGameCFGWidget->getCurrentMap(); |
329 |
if (map.size()) |
|
330 |
onMapChanged(map); |
|
331 |
||
335 | 332 |
onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
333 |
onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
|
334 |
onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
|
335 |
onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
|
444 | 336 |
onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
315 | 337 |
} |
338 |
||
339 |
void HWNewNet::RunGame() |
|
340 |
{ |
|
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
341 |
HWGame* game = new HWGame(config, m_pGameCFGWidget, m_pTeamSelWidget); |
448 | 342 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SIGNAL(GameStateChanged(GameState))); |
315 | 343 |
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
344 |
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
|
431 | 345 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
315 | 346 |
game->StartNet(); |
347 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
348 |
|
431 | 349 |
void HWNewNet::ShowErrorMessage(const QString & msg) |
350 |
{ |
|
351 |
QMessageBox::warning(0, |
|
352 |
"Hedgewars", |
|
353 |
msg); |
|
354 |
} |
|
355 |
||
352 | 356 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
357 |
{ |
|
455 | 358 |
RawSendNet(QString("HHNUM%1%2%1%3%1%4").arg(delimeter).arg(team.TeamName)\ |
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
359 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
360 |
.arg(team.numHedgehogs)); |
352 | 361 |
} |
362 |
||
372 | 363 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
364 |
{ |
|
401 | 365 |
RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\ |
372 | 366 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
367 |
.arg(team.teamColor.name())); |
|
368 |
} |
|
369 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
370 |
void HWNewNet::onSeedChanged(const QString & seed) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
371 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
372 |
RawSendNet(QString("CONFIG_PARAM%1SEED%1%2").arg(delimeter).arg(seed)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
373 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
374 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
375 |
void HWNewNet::onMapChanged(const QString & map) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
376 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
377 |
RawSendNet(QString("CONFIG_PARAM%1MAP%1%2").arg(delimeter).arg(map)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
378 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
379 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
380 |
void HWNewNet::onThemeChanged(const QString & theme) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
381 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
382 |
RawSendNet(QString("CONFIG_PARAM%1THEME%1%2").arg(delimeter).arg(theme)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
383 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
384 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
385 |
void HWNewNet::onInitHealthChanged(quint32 health) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
386 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
387 |
RawSendNet(QString("CONFIG_PARAM%1HEALTH%1%2").arg(delimeter).arg(health)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
388 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
389 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
390 |
void HWNewNet::onTurnTimeChanged(quint32 time) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
391 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
392 |
RawSendNet(QString("CONFIG_PARAM%1TURNTIME%1%2").arg(delimeter).arg(time)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
393 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
394 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
395 |
void HWNewNet::onFortsModeChanged(bool value) |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
396 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
397 |
RawSendNet(QString("CONFIG_PARAM%1FORTSMODE%1%2").arg(delimeter).arg(value)); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
398 |
} |
453 | 399 |
|
400 |
void HWNewNet::chatLineToNet(const QString& str) |
|
401 |
{ |
|
402 |
if(str!="") { |
|
403 |
RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str); |
|
404 |
emit(chatStringFromNet(QStringList(mynick) << str)); |
|
405 |
} |
|
406 |
} |