author | unc0rr |
Sat, 18 Aug 2007 12:05:29 +0000 | |
changeset 573 | e0cf483e68d6 |
parent 486 | 7ea71cd3acd5 |
child 574 | 1cafd9eb1a21 |
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("USER") + delimeter + "hwgame 1 2 Hedgewars game"); |
|
114 |
RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
|
115 |
} |
|
116 |
||
117 |
void HWNewNet::OnDisconnect() |
|
118 |
{ |
|
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
119 |
//emit ChangeInTeams(QStringList()); |
383 | 120 |
if(m_game_connected) emit Disconnected(); |
121 |
m_game_connected=false; |
|
315 | 122 |
} |
123 |
||
124 |
void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
|
125 |
{ |
|
126 |
switch (socketError) { |
|
127 |
case QAbstractSocket::RemoteHostClosedError: |
|
128 |
break; |
|
129 |
case QAbstractSocket::HostNotFoundError: |
|
130 |
QMessageBox::information(0, tr("Error"), |
|
131 |
tr("The host was not found. Please check the host name and port settings.")); |
|
132 |
break; |
|
133 |
case QAbstractSocket::ConnectionRefusedError: |
|
134 |
QMessageBox::information(0, tr("Error"), |
|
135 |
tr("Connection refused")); |
|
136 |
break; |
|
137 |
default: |
|
138 |
QMessageBox::information(0, tr("Error"), |
|
139 |
NetSocket.errorString()); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
void HWNewNet::ParseLine(const QByteArray & line) |
|
144 |
{ |
|
145 |
QString msg = QString::fromUtf8 (line.data(), line.size()); |
|
320 | 146 |
|
315 | 147 |
QStringList lst = msg.split(delimeter); |
148 |
if (lst[0] == "ERRONEUSNICKNAME") { |
|
149 |
QMessageBox::information(0, 0, "Your net nickname is in use or cannot be used"); |
|
150 |
return; |
|
151 |
} |
|
152 |
||
153 |
if (lst[0] == "CONNECTED") { |
|
383 | 154 |
m_game_connected=true; |
315 | 155 |
emit Connected(); |
156 |
emit EnteredGame(); |
|
157 |
return; |
|
158 |
} |
|
159 |
||
453 | 160 |
if (lst[0] == "CHAT_STRING") { |
161 |
lst.pop_front(); |
|
573 | 162 |
if(lst.size() < 2) |
163 |
{ |
|
164 |
qWarning("Net: Empty CHAT_STRING message"); |
|
165 |
return; |
|
166 |
} |
|
453 | 167 |
emit chatStringFromNet(lst); |
168 |
return; |
|
169 |
} |
|
170 |
||
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
171 |
if (lst[0] == "ADDTEAM:") { |
315 | 172 |
lst.pop_front(); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
173 |
emit AddNetTeam(lst); |
315 | 174 |
return; |
175 |
} |
|
176 |
||
347 | 177 |
if (lst[0] == "REMOVETEAM:") { |
573 | 178 |
if(lst.size() < 3) |
179 |
{ |
|
180 |
qWarning("Net: Bad REMOVETEAM message"); |
|
181 |
return; |
|
182 |
} |
|
352 | 183 |
m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt())); |
347 | 184 |
return; |
185 |
} |
|
186 |
||
349 | 187 |
if(lst[0]=="SLAVE") { |
188 |
m_pGameCFGWidget->setEnabled(false); |
|
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
356
diff
changeset
|
189 |
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
|
190 |
return; |
349 | 191 |
} |
192 |
||
455 | 193 |
if(lst[0]=="JOINED") { |
573 | 194 |
if(lst.size() < 2) |
195 |
{ |
|
196 |
qWarning("Net: Bad JOINED message"); |
|
197 |
return; |
|
198 |
} |
|
465 | 199 |
emit nickAdded(lst[1]); |
455 | 200 |
return; |
201 |
} |
|
202 |
||
461 | 203 |
if(lst[0]=="LEFT") { |
573 | 204 |
if(lst.size() < 2) |
205 |
{ |
|
206 |
qWarning("Net: Bad LEFT message"); |
|
207 |
return; |
|
208 |
} |
|
465 | 209 |
emit nickRemoved(lst[1]); |
461 | 210 |
return; |
211 |
} |
|
212 |
||
315 | 213 |
if (lst[0] == "CONFIGASKED") { |
334 | 214 |
isChief=true; |
315 | 215 |
ConfigAsked(); |
216 |
return; |
|
217 |
} |
|
320 | 218 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
219 |
if (lst[0] == "RUNGAME") { |
396 | 220 |
RunGame(); |
221 |
return; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
222 |
} |
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
223 |
|
315 | 224 |
if (lst[0] == "CONFIGURED") { |
225 |
lst.pop_front(); |
|
573 | 226 |
if(lst.size() < 6) |
227 |
{ |
|
228 |
qWarning("Net: Bad CONFIGURED message"); |
|
229 |
return; |
|
230 |
} |
|
334 | 231 |
emit seedChanged(lst[0]); |
232 |
emit mapChanged(lst[1]); |
|
233 |
emit themeChanged(lst[2]); |
|
234 |
emit initHealthChanged(lst[3].toUInt()); |
|
235 |
emit turnTimeChanged(lst[4].toUInt()); |
|
444 | 236 |
emit fortsModeChanged(lst[5].toInt() != 0); |
315 | 237 |
return; |
238 |
} |
|
239 |
||
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
240 |
if(lst[0]=="TEAM_ACCEPTED") { |
573 | 241 |
if(lst.size() < 3) |
242 |
{ |
|
243 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
|
244 |
return; |
|
245 |
} |
|
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
246 |
m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]); |
373 | 247 |
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
|
248 |
return; |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
249 |
} |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
250 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
251 |
if (lst[0] == "CONFIG_PARAM") { |
573 | 252 |
if(lst.size() < 3) |
253 |
{ |
|
254 |
qWarning("Net: Bad CONFIG_PARAM message"); |
|
255 |
return; |
|
256 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
257 |
if (lst[1] == "SEED") { |
332 | 258 |
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
|
259 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
260 |
} |
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] == "MAP") { |
332 | 262 |
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
|
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] == "THEME") { |
332 | 266 |
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
|
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] == "HEALTH") { |
332 | 270 |
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
|
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] == "TURNTIME") { |
332 | 274 |
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
|
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] == "FORTSMODE") { |
332 | 278 |
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
|
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 |
} |
401 | 281 |
QStringList hhTmpList=lst[1].split('+'); |
282 |
if (hhTmpList[0] == "TEAM_COLOR") { |
|
283 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
|
284 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
285 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
372 | 286 |
} |
401 | 287 |
tmptm.teamColor=QColor(lst[2]); |
372 | 288 |
emit teamColorChanged(tmptm); |
289 |
return; |
|
290 |
} |
|
401 | 291 |
if (hhTmpList[0] == "HHNUM") { |
399 | 292 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
293 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
294 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
295 |
} |
|
296 |
tmptm.numHedgehogs=lst[2].toUInt(); |
|
297 |
emit hhnumChanged(tmptm); |
|
298 |
return; |
|
299 |
} |
|
573 | 300 |
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
|
301 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
302 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
303 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
304 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
305 |
// 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
|
306 |
// "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
|
307 |
if (lst[0] == "GAMEMSG:") { |
573 | 308 |
if(lst.size() < 2) |
309 |
{ |
|
310 |
qWarning("Net: Bad LEFT message"); |
|
311 |
return; |
|
312 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
313 |
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
|
314 |
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
|
315 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
316 |
} |
573 | 317 |
|
318 |
qWarning(QString("Net: Unknown message: '%1'").arg(msg).toAscii().data()); |
|
315 | 319 |
} |
320 |
||
321 |
||
322 |
void HWNewNet::ConfigAsked() |
|
323 |
{ |
|
335 | 324 |
onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
325 |
onMapChanged(m_pGameCFGWidget->getCurrentMap()); |
|
326 |
onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
|
327 |
onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
|
328 |
onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
|
444 | 329 |
onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
315 | 330 |
} |
331 |
||
332 |
void HWNewNet::RunGame() |
|
333 |
{ |
|
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
334 |
HWGame* game = new HWGame(config, m_pGameCFGWidget, m_pTeamSelWidget); |
448 | 335 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SIGNAL(GameStateChanged(GameState))); |
315 | 336 |
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
337 |
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
|
431 | 338 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
315 | 339 |
game->StartNet(); |
340 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
341 |
|
431 | 342 |
void HWNewNet::ShowErrorMessage(const QString & msg) |
343 |
{ |
|
344 |
QMessageBox::warning(0, |
|
345 |
"Hedgewars", |
|
346 |
msg); |
|
347 |
} |
|
348 |
||
352 | 349 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
350 |
{ |
|
455 | 351 |
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
|
352 |
.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
|
353 |
.arg(team.numHedgehogs)); |
352 | 354 |
} |
355 |
||
372 | 356 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
357 |
{ |
|
401 | 358 |
RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\ |
372 | 359 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
360 |
.arg(team.teamColor.name())); |
|
361 |
} |
|
362 |
||
329
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::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
|
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%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
|
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::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
|
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%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
|
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::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
|
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%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
|
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::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
|
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%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
|
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::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
|
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%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
|
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 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
388 |
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
|
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 |
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
|
391 |
} |
453 | 392 |
|
393 |
void HWNewNet::chatLineToNet(const QString& str) |
|
394 |
{ |
|
395 |
if(str!="") { |
|
396 |
RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str); |
|
397 |
emit(chatStringFromNet(QStringList(mynick) << str)); |
|
398 |
} |
|
399 |
} |