author | unc0rr |
Sun, 30 Dec 2007 16:51:06 +0000 | |
changeset 691 | 0a534a03437e |
parent 660 | 7c155e849602 |
child 697 | 44f167938201 |
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 |
|
655
e58a77556878
- Temporary set delimiter to *, as \t seems to be endline now in Qt
unc0rr
parents:
574
diff
changeset
|
28 |
char delimeter='*'; |
315 | 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 |
{ |
|
655
e58a77556878
- Temporary set delimiter to *, as \t seems to be endline now in Qt
unc0rr
parents:
574
diff
changeset
|
46 |
mynick = nick; |
315 | 47 |
NetSocket.connectToHost(hostName, port); |
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 |
{ |
|
660 | 341 |
emit AskForRunGame(); |
431 | 342 |
} |
343 |
||
352 | 344 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
345 |
{ |
|
455 | 346 |
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
|
347 |
.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
|
348 |
.arg(team.numHedgehogs)); |
352 | 349 |
} |
350 |
||
372 | 351 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
352 |
{ |
|
401 | 353 |
RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\ |
372 | 354 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
355 |
.arg(team.teamColor.name())); |
|
356 |
} |
|
357 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
358 |
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
|
359 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
360 |
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
|
361 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
362 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
363 |
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
|
364 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
365 |
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
|
366 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
367 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
368 |
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
|
369 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
370 |
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
|
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 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
373 |
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
|
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 |
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
|
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 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
378 |
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
|
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 |
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
|
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 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
383 |
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
|
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 |
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
|
386 |
} |
453 | 387 |
|
388 |
void HWNewNet::chatLineToNet(const QString& str) |
|
389 |
{ |
|
390 |
if(str!="") { |
|
391 |
RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str); |
|
392 |
emit(chatStringFromNet(QStringList(mynick) << str)); |
|
393 |
} |
|
394 |
} |