author | unc0rr |
Mon, 21 Jul 2008 09:45:40 +0000 | |
changeset 1082 | 596b1dcdc1df |
parent 1081 | 5be338fa4e2c |
child 1083 | 3448dd03483f |
permissions | -rw-r--r-- |
315 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2006-2008 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 |
||
697 | 21 |
#include "hwconsts.h" |
315 | 22 |
#include "newnetclient.h" |
23 |
#include "proto.h" |
|
24 |
#include "gameuiconfig.h" |
|
25 |
#include "game.h" |
|
334 | 26 |
#include "gamecfgwidget.h" |
347 | 27 |
#include "teamselect.h" |
315 | 28 |
|
1082 | 29 |
char delimeter='\n'; |
315 | 30 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
31 |
HWNewNet::HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget) : |
334 | 32 |
config(config), |
33 |
m_pGameCFGWidget(pGameCFGWidget), |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
34 |
m_pTeamSelWidget(pTeamSelWidget), |
383 | 35 |
isChief(false), |
36 |
m_game_connected(false) |
|
315 | 37 |
{ |
38 |
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
|
39 |
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); |
|
40 |
connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); |
|
41 |
connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, |
|
42 |
SLOT(displayError(QAbstractSocket::SocketError))); |
|
43 |
} |
|
44 |
||
45 |
void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
|
46 |
{ |
|
655
e58a77556878
- Temporary set delimiter to *, as \t seems to be endline now in Qt
unc0rr
parents:
574
diff
changeset
|
47 |
mynick = nick; |
315 | 48 |
NetSocket.connectToHost(hostName, port); |
49 |
} |
|
50 |
||
51 |
void HWNewNet::Disconnect() |
|
52 |
{ |
|
407 | 53 |
m_game_connected=false; |
383 | 54 |
NetSocket.disconnectFromHost(); |
315 | 55 |
} |
56 |
||
1082 | 57 |
void HWNewNet::CreateRoom(const QString & room) |
315 | 58 |
{ |
1082 | 59 |
RawSendNet(QString("CREATE%1%2").arg(delimeter).arg(room)); |
60 |
} |
|
61 |
||
62 |
void HWNewNet::JoinRoom(const QString & room) |
|
63 |
{ |
|
64 |
RawSendNet(QString("JOIN%1%2").arg(delimeter).arg(room)); |
|
315 | 65 |
} |
66 |
||
67 |
void HWNewNet::AddTeam(const HWTeam & team) |
|
68 |
{ |
|
69 |
RawSendNet(QString("ADDTEAM:") + delimeter + |
|
382
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
70 |
team.TeamName + delimeter + |
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
71 |
team.teamColor.name() + delimeter + |
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
72 |
team.Grave + delimeter + |
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
73 |
team.Fort + delimeter + |
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
74 |
QString::number(team.difficulty) + delimeter + |
382
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
75 |
team.HHName[0] + delimeter + team.HHName[1] + delimeter + |
315 | 76 |
team.HHName[2] + delimeter + team.HHName[3] + delimeter + team.HHName[4] + delimeter + |
77 |
team.HHName[5] + delimeter + team.HHName[6] + delimeter + team.HHName[7]); |
|
78 |
} |
|
79 |
||
347 | 80 |
void HWNewNet::RemoveTeam(const HWTeam & team) |
81 |
{ |
|
82 |
RawSendNet(QString("REMOVETEAM:") + delimeter + team.TeamName); |
|
401 | 83 |
m_networkToLocalteams.remove(m_networkToLocalteams.key(team.TeamName)); |
347 | 84 |
} |
85 |
||
315 | 86 |
void HWNewNet::StartGame() |
87 |
{ |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
88 |
RawSendNet(QString("START:")); |
315 | 89 |
} |
90 |
||
91 |
void HWNewNet::SendNet(const QByteArray & buf) |
|
92 |
{ |
|
93 |
QString msg = QString(buf.toBase64()); |
|
94 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
95 |
RawSendNet(QString("GAMEMSG:%1%2").arg(delimeter).arg(msg)); |
315 | 96 |
} |
97 |
||
98 |
void HWNewNet::RawSendNet(const QString & str) |
|
99 |
{ |
|
100 |
RawSendNet(str.toUtf8()); |
|
101 |
} |
|
102 |
||
103 |
void HWNewNet::RawSendNet(const QByteArray & buf) |
|
104 |
{ |
|
1081
5be338fa4e2c
First steps to switch hedgewars to new net protocol
unc0rr
parents:
1066
diff
changeset
|
105 |
qDebug() << "Client: " << buf; |
315 | 106 |
NetSocket.write(buf); |
1082 | 107 |
NetSocket.write("\n\n", 2); |
315 | 108 |
} |
109 |
||
110 |
void HWNewNet::ClientRead() |
|
111 |
{ |
|
1082 | 112 |
while (NetSocket.canReadLine()) { |
113 |
QString s = QString::fromUtf8(NetSocket.readLine().trimmed()); |
|
114 |
||
115 |
if (s.size() == 0) { |
|
116 |
ParseCmd(cmdbuf); |
|
117 |
cmdbuf.clear(); |
|
118 |
} else |
|
119 |
cmdbuf << s; |
|
120 |
} |
|
315 | 121 |
} |
122 |
||
123 |
void HWNewNet::OnConnect() |
|
124 |
{ |
|
125 |
RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
|
1082 | 126 |
RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); |
127 |
RawSendNet(QString("CREATE%1%2").arg(delimeter).arg("myroom")); |
|
315 | 128 |
} |
129 |
||
130 |
void HWNewNet::OnDisconnect() |
|
131 |
{ |
|
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
132 |
//emit ChangeInTeams(QStringList()); |
383 | 133 |
if(m_game_connected) emit Disconnected(); |
134 |
m_game_connected=false; |
|
315 | 135 |
} |
136 |
||
137 |
void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
|
138 |
{ |
|
139 |
switch (socketError) { |
|
140 |
case QAbstractSocket::RemoteHostClosedError: |
|
141 |
break; |
|
142 |
case QAbstractSocket::HostNotFoundError: |
|
143 |
QMessageBox::information(0, tr("Error"), |
|
144 |
tr("The host was not found. Please check the host name and port settings.")); |
|
145 |
break; |
|
146 |
case QAbstractSocket::ConnectionRefusedError: |
|
147 |
QMessageBox::information(0, tr("Error"), |
|
148 |
tr("Connection refused")); |
|
149 |
break; |
|
150 |
default: |
|
151 |
QMessageBox::information(0, tr("Error"), |
|
152 |
NetSocket.errorString()); |
|
153 |
} |
|
154 |
} |
|
155 |
||
1082 | 156 |
void HWNewNet::ParseCmd(const QStringList & lst) |
315 | 157 |
{ |
1082 | 158 |
qDebug() << "Server: " << lst; |
320 | 159 |
|
1082 | 160 |
if(!lst.size()) |
161 |
{ |
|
162 |
qWarning("Net client: Bad message"); |
|
163 |
return; |
|
164 |
} |
|
165 |
||
315 | 166 |
if (lst[0] == "ERRONEUSNICKNAME") { |
167 |
QMessageBox::information(0, 0, "Your net nickname is in use or cannot be used"); |
|
168 |
return; |
|
169 |
} |
|
170 |
||
171 |
if (lst[0] == "CONNECTED") { |
|
383 | 172 |
m_game_connected=true; |
315 | 173 |
emit Connected(); |
174 |
emit EnteredGame(); |
|
175 |
return; |
|
176 |
} |
|
177 |
||
453 | 178 |
if (lst[0] == "CHAT_STRING") { |
1082 | 179 |
if(lst.size() < 3) |
573 | 180 |
{ |
181 |
qWarning("Net: Empty CHAT_STRING message"); |
|
182 |
return; |
|
183 |
} |
|
1082 | 184 |
QStringList tmp = lst; |
185 |
tmp.removeFirst(); |
|
186 |
emit chatStringFromNet(tmp); |
|
453 | 187 |
return; |
188 |
} |
|
189 |
||
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
190 |
if (lst[0] == "ADDTEAM:") { |
574 | 191 |
if(lst.size() < 14) |
192 |
{ |
|
193 |
qWarning("Net: Too short ADDTEAM message"); |
|
194 |
return; |
|
195 |
} |
|
1082 | 196 |
QStringList tmp = lst; |
197 |
tmp.removeFirst(); |
|
198 |
emit AddNetTeam(tmp); |
|
315 | 199 |
return; |
200 |
} |
|
201 |
||
347 | 202 |
if (lst[0] == "REMOVETEAM:") { |
573 | 203 |
if(lst.size() < 3) |
204 |
{ |
|
205 |
qWarning("Net: Bad REMOVETEAM message"); |
|
206 |
return; |
|
207 |
} |
|
352 | 208 |
m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt())); |
347 | 209 |
return; |
210 |
} |
|
211 |
||
349 | 212 |
if(lst[0]=="SLAVE") { |
213 |
m_pGameCFGWidget->setEnabled(false); |
|
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
356
diff
changeset
|
214 |
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
|
215 |
return; |
349 | 216 |
} |
217 |
||
455 | 218 |
if(lst[0]=="JOINED") { |
573 | 219 |
if(lst.size() < 2) |
220 |
{ |
|
221 |
qWarning("Net: Bad JOINED message"); |
|
222 |
return; |
|
223 |
} |
|
465 | 224 |
emit nickAdded(lst[1]); |
455 | 225 |
return; |
226 |
} |
|
227 |
||
461 | 228 |
if(lst[0]=="LEFT") { |
573 | 229 |
if(lst.size() < 2) |
230 |
{ |
|
231 |
qWarning("Net: Bad LEFT message"); |
|
232 |
return; |
|
233 |
} |
|
465 | 234 |
emit nickRemoved(lst[1]); |
461 | 235 |
return; |
236 |
} |
|
237 |
||
315 | 238 |
if (lst[0] == "CONFIGASKED") { |
334 | 239 |
isChief=true; |
315 | 240 |
ConfigAsked(); |
241 |
return; |
|
242 |
} |
|
320 | 243 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
244 |
if (lst[0] == "RUNGAME") { |
396 | 245 |
RunGame(); |
246 |
return; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
247 |
} |
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
248 |
|
315 | 249 |
if (lst[0] == "CONFIGURED") { |
1082 | 250 |
QStringList tmp = lst; |
251 |
tmp.removeFirst(); |
|
252 |
if(tmp.size() < 6) |
|
573 | 253 |
{ |
254 |
qWarning("Net: Bad CONFIGURED message"); |
|
255 |
return; |
|
256 |
} |
|
1082 | 257 |
emit seedChanged(tmp[0]); |
258 |
emit mapChanged(tmp[1]); |
|
259 |
emit themeChanged(tmp[2]); |
|
260 |
emit initHealthChanged(tmp[3].toUInt()); |
|
261 |
emit turnTimeChanged(tmp[4].toUInt()); |
|
262 |
emit fortsModeChanged(tmp[5].toInt() != 0); |
|
315 | 263 |
return; |
264 |
} |
|
265 |
||
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
266 |
if(lst[0]=="TEAM_ACCEPTED") { |
573 | 267 |
if(lst.size() < 3) |
268 |
{ |
|
269 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
|
270 |
return; |
|
271 |
} |
|
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
272 |
m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]); |
373 | 273 |
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
|
274 |
return; |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
275 |
} |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
276 |
|
329
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[0] == "CONFIG_PARAM") { |
573 | 278 |
if(lst.size() < 3) |
279 |
{ |
|
280 |
qWarning("Net: Bad CONFIG_PARAM message"); |
|
281 |
return; |
|
282 |
} |
|
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 |
if (lst[1] == "SEED") { |
332 | 284 |
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
|
285 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
286 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
287 |
if (lst[1] == "MAP") { |
332 | 288 |
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
|
289 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
290 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
291 |
if (lst[1] == "THEME") { |
332 | 292 |
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
|
293 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
294 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
295 |
if (lst[1] == "HEALTH") { |
332 | 296 |
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
|
297 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
298 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
299 |
if (lst[1] == "TURNTIME") { |
332 | 300 |
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
|
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 |
if (lst[1] == "FORTSMODE") { |
332 | 304 |
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
|
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 |
} |
697 | 307 |
if (lst[1] == "AMMO") { |
703 | 308 |
if(lst.size() < 4) return; |
309 |
emit ammoChanged(lst[3], lst[2]); |
|
697 | 310 |
return; |
311 |
} |
|
401 | 312 |
QStringList hhTmpList=lst[1].split('+'); |
313 |
if (hhTmpList[0] == "TEAM_COLOR") { |
|
314 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
|
315 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
316 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
372 | 317 |
} |
401 | 318 |
tmptm.teamColor=QColor(lst[2]); |
372 | 319 |
emit teamColorChanged(tmptm); |
320 |
return; |
|
321 |
} |
|
401 | 322 |
if (hhTmpList[0] == "HHNUM") { |
399 | 323 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
324 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
325 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
326 |
} |
|
327 |
tmptm.numHedgehogs=lst[2].toUInt(); |
|
328 |
emit hhnumChanged(tmptm); |
|
329 |
return; |
|
330 |
} |
|
1082 | 331 |
qWarning() << "Net: Unknown 'CONFIG_PARAM' message:" << lst; |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
332 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
333 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
334 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
335 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
336 |
// 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
|
337 |
// "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
|
338 |
if (lst[0] == "GAMEMSG:") { |
573 | 339 |
if(lst.size() < 2) |
340 |
{ |
|
341 |
qWarning("Net: Bad LEFT message"); |
|
342 |
return; |
|
343 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
344 |
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
|
345 |
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
|
346 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
347 |
} |
573 | 348 |
|
1082 | 349 |
qWarning() << "Net: Unknown message:" << lst; |
315 | 350 |
} |
351 |
||
352 |
||
353 |
void HWNewNet::ConfigAsked() |
|
354 |
{ |
|
574 | 355 |
QString map = m_pGameCFGWidget->getCurrentMap(); |
356 |
if (map.size()) |
|
357 |
onMapChanged(map); |
|
358 |
||
335 | 359 |
onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
360 |
onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
|
361 |
onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
|
362 |
onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
|
444 | 363 |
onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
697 | 364 |
// always initialize with default ammo (also avoiding complicated cross-class dependencies) |
703 | 365 |
onWeaponsNameChanged("Default", cDefaultAmmoStore->mid(10)); |
315 | 366 |
} |
367 |
||
368 |
void HWNewNet::RunGame() |
|
369 |
{ |
|
660 | 370 |
emit AskForRunGame(); |
431 | 371 |
} |
372 |
||
352 | 373 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
374 |
{ |
|
455 | 375 |
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
|
376 |
.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
|
377 |
.arg(team.numHedgehogs)); |
352 | 378 |
} |
379 |
||
372 | 380 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
381 |
{ |
|
401 | 382 |
RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\ |
372 | 383 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
384 |
.arg(team.teamColor.name())); |
|
385 |
} |
|
386 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
387 |
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
|
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 |
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
|
390 |
} |
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 |
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
|
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 |
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
|
395 |
} |
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 |
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
|
398 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
399 |
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
|
400 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
401 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
402 |
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
|
403 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
404 |
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
|
405 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
406 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
407 |
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
|
408 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
409 |
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
|
410 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
411 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
412 |
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
|
413 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
414 |
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
|
415 |
} |
453 | 416 |
|
703 | 417 |
void HWNewNet::onWeaponsNameChanged(const QString& name, const QString& ammo) |
697 | 418 |
{ |
703 | 419 |
RawSendNet(QString("CONFIG_PARAM%1AMMO%1%2%1%3").arg(delimeter).arg(ammo).arg(name)); |
697 | 420 |
} |
421 |
||
453 | 422 |
void HWNewNet::chatLineToNet(const QString& str) |
423 |
{ |
|
424 |
if(str!="") { |
|
425 |
RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str); |
|
426 |
emit(chatStringFromNet(QStringList(mynick) << str)); |
|
427 |
} |
|
428 |
} |