author | unc0rr |
Wed, 21 Feb 2007 19:18:05 +0000 | |
changeset 470 | 86ca84d5da74 |
parent 468 | 8403d6884707 |
child 486 | 7ea71cd3acd5 |
permissions | -rw-r--r-- |
315 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2006 Ulyanov Igor <iulyanov@gmail.com> |
|
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(); |
|
162 |
if(lst.size() < 2) return; |
|
163 |
emit chatStringFromNet(lst); |
|
164 |
return; |
|
165 |
} |
|
166 |
||
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
167 |
if (lst[0] == "ADDTEAM:") { |
315 | 168 |
lst.pop_front(); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
169 |
emit AddNetTeam(lst); |
315 | 170 |
return; |
171 |
} |
|
172 |
||
347 | 173 |
if (lst[0] == "REMOVETEAM:") { |
352 | 174 |
if(lst.size()<3) return; |
175 |
m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt())); |
|
347 | 176 |
return; |
177 |
} |
|
178 |
||
349 | 179 |
if(lst[0]=="SLAVE") { |
180 |
m_pGameCFGWidget->setEnabled(false); |
|
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
356
diff
changeset
|
181 |
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
|
182 |
return; |
349 | 183 |
} |
184 |
||
455 | 185 |
if(lst[0]=="JOINED") { |
186 |
if(lst.size()<2) return; |
|
465 | 187 |
emit nickAdded(lst[1]); |
455 | 188 |
return; |
189 |
} |
|
190 |
||
461 | 191 |
if(lst[0]=="LEFT") { |
192 |
if(lst.size()<2) return; |
|
465 | 193 |
emit nickRemoved(lst[1]); |
461 | 194 |
return; |
195 |
} |
|
196 |
||
315 | 197 |
if (lst[0] == "CONFIGASKED") { |
334 | 198 |
isChief=true; |
315 | 199 |
ConfigAsked(); |
200 |
return; |
|
201 |
} |
|
320 | 202 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
203 |
if (lst[0] == "RUNGAME") { |
396 | 204 |
RunGame(); |
205 |
return; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
206 |
} |
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
207 |
|
315 | 208 |
if (lst[0] == "CONFIGURED") { |
209 |
lst.pop_front(); |
|
334 | 210 |
if(lst.size()<5) return; |
211 |
emit seedChanged(lst[0]); |
|
212 |
emit mapChanged(lst[1]); |
|
213 |
emit themeChanged(lst[2]); |
|
214 |
emit initHealthChanged(lst[3].toUInt()); |
|
215 |
emit turnTimeChanged(lst[4].toUInt()); |
|
444 | 216 |
emit fortsModeChanged(lst[5].toInt() != 0); |
315 | 217 |
return; |
218 |
} |
|
219 |
||
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
220 |
if(lst[0]=="TEAM_ACCEPTED") { |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
221 |
m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]); |
373 | 222 |
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
|
223 |
return; |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
224 |
} |
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
225 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
226 |
if (lst[0] == "CONFIG_PARAM") { |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
227 |
if (lst[1] == "SEED") { |
332 | 228 |
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
|
229 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
230 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
231 |
if (lst[1] == "MAP") { |
332 | 232 |
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
|
233 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
234 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
235 |
if (lst[1] == "THEME") { |
332 | 236 |
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
|
237 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
238 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
239 |
if (lst[1] == "HEALTH") { |
332 | 240 |
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
|
241 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
242 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
243 |
if (lst[1] == "TURNTIME") { |
332 | 244 |
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
|
245 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
246 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
247 |
if (lst[1] == "FORTSMODE") { |
332 | 248 |
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
|
249 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
250 |
} |
401 | 251 |
QStringList hhTmpList=lst[1].split('+'); |
252 |
if (hhTmpList[0] == "TEAM_COLOR") { |
|
253 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
|
254 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
255 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
372 | 256 |
} |
401 | 257 |
tmptm.teamColor=QColor(lst[2]); |
372 | 258 |
emit teamColorChanged(tmptm); |
259 |
return; |
|
260 |
} |
|
401 | 261 |
if (hhTmpList[0] == "HHNUM") { |
399 | 262 |
HWTeam tmptm(hhTmpList[1], hhTmpList[2].toUInt()); |
263 |
if(m_networkToLocalteams.find(hhTmpList[2].toUInt())!=m_networkToLocalteams.end()) { |
|
264 |
tmptm=HWTeam(hhTmpList[1]); // local team should be changed |
|
265 |
} |
|
266 |
tmptm.numHedgehogs=lst[2].toUInt(); |
|
267 |
emit hhnumChanged(tmptm); |
|
268 |
return; |
|
269 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
270 |
return; |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
271 |
} |
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 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
274 |
// 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
|
275 |
// "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
|
276 |
if (lst[0] == "GAMEMSG:") { |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
277 |
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
|
278 |
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
|
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 |
} |
315 | 281 |
} |
282 |
||
283 |
||
284 |
void HWNewNet::ConfigAsked() |
|
285 |
{ |
|
335 | 286 |
onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
287 |
onMapChanged(m_pGameCFGWidget->getCurrentMap()); |
|
288 |
onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
|
289 |
onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
|
290 |
onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
|
444 | 291 |
onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
315 | 292 |
} |
293 |
||
294 |
void HWNewNet::RunGame() |
|
295 |
{ |
|
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
296 |
HWGame* game = new HWGame(config, m_pGameCFGWidget, m_pTeamSelWidget); |
448 | 297 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SIGNAL(GameStateChanged(GameState))); |
315 | 298 |
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &))); |
299 |
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
|
431 | 300 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
315 | 301 |
game->StartNet(); |
302 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
303 |
|
431 | 304 |
void HWNewNet::ShowErrorMessage(const QString & msg) |
305 |
{ |
|
306 |
QMessageBox::warning(0, |
|
307 |
"Hedgewars", |
|
308 |
msg); |
|
309 |
} |
|
310 |
||
352 | 311 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
312 |
{ |
|
455 | 313 |
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
|
314 |
.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
|
315 |
.arg(team.numHedgehogs)); |
352 | 316 |
} |
317 |
||
372 | 318 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
319 |
{ |
|
401 | 320 |
RawSendNet(QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(team.TeamName)\ |
372 | 321 |
.arg(team.getNetID() ? team.getNetID() : m_networkToLocalteams.key(team.TeamName))\ |
322 |
.arg(team.teamColor.name())); |
|
323 |
} |
|
324 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
325 |
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
|
326 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
327 |
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
|
328 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
329 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
330 |
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
|
331 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
332 |
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
|
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 |
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
|
336 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
337 |
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
|
338 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
339 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
340 |
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
|
341 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
342 |
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
|
343 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
344 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
345 |
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
|
346 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
347 |
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
|
348 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
349 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
350 |
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
|
351 |
{ |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
352 |
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
|
353 |
} |
453 | 354 |
|
355 |
void HWNewNet::chatLineToNet(const QString& str) |
|
356 |
{ |
|
357 |
if(str!="") { |
|
358 |
RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str); |
|
359 |
emit(chatStringFromNet(QStringList(mynick) << str)); |
|
360 |
} |
|
361 |
} |