author | unc0rr |
Sat, 06 Dec 2008 11:53:50 +0000 | |
changeset 1541 | 61b3b32aede8 |
parent 1530 | 3b8d723661b2 |
child 1558 | 3370b7ffeb5c |
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> |
|
1189
f66cdbbfc4b6
Fix compile under Ubuntu (why it compiles everywhere else?)
unc0rr
parents:
1083
diff
changeset
|
20 |
#include <QDebug> |
315 | 21 |
|
697 | 22 |
#include "hwconsts.h" |
315 | 23 |
#include "newnetclient.h" |
24 |
#include "proto.h" |
|
25 |
#include "gameuiconfig.h" |
|
26 |
#include "game.h" |
|
334 | 27 |
#include "gamecfgwidget.h" |
347 | 28 |
#include "teamselect.h" |
315 | 29 |
|
1082 | 30 |
char delimeter='\n'; |
315 | 31 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
32 |
HWNewNet::HWNewNet(GameUIConfig * config, GameCFGWidget* pGameCFGWidget, TeamSelWidget* pTeamSelWidget) : |
334 | 33 |
config(config), |
34 |
m_pGameCFGWidget(pGameCFGWidget), |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
35 |
m_pTeamSelWidget(pTeamSelWidget), |
383 | 36 |
isChief(false), |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
37 |
m_game_connected(false), |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
38 |
loginStep(0), |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
39 |
netClientState(0) |
315 | 40 |
{ |
1418 | 41 |
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
42 |
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); |
|
43 |
connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); |
|
44 |
connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, |
|
45 |
SLOT(displayError(QAbstractSocket::SocketError))); |
|
315 | 46 |
} |
47 |
||
1526
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
48 |
HWNewNet::~HWNewNet() |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
49 |
{ |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
50 |
if (m_game_connected) |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
51 |
RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
52 |
NetSocket.flush(); |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
53 |
} |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
54 |
|
315 | 55 |
void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
56 |
{ |
|
1418 | 57 |
mynick = nick; |
58 |
NetSocket.connectToHost(hostName, port); |
|
315 | 59 |
} |
60 |
||
61 |
void HWNewNet::Disconnect() |
|
62 |
{ |
|
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1351
diff
changeset
|
63 |
if (m_game_connected) |
1526
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
64 |
RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1351
diff
changeset
|
65 |
m_game_connected = false; |
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1351
diff
changeset
|
66 |
NetSocket.disconnectFromHost(); |
315 | 67 |
} |
68 |
||
1082 | 69 |
void HWNewNet::CreateRoom(const QString & room) |
315 | 70 |
{ |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
71 |
if(netClientState != 2) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
72 |
{ |
1321 | 73 |
qWarning("Illegal try to create room!"); |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
74 |
return; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
75 |
} |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
76 |
|
1082 | 77 |
RawSendNet(QString("CREATE%1%2").arg(delimeter).arg(room)); |
1336
4e88eccbe7f6
Fix team colors mismatch on some conditions (just synchronize them when team is added)
unc0rr
parents:
1333
diff
changeset
|
78 |
m_pGameCFGWidget->setEnabled(true); |
1475
bab5650fc894
- Fix ConfigAsked not sending full config (leads to team divide checkbox inconsistency)
unc0rr
parents:
1471
diff
changeset
|
79 |
m_pTeamSelWidget->setInteractivity(true); |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
80 |
isChief = true; |
1082 | 81 |
} |
82 |
||
83 |
void HWNewNet::JoinRoom(const QString & room) |
|
84 |
{ |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
85 |
if(netClientState != 2) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
86 |
{ |
1321 | 87 |
qWarning("Illegal try to join room!"); |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
88 |
return; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
89 |
} |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
90 |
|
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
91 |
loginStep++; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
92 |
|
1082 | 93 |
RawSendNet(QString("JOIN%1%2").arg(delimeter).arg(room)); |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
94 |
m_pGameCFGWidget->setEnabled(false); |
1475
bab5650fc894
- Fix ConfigAsked not sending full config (leads to team divide checkbox inconsistency)
unc0rr
parents:
1471
diff
changeset
|
95 |
m_pTeamSelWidget->setInteractivity(false); |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
96 |
isChief = false; |
315 | 97 |
} |
98 |
||
99 |
void HWNewNet::AddTeam(const HWTeam & team) |
|
100 |
{ |
|
1327 | 101 |
QString cmd = QString("ADD_TEAM") + delimeter + |
382
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
102 |
team.TeamName + delimeter + |
e7220e48ead1
colors changing config fully working (still need disabling in slaves)
displacer
parents:
373
diff
changeset
|
103 |
team.teamColor.name() + delimeter + |
443
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
104 |
team.Grave + delimeter + |
eec37eb7f5db
fort, grave and difficulty information for net team
displacer
parents:
431
diff
changeset
|
105 |
team.Fort + delimeter + |
1245
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
106 |
QString::number(team.difficulty); |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
107 |
|
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
108 |
for(int i = 0; i < 8; ++i) |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
109 |
{ |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
110 |
cmd.append(delimeter); |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
111 |
cmd.append(team.HHName[i]); |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
112 |
cmd.append(delimeter); |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
113 |
cmd.append(team.HHHat[i]); |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
114 |
} |
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
115 |
RawSendNet(cmd); |
315 | 116 |
} |
117 |
||
347 | 118 |
void HWNewNet::RemoveTeam(const HWTeam & team) |
119 |
{ |
|
1329 | 120 |
RawSendNet(QString("REMOVE_TEAM") + delimeter + team.TeamName); |
347 | 121 |
} |
122 |
||
1404 | 123 |
void HWNewNet::ToggleReady() |
315 | 124 |
{ |
1404 | 125 |
RawSendNet(QString("TOGGLE_READY")); |
315 | 126 |
} |
127 |
||
128 |
void HWNewNet::SendNet(const QByteArray & buf) |
|
129 |
{ |
|
130 |
QString msg = QString(buf.toBase64()); |
|
131 |
||
1311 | 132 |
RawSendNet(QString("GAMEMSG%1%2").arg(delimeter).arg(msg)); |
315 | 133 |
} |
134 |
||
135 |
void HWNewNet::RawSendNet(const QString & str) |
|
136 |
{ |
|
137 |
RawSendNet(str.toUtf8()); |
|
138 |
} |
|
139 |
||
140 |
void HWNewNet::RawSendNet(const QByteArray & buf) |
|
141 |
{ |
|
1369 | 142 |
//qDebug() << "Client: " << QString(buf).split("\n"); |
143 |
NetSocket.write(buf); |
|
144 |
NetSocket.write("\n\n", 2); |
|
315 | 145 |
} |
146 |
||
147 |
void HWNewNet::ClientRead() |
|
148 |
{ |
|
1082 | 149 |
while (NetSocket.canReadLine()) { |
150 |
QString s = QString::fromUtf8(NetSocket.readLine().trimmed()); |
|
151 |
||
152 |
if (s.size() == 0) { |
|
153 |
ParseCmd(cmdbuf); |
|
154 |
cmdbuf.clear(); |
|
155 |
} else |
|
156 |
cmdbuf << s; |
|
157 |
} |
|
315 | 158 |
} |
159 |
||
160 |
void HWNewNet::OnConnect() |
|
161 |
{ |
|
162 |
} |
|
163 |
||
164 |
void HWNewNet::OnDisconnect() |
|
165 |
{ |
|
338
d1e75dcd285f
multiple teams now available per host (still alpha)
displacer
parents:
335
diff
changeset
|
166 |
//emit ChangeInTeams(QStringList()); |
383 | 167 |
if(m_game_connected) emit Disconnected(); |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1351
diff
changeset
|
168 |
m_game_connected = false; |
315 | 169 |
} |
170 |
||
171 |
void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
|
172 |
{ |
|
1302 | 173 |
switch (socketError) { |
174 |
case QAbstractSocket::RemoteHostClosedError: |
|
175 |
break; |
|
176 |
case QAbstractSocket::HostNotFoundError: |
|
177 |
QMessageBox::information(0, tr("Error"), |
|
178 |
tr("The host was not found. Please check the host name and port settings.")); |
|
179 |
break; |
|
180 |
case QAbstractSocket::ConnectionRefusedError: |
|
181 |
QMessageBox::information(0, tr("Error"), |
|
182 |
tr("Connection refused")); |
|
183 |
break; |
|
184 |
default: |
|
185 |
QMessageBox::information(0, tr("Error"), |
|
186 |
NetSocket.errorString()); |
|
187 |
} |
|
315 | 188 |
} |
189 |
||
1082 | 190 |
void HWNewNet::ParseCmd(const QStringList & lst) |
315 | 191 |
{ |
1385 | 192 |
//qDebug() << "Server: " << lst; |
1305 | 193 |
|
194 |
if(!lst.size()) |
|
195 |
{ |
|
196 |
qWarning("Net client: Bad message"); |
|
197 |
return; |
|
198 |
} |
|
320 | 199 |
|
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
200 |
if ((lst[0] == "NICK") || (lst[0] == "PROTO")) |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
201 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
202 |
loginStep++; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
203 |
if (loginStep == 2) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
204 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
205 |
netClientState = 2; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
206 |
RawSendNet(QString("LIST")); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
207 |
} |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
208 |
return ; |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
209 |
} |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
210 |
|
1305 | 211 |
if (lst[0] == "ERROR") { |
212 |
if (lst.size() == 2) |
|
1307 | 213 |
QMessageBox::information(0, 0, "Error: " + lst[1]); |
1305 | 214 |
else |
215 |
QMessageBox::information(0, 0, "Unknown error"); |
|
216 |
return; |
|
217 |
} |
|
315 | 218 |
|
1307 | 219 |
if (lst[0] == "WARNING") { |
220 |
if (lst.size() == 2) |
|
221 |
QMessageBox::information(0, 0, "Warning: " + lst[1]); |
|
222 |
else |
|
223 |
QMessageBox::information(0, 0, "Unknown warning"); |
|
224 |
return; |
|
225 |
} |
|
226 |
||
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
227 |
if (lst[0] == "CONNECTED") { |
1471 | 228 |
RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); |
229 |
RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
230 |
netClientState = 1; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
231 |
m_game_connected = true; |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
232 |
emit Connected(); |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
233 |
return; |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
234 |
} |
315 | 235 |
|
1462 | 236 |
if (lst[0] == "PING") { |
237 |
RawSendNet(QString("PONG")); |
|
238 |
return; |
|
239 |
} |
|
240 |
||
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
241 |
if (lst[0] == "ROOMS") { |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
242 |
QStringList tmp = lst; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
243 |
tmp.removeFirst(); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
244 |
emit roomsList(tmp); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
245 |
return; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
246 |
} |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
247 |
|
1377 | 248 |
if (lst[0] == "SERVER_MESSAGE") { |
249 |
if(lst.size() < 2) |
|
250 |
{ |
|
251 |
qWarning("Net: Empty SERVERMESSAGE message"); |
|
252 |
return; |
|
253 |
} |
|
254 |
emit serverMessage(lst[1]); |
|
255 |
return; |
|
256 |
} |
|
257 |
||
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
258 |
if (lst[0] == "CHAT_STRING") { |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
259 |
if(lst.size() < 3) |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
260 |
{ |
1377 | 261 |
qWarning("Net: Empty CHAT_STRING message"); |
262 |
return; |
|
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
263 |
} |
1378 | 264 |
emit chatStringFromNet(formatChatMsg(lst[1], lst[2])); |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
265 |
return; |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
266 |
} |
453 | 267 |
|
1405 | 268 |
if (lst[0] == "READY") { |
269 |
if(lst.size() != 2) |
|
270 |
{ |
|
271 |
qWarning("Net: Malformed READY message"); |
|
272 |
return; |
|
273 |
} |
|
274 |
emit setReadyStatus(lst[1], true); |
|
275 |
return; |
|
276 |
} |
|
277 |
if (lst[0] == "NOT_READY") { |
|
278 |
if(lst.size() != 2) |
|
279 |
{ |
|
280 |
qWarning("Net: Malformed NOT_READY message"); |
|
281 |
return; |
|
282 |
} |
|
283 |
emit setReadyStatus(lst[1], false); |
|
284 |
return; |
|
285 |
} |
|
286 |
||
1325 | 287 |
if (lst[0] == "ADD_TEAM") { |
288 |
if(lst.size() != 21) |
|
1321 | 289 |
{ |
1325 | 290 |
qWarning("Net: Bad ADDTEAM message"); |
1321 | 291 |
return; |
292 |
} |
|
293 |
QStringList tmp = lst; |
|
294 |
tmp.removeFirst(); |
|
295 |
emit AddNetTeam(tmp); |
|
296 |
return; |
|
297 |
} |
|
315 | 298 |
|
1338 | 299 |
if (lst[0] == "REMOVE_TEAM") { |
300 |
if(lst.size() != 2) |
|
301 |
{ |
|
302 |
qWarning("Net: Bad REMOVETEAM message"); |
|
303 |
return; |
|
304 |
} |
|
305 |
m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1])); |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
306 |
if (netClientState == 5) // we're in game, need to tell the engine about this |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
307 |
{ |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
308 |
QByteArray em; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
309 |
HWProto::addStringToBuffer(em, "F" + lst[1]); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
310 |
emit FromNet(em); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
311 |
} |
1338 | 312 |
return; |
313 |
} |
|
347 | 314 |
|
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
315 |
if(lst[0]=="JOINED") { |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
316 |
if(lst.size() < 2) |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
317 |
{ |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
318 |
qWarning("Net: Bad JOINED message"); |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
319 |
return; |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
320 |
} |
1311 | 321 |
|
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
322 |
for(int i = 1; i < lst.size(); ++i) |
1311 | 323 |
{ |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
324 |
if (lst[i] == mynick) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
325 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
326 |
netClientState = 3; |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
327 |
emit EnteredGame(); |
1316 | 328 |
if (isChief) |
329 |
ConfigAsked(); |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
330 |
} |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
331 |
emit nickAdded(lst[i]); |
1378 | 332 |
emit chatStringFromNet(QString(tr("*** %1 joined")).arg(lst[i])); |
1311 | 333 |
} |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
334 |
return; |
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
335 |
} |
455 | 336 |
|
1325 | 337 |
if(lst[0] == "LEFT") { |
1310 | 338 |
if(lst.size() < 2) |
339 |
{ |
|
340 |
qWarning("Net: Bad LEFT message"); |
|
341 |
return; |
|
342 |
} |
|
343 |
emit nickRemoved(lst[1]); |
|
1512
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
344 |
if (lst.size() < 3) |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
345 |
emit chatStringFromNet(QString(tr("*** %1 left")).arg(lst[1])); |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
346 |
else |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
347 |
emit chatStringFromNet(QString(tr("*** %1 left (%2)")).arg(lst[1], lst[2])); |
1310 | 348 |
return; |
349 |
} |
|
461 | 350 |
|
1338 | 351 |
if (lst[0] == "RUN_GAME") { |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
352 |
netClientState = 5; |
1325 | 353 |
RunGame(); |
354 |
return; |
|
355 |
} |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
356 |
|
1325 | 357 |
if (lst[0] == "TEAM_ACCEPTED") { |
358 |
if (lst.size() != 2) |
|
359 |
{ |
|
360 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
|
361 |
return; |
|
362 |
} |
|
363 |
m_pTeamSelWidget->changeTeamStatus(lst[1]); |
|
364 |
return; |
|
365 |
} |
|
354
60e4af0a4375
network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents:
352
diff
changeset
|
366 |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
367 |
if (lst[0] == "MAP") { |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
368 |
if (lst.size() != 2) |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
369 |
{ |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
370 |
qWarning("Net: Bad MAP message"); |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
371 |
return; |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
372 |
} |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
373 |
emit mapChanged(lst[1]); |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
374 |
return; |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
375 |
} |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
376 |
|
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1330
diff
changeset
|
377 |
|
1319 | 378 |
if (lst[0] == "CONFIG_PARAM") { |
379 |
if(lst.size() < 3) |
|
380 |
{ |
|
381 |
qWarning("Net: Bad CONFIG_PARAM message"); |
|
382 |
return; |
|
383 |
} |
|
384 |
if (lst[1] == "SEED") { |
|
385 |
emit seedChanged(lst[2]); |
|
386 |
return; |
|
387 |
} |
|
388 |
if (lst[1] == "THEME") { |
|
389 |
emit themeChanged(lst[2]); |
|
390 |
return; |
|
391 |
} |
|
392 |
if (lst[1] == "HEALTH") { |
|
393 |
emit initHealthChanged(lst[2].toUInt()); |
|
394 |
return; |
|
395 |
} |
|
396 |
if (lst[1] == "TURNTIME") { |
|
397 |
emit turnTimeChanged(lst[2].toUInt()); |
|
398 |
return; |
|
399 |
} |
|
400 |
if (lst[1] == "FORTSMODE") { |
|
401 |
emit fortsModeChanged(lst[2].toInt() != 0); |
|
402 |
return; |
|
403 |
} |
|
1427 | 404 |
if (lst[1] == "DIVIDETEAMS") { |
405 |
emit teamsDivideChanged(lst[2].toInt() != 0); |
|
406 |
return; |
|
407 |
} |
|
1530 | 408 |
if (lst[1] == "SOLIDLAND") { |
409 |
emit solidChanged(lst[2].toInt() != 0); |
|
410 |
return; |
|
411 |
} |
|
1319 | 412 |
if (lst[1] == "AMMO") { |
413 |
if(lst.size() < 4) return; |
|
414 |
emit ammoChanged(lst[3], lst[2]); |
|
415 |
return; |
|
416 |
} |
|
417 |
qWarning() << "Net: Unknown 'CONFIG_PARAM' message:" << lst; |
|
418 |
return; |
|
697 | 419 |
} |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
420 |
|
1327 | 421 |
if (lst[0] == "HH_NUM") { |
422 |
if (lst.size() != 3) |
|
423 |
{ |
|
424 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
|
425 |
return; |
|
426 |
} |
|
427 |
HWTeam tmptm(lst[1]); |
|
428 |
tmptm.numHedgehogs = lst[2].toUInt(); |
|
429 |
emit hhnumChanged(tmptm); |
|
430 |
return; |
|
431 |
} |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
432 |
|
1330 | 433 |
if (lst[0] == "TEAM_COLOR") { |
434 |
if (lst.size() != 3) |
|
435 |
{ |
|
436 |
qWarning("Net: Bad TEAM_COLOR message"); |
|
437 |
return; |
|
438 |
} |
|
439 |
HWTeam tmptm(lst[1]); |
|
440 |
tmptm.teamColor = QColor(lst[2]); |
|
441 |
emit teamColorChanged(tmptm); |
|
442 |
return; |
|
443 |
} |
|
444 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
445 |
if (lst[0] == "GAMEMSG") { |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
446 |
if(lst.size() < 2) |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
447 |
{ |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
448 |
qWarning("Net: Bad GAMEMSG message"); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
449 |
return; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
450 |
} |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
451 |
QByteArray em = QByteArray::fromBase64(lst[1].toAscii()); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
452 |
emit FromNet(em); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
453 |
return; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
454 |
} |
573 | 455 |
|
1512
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
456 |
if (lst[0] == "BYE") { |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
457 |
if (lst.size() < 2) |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
458 |
{ |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
459 |
qWarning("Net: Bad BYE message"); |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
460 |
return; |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
461 |
} |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
462 |
emit showMessage(HWNewNet::tr("Quit reason: ") + lst[1]); |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
463 |
return; |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
464 |
} |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
465 |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
466 |
qWarning() << "Net: Unknown message:" << lst; |
315 | 467 |
} |
468 |
||
469 |
||
470 |
void HWNewNet::ConfigAsked() |
|
471 |
{ |
|
1310 | 472 |
QString map = m_pGameCFGWidget->getCurrentMap(); |
473 |
if (map.size()) |
|
474 |
onMapChanged(map); |
|
574 | 475 |
|
1310 | 476 |
onSeedChanged(m_pGameCFGWidget->getCurrentSeed()); |
477 |
onThemeChanged(m_pGameCFGWidget->getCurrentTheme()); |
|
478 |
onInitHealthChanged(m_pGameCFGWidget->getInitHealth()); |
|
479 |
onTurnTimeChanged(m_pGameCFGWidget->getTurnTime()); |
|
480 |
onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1); |
|
1475
bab5650fc894
- Fix ConfigAsked not sending full config (leads to team divide checkbox inconsistency)
unc0rr
parents:
1471
diff
changeset
|
481 |
onTeamsDivideChanged(m_pGameCFGWidget->getGameFlags() & 0x10); |
1530 | 482 |
onSolidChanged(m_pGameCFGWidget->getGameFlags() & 0x04); |
1310 | 483 |
// always initialize with default ammo (also avoiding complicated cross-class dependencies) |
1541 | 484 |
QString name = m_pGameCFGWidget->WeaponsName->currentText(); |
485 |
QString ammo = m_pGameCFGWidget->WeaponsName->itemData( |
|
486 |
m_pGameCFGWidget->WeaponsName->currentIndex() |
|
487 |
).toString(); |
|
488 |
onWeaponsNameChanged(name, ammo); |
|
315 | 489 |
} |
490 |
||
491 |
void HWNewNet::RunGame() |
|
492 |
{ |
|
1310 | 493 |
emit AskForRunGame(); |
431 | 494 |
} |
495 |
||
352 | 496 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
497 |
{ |
|
1330 | 498 |
if (isChief) |
1327 | 499 |
RawSendNet(QString("HH_NUM%1%2%1%3") |
1324 | 500 |
.arg(delimeter) |
501 |
.arg(team.TeamName) |
|
1321 | 502 |
.arg(team.numHedgehogs)); |
352 | 503 |
} |
504 |
||
372 | 505 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
506 |
{ |
|
1330 | 507 |
if (isChief) |
508 |
RawSendNet(QString("TEAM_COLOR%1%2%1%3") |
|
1324 | 509 |
.arg(delimeter) |
510 |
.arg(team.TeamName) |
|
1321 | 511 |
.arg(team.teamColor.name())); |
372 | 512 |
} |
513 |
||
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
514 |
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
|
515 |
{ |
1530 | 516 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1SEED%1%2").arg(delimeter).arg(seed)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
517 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
518 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
519 |
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
|
520 |
{ |
1530 | 521 |
if (isChief) RawSendNet(QString("MAP%1%2").arg(delimeter).arg(map)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
522 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
523 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
524 |
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
|
525 |
{ |
1530 | 526 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1THEME%1%2").arg(delimeter).arg(theme)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
527 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
528 |
|
1427 | 529 |
void HWNewNet::onInitHealthChanged(int health) |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
530 |
{ |
1530 | 531 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1HEALTH%1%2").arg(delimeter).arg(health)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
532 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
533 |
|
1427 | 534 |
void HWNewNet::onTurnTimeChanged(int time) |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
535 |
{ |
1530 | 536 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1TURNTIME%1%2").arg(delimeter).arg(time)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
537 |
} |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
538 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
539 |
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
|
540 |
{ |
1530 | 541 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1FORTSMODE%1%2").arg(delimeter).arg(value)); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
322
diff
changeset
|
542 |
} |
453 | 543 |
|
1427 | 544 |
void HWNewNet::onTeamsDivideChanged(bool value) |
545 |
{ |
|
1530 | 546 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1DIVIDETEAMS%1%2").arg(delimeter).arg(value)); |
547 |
} |
|
548 |
||
549 |
void HWNewNet::onSolidChanged(bool value) |
|
550 |
{ |
|
551 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1SOLIDLAND%1%2").arg(delimeter).arg(value)); |
|
1427 | 552 |
} |
553 |
||
703 | 554 |
void HWNewNet::onWeaponsNameChanged(const QString& name, const QString& ammo) |
697 | 555 |
{ |
1530 | 556 |
if (isChief) RawSendNet(QString("CONFIG_PARAM%1AMMO%1%2%1%3").arg(delimeter).arg(ammo).arg(name)); |
697 | 557 |
} |
558 |
||
453 | 559 |
void HWNewNet::chatLineToNet(const QString& str) |
560 |
{ |
|
561 |
if(str!="") { |
|
1322
c624b04699fb
Fix protocol implementation to conform documentation
unc0rr
parents:
1321
diff
changeset
|
562 |
RawSendNet(QString("CHAT_STRING")+delimeter+str); |
1378 | 563 |
emit(chatStringFromMe(formatChatMsg(mynick, str))); |
453 | 564 |
} |
565 |
} |
|
1315 | 566 |
|
567 |
void HWNewNet::askRoomsList() |
|
568 |
{ |
|
569 |
if(netClientState != 2) |
|
570 |
{ |
|
1321 | 571 |
qWarning("Illegal try to get rooms list!"); |
1315 | 572 |
return; |
573 |
} |
|
574 |
RawSendNet(QString("LIST")); |
|
575 |
} |
|
1339 | 576 |
|
577 |
bool HWNewNet::isRoomChief() |
|
578 |
{ |
|
579 |
return isChief; |
|
580 |
} |
|
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
581 |
|
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
582 |
void HWNewNet::gameFinished() |
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
583 |
{ |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1344
diff
changeset
|
584 |
netClientState = 3; |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
585 |
RawSendNet(QString("ROUNDFINISHED")); |
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
586 |
} |
1378 | 587 |
|
588 |
QString HWNewNet::formatChatMsg(const QString & nick, const QString & msg) |
|
589 |
{ |
|
590 |
if(msg.left(4) == "/me ") |
|
591 |
return QString("* %1 %2").arg(nick).arg(msg.mid(4)); |
|
592 |
else |
|
593 |
return QString("%1: %2").arg(nick).arg(msg); |
|
594 |
} |
|
1391 | 595 |
|
596 |
void HWNewNet::kickPlayer(const QString & nick) |
|
597 |
{ |
|
598 |
RawSendNet(QString("KICK%1%2").arg(delimeter).arg(nick)); |
|
599 |
} |
|
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
600 |
|
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
601 |
void HWNewNet::startGame() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
602 |
{ |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
603 |
RawSendNet(QString("START_GAME")); |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
604 |
} |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
605 |
|
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
606 |
void HWNewNet::toggleRestrictJoins() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
607 |
{ |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
608 |
RawSendNet(QString("TOGGLE_RESTRICT_JOINS")); |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
609 |
} |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
610 |
|
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
611 |
void HWNewNet::toggleRestrictTeamAdds() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
612 |
{ |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
613 |
RawSendNet(QString("TOGGLE_RESTRICT_TEAMS")); |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
614 |
} |