author | nemo |
Sun, 24 Mar 2024 14:34:27 -0400 | |
changeset 15996 | 19927b70588c |
parent 15995 | 4c523ed1d35c |
parent 15994 | fcc98c953b5e |
permissions | -rw-r--r-- |
315 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com> |
11046 | 4 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
315 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10076
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
315 | 18 |
*/ |
19 |
||
1189
f66cdbbfc4b6
Fix compile under Ubuntu (why it compiles everywhere else?)
unc0rr
parents:
1083
diff
changeset
|
20 |
#include <QDebug> |
1844 | 21 |
#include <QInputDialog> |
1905 | 22 |
#include <QCryptographicHash> |
7728 | 23 |
#include <QSortFilterProxyModel> |
10074 | 24 |
#include <QUuid> |
1844 | 25 |
|
697 | 26 |
#include "hwconsts.h" |
315 | 27 |
#include "newnetclient.h" |
28 |
#include "proto.h" |
|
29 |
#include "game.h" |
|
6732
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
30 |
#include "roomslistmodel.h" |
7723 | 31 |
#include "playerslistmodel.h" |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
32 |
#include "servermessages.h" |
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
33 |
#include "HWApplication.h" |
315 | 34 |
|
10695 | 35 |
char delimiter='\n'; |
315 | 36 |
|
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
37 |
HWNewNet::HWNewNet() : |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
38 |
isChief(false), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
39 |
m_game_connected(false), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
40 |
netClientState(Disconnected) |
315 | 41 |
{ |
10248 | 42 |
m_private_game = false; |
43 |
m_nick_registered = false; |
|
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
44 |
m_demo_data_pending = false; |
10248 | 45 |
|
6732
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
46 |
m_roomsListModel = new RoomsListModel(this); |
7728 | 47 |
|
48 |
m_playersModel = new PlayersListModel(this); |
|
49 |
||
50 |
m_lobbyPlayersModel = new QSortFilterProxyModel(this); |
|
51 |
m_lobbyPlayersModel->setSourceModel(m_playersModel); |
|
52 |
m_lobbyPlayersModel->setSortRole(PlayersListModel::SortRole); |
|
53 |
m_lobbyPlayersModel->setDynamicSortFilter(true); |
|
54 |
m_lobbyPlayersModel->sort(0); |
|
55 |
||
56 |
m_roomPlayersModel = new QSortFilterProxyModel(this); |
|
57 |
m_roomPlayersModel->setSourceModel(m_playersModel); |
|
58 |
m_roomPlayersModel->setSortRole(PlayersListModel::SortRole); |
|
59 |
m_roomPlayersModel->setDynamicSortFilter(true); |
|
60 |
m_roomPlayersModel->sort(0); |
|
7731 | 61 |
m_roomPlayersModel->setFilterRole(PlayersListModel::RoomFilterRole); |
7834 | 62 |
m_roomPlayersModel->setFilterFixedString("true"); |
7728 | 63 |
|
64 |
// socket stuff |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
65 |
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
66 |
connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
67 |
connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
68 |
connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
69 |
SLOT(displayError(QAbstractSocket::SocketError))); |
8534
92da587691c9
Workaround queued signals problem in netclient instead. Should fix everything.
unc0rr
parents:
8489
diff
changeset
|
70 |
|
92da587691c9
Workaround queued signals problem in netclient instead. Should fix everything.
unc0rr
parents:
8489
diff
changeset
|
71 |
connect(this, SIGNAL(messageProcessed()), this, SLOT(ClientRead()), Qt::QueuedConnection); |
315 | 72 |
} |
73 |
||
1526
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
74 |
HWNewNet::~HWNewNet() |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
75 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
76 |
if (m_game_connected) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
77 |
{ |
13673
1aa5e884326a
Fix some string/translation inconsistencies in strings related to leaving
Wuzzy <Wuzzy2@mail.ru>
parents:
13658
diff
changeset
|
78 |
RawSendNet(QString("QUIT%1").arg(delimiter)); |
13846 | 79 |
emit disconnected(""); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
80 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
81 |
NetSocket.flush(); |
1526
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
82 |
} |
18e412dd7d50
Send QUIT message to server when netclient object is destroyed
unc0rr
parents:
1512
diff
changeset
|
83 |
|
14865 | 84 |
void HWNewNet::Connect(const QString & hostName, quint16 port, bool useTls, const QString & nick) |
315 | 85 |
{ |
6036 | 86 |
netClientState = Connecting; |
5390
f41e87de8989
(fix issue 126) moved initial nickname popup to the netconnection page
koda
parents:
5230
diff
changeset
|
87 |
mynick = nick; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
88 |
myhost = hostName + QString(":%1").arg(port); |
14866 | 89 |
if (useTls) |
90 |
{ |
|
91 |
NetSocket.connectToHostEncrypted(hostName, port); |
|
92 |
if (!NetSocket.waitForEncrypted()) |
|
93 |
{ |
|
94 |
qWarning("Handshake failed"); |
|
95 |
} |
|
96 |
} |
|
97 |
else |
|
98 |
{ |
|
99 |
NetSocket.connectToHost(hostName, port); |
|
100 |
} |
|
315 | 101 |
} |
102 |
||
103 |
void HWNewNet::Disconnect() |
|
104 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
105 |
if (m_game_connected) |
13673
1aa5e884326a
Fix some string/translation inconsistencies in strings related to leaving
Wuzzy <Wuzzy2@mail.ru>
parents:
13658
diff
changeset
|
106 |
RawSendNet(QString("QUIT%1").arg(delimiter)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
107 |
m_game_connected = false; |
2377 | 108 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
109 |
NetSocket.disconnectFromHost(); |
315 | 110 |
} |
111 |
||
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9503
diff
changeset
|
112 |
void HWNewNet::CreateRoom(const QString & room, const QString & password) |
315 | 113 |
{ |
13322
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
114 |
if(netClientState != InLobby || !ByteLength(room)) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
115 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
116 |
qWarning("Illegal try to create room!"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
117 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
118 |
} |
2377 | 119 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
120 |
myroom = room; |
2821 | 121 |
|
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9503
diff
changeset
|
122 |
if(password.isEmpty()) |
10695 | 123 |
RawSendNet(QString("CREATE_ROOM%1%2").arg(delimiter).arg(room)); |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9503
diff
changeset
|
124 |
else |
10695 | 125 |
RawSendNet(QString("CREATE_ROOM%1%2%1%3").arg(delimiter).arg(room).arg(password)); |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9503
diff
changeset
|
126 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
127 |
isChief = true; |
1082 | 128 |
} |
129 |
||
9549 | 130 |
void HWNewNet::JoinRoom(const QString & room, const QString &password) |
1082 | 131 |
{ |
6036 | 132 |
if(netClientState != InLobby) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
133 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
134 |
qWarning("Illegal try to join room!"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
135 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
136 |
} |
2377 | 137 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
138 |
myroom = room; |
2821 | 139 |
|
9549 | 140 |
if(password.isEmpty()) |
10695 | 141 |
RawSendNet(QString("JOIN_ROOM%1%2").arg(delimiter).arg(room)); |
9549 | 142 |
else |
10695 | 143 |
RawSendNet(QString("JOIN_ROOM%1%2%1%3").arg(delimiter).arg(room).arg(password)); |
9549 | 144 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
145 |
isChief = false; |
315 | 146 |
} |
147 |
||
148 |
void HWNewNet::AddTeam(const HWTeam & team) |
|
149 |
{ |
|
10695 | 150 |
QString cmd = QString("ADD_TEAM") + delimiter + |
151 |
team.name() + delimiter + |
|
152 |
QString::number(team.color()) + delimiter + |
|
153 |
team.grave() + delimiter + |
|
154 |
team.fort() + delimiter + |
|
155 |
team.voicepack() + delimiter + |
|
156 |
team.flag() + delimiter + |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
157 |
QString::number(team.difficulty()); |
1245
d2eca4a053f5
Send hats info via net. Hats implementation complete now.
unc0rr
parents:
1189
diff
changeset
|
158 |
|
6024 | 159 |
for(int i = 0; i < HEDGEHOGS_PER_TEAM; ++i) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
160 |
{ |
10695 | 161 |
cmd.append(delimiter); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5998
diff
changeset
|
162 |
cmd.append(team.hedgehog(i).Name); |
10695 | 163 |
cmd.append(delimiter); |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
5998
diff
changeset
|
164 |
cmd.append(team.hedgehog(i).Hat); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
165 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
166 |
RawSendNet(cmd); |
315 | 167 |
} |
168 |
||
347 | 169 |
void HWNewNet::RemoveTeam(const HWTeam & team) |
170 |
{ |
|
10695 | 171 |
RawSendNet(QString("REMOVE_TEAM") + delimiter + team.name()); |
347 | 172 |
} |
173 |
||
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
174 |
void HWNewNet::NewNick(const QString & nick) |
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
175 |
{ |
10695 | 176 |
RawSendNet(QString("NICK%1%2").arg(delimiter).arg(nick)); |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
177 |
} |
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
178 |
|
1404 | 179 |
void HWNewNet::ToggleReady() |
315 | 180 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
181 |
RawSendNet(QString("TOGGLE_READY")); |
315 | 182 |
} |
183 |
||
184 |
void HWNewNet::SendNet(const QByteArray & buf) |
|
185 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
186 |
QString msg = QString(buf.toBase64()); |
315 | 187 |
|
10695 | 188 |
RawSendNet(QString("EM%1%2").arg(delimiter).arg(msg)); |
315 | 189 |
} |
190 |
||
13322
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
191 |
int HWNewNet::ByteLength(const QString & str) |
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
192 |
{ |
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
193 |
return str.toUtf8().size(); |
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
194 |
} |
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
195 |
|
315 | 196 |
void HWNewNet::RawSendNet(const QString & str) |
197 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
198 |
RawSendNet(str.toUtf8()); |
315 | 199 |
} |
200 |
||
201 |
void HWNewNet::RawSendNet(const QByteArray & buf) |
|
202 |
{ |
|
11461
5dbc0f976b4a
assume frontend buffer utf-8 to avoid garbage strings in debug
nemo
parents:
11046
diff
changeset
|
203 |
qDebug() << "Client: " << QString(QString::fromUtf8(buf)).split("\n"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
204 |
NetSocket.write(buf); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
205 |
NetSocket.write("\n\n", 2); |
315 | 206 |
} |
207 |
||
208 |
void HWNewNet::ClientRead() |
|
209 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
210 |
while (NetSocket.canReadLine()) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
211 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
212 |
QString s = QString::fromUtf8(NetSocket.readLine()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
213 |
if (s.endsWith('\n')) s.chop(1); |
1082 | 214 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
215 |
if (s.size() == 0) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
216 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
217 |
ParseCmd(cmdbuf); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
218 |
cmdbuf.clear(); |
8534
92da587691c9
Workaround queued signals problem in netclient instead. Should fix everything.
unc0rr
parents:
8489
diff
changeset
|
219 |
emit messageProcessed(); |
92da587691c9
Workaround queued signals problem in netclient instead. Should fix everything.
unc0rr
parents:
8489
diff
changeset
|
220 |
return ; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
221 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
222 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
223 |
cmdbuf << s; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
224 |
} |
315 | 225 |
} |
226 |
||
227 |
void HWNewNet::OnConnect() |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
228 |
{ |
6036 | 229 |
netClientState = Connected; |
315 | 230 |
} |
231 |
||
232 |
void HWNewNet::OnDisconnect() |
|
233 |
{ |
|
6036 | 234 |
netClientState = Disconnected; |
235 |
if(m_game_connected) emit disconnected(""); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
236 |
m_game_connected = false; |
315 | 237 |
} |
238 |
||
239 |
void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
|
240 |
{ |
|
5230
c088be28d5e8
Set m_game_connected to false after emitting Disconnected(). This fixes a bug in a case such that when entering an invalid password, the game would bring you back to the main menu.
Zorg <zorgiepoo@gmail.com>
parents:
5229
diff
changeset
|
241 |
m_game_connected = false; |
2377 | 242 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
243 |
switch (socketError) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
244 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
245 |
case QAbstractSocket::RemoteHostClosedError: |
6722
e3a35bc838fb
Show message and return from network game pages on server shutdown
unc0rr
parents:
6700
diff
changeset
|
246 |
emit disconnected(tr("Remote host has closed connection")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
247 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
248 |
case QAbstractSocket::HostNotFoundError: |
6036 | 249 |
emit disconnected(tr("The host was not found. Please check the host name and port settings.")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
250 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
251 |
case QAbstractSocket::ConnectionRefusedError: |
13658
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
252 |
if (getHost() == (QString("%1:%2").arg(NETGAME_DEFAULT_SERVER).arg(NETGAME_DEFAULT_PORT))) |
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
253 |
// Error for official server |
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
254 |
emit disconnected(tr("The connection was refused by the official server or timed out. Something seems to be wrong with the official server at the moment. This might be a temporary problem. Please try again later.")); |
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
255 |
else |
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
256 |
// Error for every other host |
73993abb85d7
Improve “Connection refused” error message
Wuzzy <Wuzzy2@mail.ru>
parents:
13322
diff
changeset
|
257 |
emit disconnected(tr("The connection was refused by the host or timed out. This might have one of the following reasons:\n- The Hedgewars Server program does currently not run on the host\n- The specified port number is incorrect\n- There is a temporary network problem\n\nPlease check the host name and port settings and/or try again later.")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
258 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
259 |
default: |
6036 | 260 |
emit disconnected(NetSocket.errorString()); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
261 |
} |
315 | 262 |
} |
263 |
||
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
264 |
void HWNewNet::SendPasswordHash(const QString & hash) |
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
265 |
{ |
10074 | 266 |
// don't send it immediately, only store and check if server asked us for a password |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
267 |
m_passwordHash = hash.toLatin1(); |
10074 | 268 |
|
269 |
maybeSendPassword(); |
|
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
270 |
} |
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
271 |
|
14865 | 272 |
void HWNewNet::ContinueConnection() |
273 |
{ |
|
274 |
if (netClientState == Connected) |
|
275 |
{ |
|
276 |
RawSendNet(QString("NICK%1%2").arg(delimiter).arg(mynick)); |
|
277 |
RawSendNet(QString("PROTO%1%2").arg(delimiter).arg(*cProtoVer)); |
|
278 |
m_game_connected = true; |
|
279 |
emit adminAccess(false); |
|
280 |
} |
|
281 |
} |
|
282 |
||
1082 | 283 |
void HWNewNet::ParseCmd(const QStringList & lst) |
315 | 284 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
285 |
qDebug() << "Server: " << lst; |
1305 | 286 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
287 |
if(!lst.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
288 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
289 |
qWarning("Net client: Bad message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
290 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
291 |
} |
320 | 292 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
293 |
if (lst[0] == "NICK") |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
294 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
295 |
mynick = lst[1]; |
7732 | 296 |
m_playersModel->setNickname(mynick); |
8299
ef2e284255cd
Added handling of not registered nicks (no change-server side tho), clearPasswordHash() also now sets the savepassword setting to false
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8291
diff
changeset
|
297 |
m_nick_registered = false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
298 |
return ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
299 |
} |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
300 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
301 |
if (lst[0] == "PROTO") |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
302 |
return ; |
2108 | 303 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
304 |
if (lst[0] == "ERROR") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
305 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
306 |
if (lst.size() == 2) |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
307 |
emit Error(HWApplication::translate("server", lst[1].toLatin1().constData())); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
308 |
else |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
309 |
emit Error("Unknown error"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
310 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
311 |
} |
315 | 312 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
313 |
if (lst[0] == "WARNING") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
314 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
315 |
if (lst.size() == 2) |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
316 |
emit Warning(HWApplication::translate("server", lst[1].toLatin1().constData())); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
317 |
else |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
318 |
emit Warning("Unknown warning"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
319 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
320 |
} |
1307 | 321 |
|
14838 | 322 |
if (lst[0] == "REDIRECT") |
323 |
{ |
|
324 |
if (lst.size() < 2 || lst[1].toInt() == 0) |
|
325 |
{ |
|
326 |
qWarning("Net: Malformed REDIRECT message"); |
|
327 |
return; |
|
328 |
} |
|
329 |
||
330 |
quint16 port = lst[1].toInt(); |
|
331 |
if (port == 0) |
|
332 |
{ |
|
333 |
qWarning() << "Invalid redirection port"; |
|
334 |
} |
|
335 |
else |
|
336 |
{ |
|
14865 | 337 |
netClientState = Redirected; |
14838 | 338 |
emit redirected(port); |
339 |
} |
|
340 |
return; |
|
341 |
} |
|
342 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
343 |
if (lst[0] == "CONNECTED") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
344 |
{ |
4973
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
345 |
if(lst.size() < 3 || lst[2].toInt() < cMinServerVersion) |
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
346 |
{ |
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
347 |
// TODO: Warn user, disconnect |
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
348 |
qWarning() << "Server too old"; |
10695 | 349 |
RawSendNet(QString("QUIT%1%2").arg(delimiter).arg("Server too old")); |
6737
ce5fbd98370f
- Increase server version number due to rooms list protocol changes
unc0rr
parents:
6735
diff
changeset
|
350 |
Disconnect(); |
ce5fbd98370f
- Increase server version number due to rooms list protocol changes
unc0rr
parents:
6735
diff
changeset
|
351 |
emit disconnected(tr("The server is too old. Disconnecting now.")); |
ce5fbd98370f
- Increase server version number due to rooms list protocol changes
unc0rr
parents:
6735
diff
changeset
|
352 |
return; |
4973
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
353 |
} |
53411a26df7e
Add server version (which is separate from protocol version) and a check in frontend for a new enough server (currently only qWarning)
unc0rr
parents:
4963
diff
changeset
|
354 |
|
14865 | 355 |
ClientState lastState = netClientState; |
356 |
netClientState = Connected; |
|
357 |
if (lastState != Redirected) |
|
358 |
{ |
|
359 |
ContinueConnection(); |
|
360 |
} |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
361 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
362 |
} |
315 | 363 |
|
10074 | 364 |
if (lst[0] == "SERVER_AUTH") |
365 |
{ |
|
366 |
if(lst.size() < 2) |
|
367 |
{ |
|
368 |
qWarning("Net: Malformed SERVER_AUTH message"); |
|
369 |
return; |
|
370 |
} |
|
371 |
||
10076 | 372 |
if(lst[1] != m_serverHash) |
10074 | 373 |
{ |
374 |
Error("Server authentication error"); |
|
375 |
Disconnect(); |
|
376 |
} else |
|
377 |
{ |
|
378 |
// empty m_serverHash variable means no authentication was performed |
|
379 |
// or server passed authentication |
|
380 |
m_serverHash.clear(); |
|
381 |
} |
|
382 |
||
383 |
return; |
|
384 |
} |
|
385 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
386 |
if (lst[0] == "PING") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
387 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
388 |
if (lst.size() > 1) |
10695 | 389 |
RawSendNet(QString("PONG%1%2").arg(delimiter).arg(lst[1])); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
390 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
391 |
RawSendNet(QString("PONG")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
392 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
393 |
} |
1462 | 394 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
395 |
if (lst[0] == "ROOMS") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
396 |
{ |
15878
fc3cb23fd26f
Allow to see rooms of incompatible versions in the lobby
S.D.
parents:
15424
diff
changeset
|
397 |
if(lst.size() % m_roomsListModel->columnCountSupported() != 1) |
6733 | 398 |
{ |
399 |
qWarning("Net: Malformed ROOMS message"); |
|
400 |
return; |
|
401 |
} |
|
9702 | 402 |
m_roomsListModel->setRoomsList(lst.mid(1)); |
8720
5603527f9803
this should prevent the password prompt from appearing on local games (issue 548)
koda
parents:
8567
diff
changeset
|
403 |
if (m_private_game == false && m_nick_registered == false) |
8299
ef2e284255cd
Added handling of not registered nicks (no change-server side tho), clearPasswordHash() also now sets the savepassword setting to false
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8291
diff
changeset
|
404 |
{ |
ef2e284255cd
Added handling of not registered nicks (no change-server side tho), clearPasswordHash() also now sets the savepassword setting to false
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8291
diff
changeset
|
405 |
emit NickNotRegistered(mynick); |
ef2e284255cd
Added handling of not registered nicks (no change-server side tho), clearPasswordHash() also now sets the savepassword setting to false
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8291
diff
changeset
|
406 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
407 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
408 |
} |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1311
diff
changeset
|
409 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
410 |
if (lst[0] == "SERVER_MESSAGE") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
411 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
412 |
if(lst.size() < 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
413 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
414 |
qWarning("Net: Empty SERVERMESSAGE message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
415 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
416 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
417 |
emit serverMessage(lst[1]); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
418 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
419 |
} |
1377 | 420 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
421 |
if (lst[0] == "CHAT") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
422 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
423 |
if(lst.size() < 3) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
424 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
425 |
qWarning("Net: Empty CHAT message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
426 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
427 |
} |
8759 | 428 |
|
13692
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
429 |
QString action; |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
430 |
QString message; |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
431 |
QString sender = lst[1]; |
13695
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
432 |
// '[' is a special character used in fake nick names of server messages. |
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
433 |
// Those are supposed to be translated |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
434 |
if(!sender.startsWith('[')) |
13692
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
435 |
{ |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
436 |
// Normal message |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
437 |
message = lst[2]; |
13695
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
438 |
// Another kind of fake nick. '(' nicks are server messages, but they must not be translated |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
439 |
if(!sender.startsWith('(')) |
13695
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
440 |
{ |
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
441 |
// Check for action (/me command) |
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
442 |
action = HWProto::chatStringToAction(message); |
e529a34872f9
Fix some formatting problems with /me
Wuzzy <Wuzzy2@mail.ru>
parents:
13692
diff
changeset
|
443 |
} |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
444 |
else |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
445 |
{ |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
446 |
// If parenthesis were used, replace them with square brackets |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
447 |
// for a consistent style. |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
448 |
sender.replace(0, 1, '['); |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
449 |
sender.replace(sender.length()-1, 1, ']'); |
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
450 |
} |
13692
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
451 |
} |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
452 |
else |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
453 |
{ |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
454 |
// Server message |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
455 |
// Server messages are translated client-side |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
456 |
message = HWApplication::translate("server", lst[2].toLatin1().constData()); |
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
457 |
} |
8759 | 458 |
|
6036 | 459 |
if (netClientState == InLobby) |
8759 | 460 |
{ |
13692
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
461 |
if (!action.isNull()) |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
462 |
emit lobbyChatAction(sender, action); |
8759 | 463 |
else |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
464 |
emit lobbyChatMessage(sender, message); |
8759 | 465 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
466 |
else |
8759 | 467 |
{ |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
468 |
emit chatStringFromNet(HWProto::formatChatMsg(sender, message)); |
13692
70c8feb81d35
Make frontend translate server messages properly
Wuzzy <Wuzzy2@mail.ru>
parents:
13673
diff
changeset
|
469 |
if (!action.isNull()) |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
470 |
emit roomChatAction(sender, action); |
8759 | 471 |
else |
13969
4d761adb4e6c
Frontend: Make sure special nicks always show up in square brackets
Wuzzy <Wuzzy2@mail.ru>
parents:
13846
diff
changeset
|
472 |
emit roomChatMessage(sender, message); |
8759 | 473 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
474 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
475 |
} |
453 | 476 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
477 |
if (lst[0] == "INFO") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
478 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
479 |
if(lst.size() < 5) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
480 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
481 |
qWarning("Net: Malformed INFO message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
482 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
483 |
} |
8759 | 484 |
emit playerInfo(lst[1], lst[2], lst[3], lst[4]); |
485 |
if (netClientState != InLobby) |
|
486 |
{ |
|
487 |
QStringList tmp = lst; |
|
488 |
tmp.removeFirst(); |
|
8762 | 489 |
emit chatStringFromNet(tmp.join(" ").prepend('\x01')); |
8759 | 490 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
491 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
492 |
} |
1577 | 493 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
494 |
if (lst[0] == "SERVER_VARS") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
495 |
{ |
3283 | 496 |
QStringList tmp = lst; |
497 |
tmp.removeFirst(); |
|
498 |
while (tmp.size() >= 2) |
|
499 |
{ |
|
500 |
if(tmp[0] == "MOTD_NEW") emit serverMessageNew(tmp[1]); |
|
501 |
else if(tmp[0] == "MOTD_OLD") emit serverMessageOld(tmp[1]); |
|
502 |
else if(tmp[0] == "LATEST_PROTO") emit latestProtocolVar(tmp[1].toInt()); |
|
3697 | 503 |
|
3283 | 504 |
tmp.removeFirst(); |
505 |
tmp.removeFirst(); |
|
506 |
} |
|
507 |
return; |
|
508 |
} |
|
509 |
||
8157 | 510 |
if (lst[0] == "BANLIST") |
511 |
{ |
|
512 |
QStringList tmp = lst; |
|
513 |
tmp.removeFirst(); |
|
514 |
emit bansList(tmp); |
|
515 |
return; |
|
516 |
} |
|
517 |
||
9702 | 518 |
if (lst[0] == "CLIENT_FLAGS" || lst[0] == "CF") |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
519 |
{ |
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
520 |
if(lst.size() < 3 || lst[1].size() < 2) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
521 |
{ |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
522 |
qWarning("Net: Malformed CLIENT_FLAGS message"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
523 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
524 |
} |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
525 |
|
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
526 |
QString flags = lst[1]; |
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
527 |
bool setFlag = flags[0] == '+'; |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
528 |
const QStringList nicks = lst.mid(2); |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
529 |
|
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
530 |
while(flags.size() > 1) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
531 |
{ |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
532 |
flags.remove(0, 1); |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
533 |
char c = flags[0].toLatin1(); |
8021 | 534 |
bool inRoom = (netClientState == InRoom || netClientState == InGame); |
2377 | 535 |
|
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
536 |
switch(c) |
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
537 |
{ |
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
538 |
// flag indicating if a player is ready to start a game |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
539 |
case 'r': |
8021 | 540 |
if(inRoom) |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
541 |
foreach (const QString & nick, nicks) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
542 |
{ |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
543 |
if (nick == mynick) |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
544 |
{ |
8983 | 545 |
emit setMyReadyStatus(setFlag); |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
546 |
} |
7728 | 547 |
m_playersModel->setFlag(nick, PlayersListModel::Ready, setFlag); |
6539 | 548 |
} |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
549 |
break; |
6539 | 550 |
|
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
551 |
// flag indicating if a player is a registered user |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
552 |
case 'u': |
7727 | 553 |
foreach(const QString & nick, nicks) |
7728 | 554 |
m_playersModel->setFlag(nick, PlayersListModel::Registered, setFlag); |
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
555 |
break; |
9503 | 556 |
// flag indicating if a player is in room |
557 |
case 'i': |
|
558 |
foreach(const QString & nick, nicks) |
|
559 |
m_playersModel->setFlag(nick, PlayersListModel::InRoom, setFlag); |
|
560 |
break; |
|
561 |
// flag indicating if a player is contributor |
|
562 |
case 'c': |
|
563 |
foreach(const QString & nick, nicks) |
|
10144 | 564 |
m_playersModel->setFlag(nick, PlayersListModel::Contributor, setFlag); |
9503 | 565 |
break; |
8021 | 566 |
// flag indicating if a player has engine running |
7765
1e162c1d6dc7
'In game' client flag, both server and frontend support
unc0rr
parents:
7744
diff
changeset
|
567 |
case 'g': |
8021 | 568 |
if(inRoom) |
7765
1e162c1d6dc7
'In game' client flag, both server and frontend support
unc0rr
parents:
7744
diff
changeset
|
569 |
foreach(const QString & nick, nicks) |
1e162c1d6dc7
'In game' client flag, both server and frontend support
unc0rr
parents:
7744
diff
changeset
|
570 |
m_playersModel->setFlag(nick, PlayersListModel::InGame, setFlag); |
1e162c1d6dc7
'In game' client flag, both server and frontend support
unc0rr
parents:
7744
diff
changeset
|
571 |
break; |
1e162c1d6dc7
'In game' client flag, both server and frontend support
unc0rr
parents:
7744
diff
changeset
|
572 |
|
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
573 |
// flag indicating if a player is the host/master of the room |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
574 |
case 'h': |
8021 | 575 |
if(inRoom) |
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
576 |
foreach (const QString & nick, nicks) |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
577 |
{ |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
578 |
if (nick == mynick) |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
579 |
{ |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
580 |
isChief = setFlag; |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
581 |
emit roomMaster(isChief); |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
582 |
} |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
583 |
|
7728 | 584 |
m_playersModel->setFlag(nick, PlayersListModel::RoomAdmin, setFlag); |
7684
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
585 |
} |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
586 |
break; |
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
587 |
|
db140521d102
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
sheepluva
parents:
7683
diff
changeset
|
588 |
// flag indicating if a player is admin (if so -> worship them!) |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
589 |
case 'a': |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
590 |
foreach (const QString & nick, nicks) |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
591 |
{ |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
592 |
if (nick == mynick) |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
593 |
emit adminAccess(setFlag); |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
594 |
|
7728 | 595 |
m_playersModel->setFlag(nick, PlayersListModel::ServerAdmin, setFlag); |
7683
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
596 |
} |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
597 |
break; |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
598 |
|
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
599 |
default: |
993337e5021f
client-flags: make code easier to read/prettier; add parsing of flag 'a'; add warning in console on unknown flag; ignore ADMIN_ACCESS
sheepluva
parents:
7545
diff
changeset
|
600 |
qWarning() << "Net: Unknown client-flag: " << c; |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
601 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
602 |
} |
4917
8ff92bdc9f98
Convert READY and NOT_READY messages to CLIENT_FLAGS message
unc0rr
parents:
4908
diff
changeset
|
603 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
604 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
605 |
} |
1405 | 606 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
607 |
if(lst[0] == "KICKED") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
608 |
{ |
6036 | 609 |
netClientState = InLobby; |
6513
677b96d13e1f
Auto refresh room list after leaving room. Fixes issue #320 for voluntarily and involuntarily coming to room list.
blackmetalowiec
parents:
6222
diff
changeset
|
610 |
askRoomsList(); |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
611 |
emit LeftRoom(tr("You got kicked")); |
7732 | 612 |
m_playersModel->resetRoomFlags(); |
613 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
614 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
615 |
} |
1879 | 616 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
617 |
if(lst[0] == "LOBBY:JOINED") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
618 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
619 |
if(lst.size() < 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
620 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
621 |
qWarning("Net: Bad JOINED message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
622 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
623 |
} |
2377 | 624 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
625 |
for(int i = 1; i < lst.size(); ++i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
626 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
627 |
if (lst[i] == mynick) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
628 |
{ |
10074 | 629 |
// check if server is authenticated or no authentication was performed at all |
630 |
if(!m_serverHash.isEmpty()) |
|
631 |
{ |
|
632 |
Error(tr("Server authentication error")); |
|
633 |
||
634 |
Disconnect(); |
|
635 |
} |
|
636 |
||
6036 | 637 |
netClientState = InLobby; |
11463 | 638 |
//RawSendNet(QString("LIST")); //deprecated |
6036 | 639 |
emit connected(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
640 |
} |
1838
00a5fc50aa43
Use another event to change state from 'logging in' to 'lobby'
unc0rr
parents:
1829
diff
changeset
|
641 |
|
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
642 |
m_playersModel->addPlayer(lst[i], false); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
643 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
644 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
645 |
} |
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1560
diff
changeset
|
646 |
|
15878
fc3cb23fd26f
Allow to see rooms of incompatible versions in the lobby
S.D.
parents:
15424
diff
changeset
|
647 |
if(lst[0] == "ROOM" && lst.size() == m_roomsListModel->columnCountSupported() + 2 && lst[1] == "ADD") |
6733 | 648 |
{ |
649 |
QStringList tmp = lst; |
|
650 |
tmp.removeFirst(); |
|
651 |
tmp.removeFirst(); |
|
652 |
||
653 |
m_roomsListModel->addRoom(tmp); |
|
654 |
return; |
|
655 |
} |
|
656 |
||
15878
fc3cb23fd26f
Allow to see rooms of incompatible versions in the lobby
S.D.
parents:
15424
diff
changeset
|
657 |
if(lst[0] == "ROOM" && lst.size() == m_roomsListModel->columnCountSupported() + 3 && lst[1] == "UPD") |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
658 |
{ |
6733 | 659 |
QStringList tmp = lst; |
660 |
tmp.removeFirst(); |
|
661 |
tmp.removeFirst(); |
|
662 |
||
663 |
QString roomName = tmp.takeFirst(); |
|
664 |
m_roomsListModel->updateRoom(roomName, tmp); |
|
7710
fd5bcbd698a5
- Keep track of room name so correct name is displayed when you become room admin
unc0rr
parents:
7684
diff
changeset
|
665 |
|
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
666 |
// keep track of room name so correct name is displayed |
9906
93c16a4b0c6a
Only emit roomNameUpdated when it actually is changed
unc0rr
parents:
9730
diff
changeset
|
667 |
if(myroom == roomName && myroom != tmp[1]) |
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
668 |
{ |
7712 | 669 |
myroom = tmp[1]; |
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
670 |
emit roomNameUpdated(myroom); |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
671 |
} |
7710
fd5bcbd698a5
- Keep track of room name so correct name is displayed when you become room admin
unc0rr
parents:
7684
diff
changeset
|
672 |
|
6733 | 673 |
return; |
674 |
} |
|
675 |
||
676 |
if(lst[0] == "ROOM" && lst.size() == 3 && lst[1] == "DEL") |
|
677 |
{ |
|
678 |
m_roomsListModel->removeRoom(lst[2]); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
679 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
680 |
} |
1591 | 681 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
682 |
if(lst[0] == "LOBBY:LEFT") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
683 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
684 |
if(lst.size() < 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
685 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
686 |
qWarning("Net: Bad LOBBY:LEFT message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
687 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
688 |
} |
8759 | 689 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
690 |
if (lst.size() < 3) |
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
691 |
m_playersModel->removePlayer(lst[1]); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
692 |
else |
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
693 |
m_playersModel->removePlayer(lst[1], lst[2]); |
7725 | 694 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
695 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
696 |
} |
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1560
diff
changeset
|
697 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
698 |
if (lst[0] == "ASKPASSWORD") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
699 |
{ |
10074 | 700 |
// server should send us salt of at least 16 characters |
701 |
||
702 |
if(lst.size() < 2 || lst[1].size() < 16) |
|
703 |
{ |
|
704 |
qWarning("Net: Bad ASKPASSWORD message"); |
|
705 |
return; |
|
706 |
} |
|
707 |
||
8291
e4a0d980d1e2
Patched login dialog bugs, added retry dialogs
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8157
diff
changeset
|
708 |
emit NickRegistered(mynick); |
8299
ef2e284255cd
Added handling of not registered nicks (no change-server side tho), clearPasswordHash() also now sets the savepassword setting to false
Ondrej Skopek <skopekondrej@gmail.com>
parents:
8291
diff
changeset
|
709 |
m_nick_registered = true; |
10074 | 710 |
|
711 |
// store server salt |
|
712 |
// when this variable is set, it is assumed that server asked us for a password |
|
713 |
m_serverSalt = lst[1]; |
|
714 |
m_clientSalt = QUuid::createUuid().toString(); |
|
715 |
||
716 |
maybeSendPassword(); |
|
717 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
718 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
719 |
} |
1841
fba7210b438b
Retrieve client password from web database and ask for it
unc0rr
parents:
1838
diff
changeset
|
720 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
721 |
if (lst[0] == "NOTICE") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
722 |
{ |
4879
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
723 |
if(lst.size() < 2) |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
724 |
{ |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
725 |
qWarning("Net: Bad NOTICE message"); |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
726 |
return; |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
727 |
} |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
728 |
|
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
729 |
bool ok; |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
730 |
int n = lst[1].toInt(&ok); |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
731 |
if(!ok) |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
732 |
{ |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
733 |
qWarning("Net: Bad NOTICE message"); |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
734 |
return; |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
735 |
} |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
736 |
|
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
737 |
handleNotice(n); |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
738 |
|
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
739 |
return; |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
740 |
} |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
741 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
742 |
if (lst[0] == "BYE") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
743 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
744 |
if (lst.size() < 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
745 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
746 |
qWarning("Net: Bad BYE message"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
747 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
748 |
} |
5861 | 749 |
if (lst[1] == "Authentication failed") |
750 |
{ |
|
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
751 |
emit AuthFailed(); |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
752 |
m_game_connected = false; |
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
753 |
Disconnect(); |
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
754 |
//omitted 'emit disconnected()', we don't want the error message |
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
755 |
return; |
5861 | 756 |
} |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
757 |
m_game_connected = false; |
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
758 |
Disconnect(); |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
759 |
emit disconnected(HWApplication::translate("server", lst[1].toLatin1().constData())); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
760 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
761 |
} |
1512
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1475
diff
changeset
|
762 |
|
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
763 |
if(lst[0] == "JOINING") |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
764 |
{ |
9730 | 765 |
if(lst.size() != 2) |
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
766 |
{ |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
767 |
qWarning("Net: Bad JOINING message"); |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
768 |
return; |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
769 |
} |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
770 |
|
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
771 |
myroom = lst[1]; |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
772 |
emit roomNameUpdated(myroom); |
9730 | 773 |
return; |
8489
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
774 |
} |
25cb6f4a1d1b
Implements protocol message JOINING on frontend, so client in a room always displays correct room name, even when room name changes. Fixes issue 522.
dag10
parents:
8436
diff
changeset
|
775 |
|
7535 | 776 |
if(netClientState == InLobby && lst[0] == "JOINED") |
777 |
{ |
|
778 |
if(lst.size() < 2 || lst[1] != mynick) |
|
779 |
{ |
|
780 |
qWarning("Net: Bad JOINED message"); |
|
781 |
return; |
|
782 |
} |
|
783 |
||
784 |
for(int i = 1; i < lst.size(); ++i) |
|
785 |
{ |
|
786 |
if (lst[i] == mynick) |
|
787 |
{ |
|
788 |
netClientState = InRoom; |
|
789 |
emit EnteredGame(); |
|
790 |
emit roomMaster(isChief); |
|
791 |
if (isChief) |
|
792 |
emit configAsked(); |
|
793 |
} |
|
794 |
||
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
795 |
m_playersModel->playerJoinedRoom(lst[i], isChief && (lst[i] != mynick)); |
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
796 |
|
7535 | 797 |
emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); |
798 |
} |
|
799 |
return; |
|
800 |
} |
|
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
801 |
|
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
802 |
if(netClientState == InLobby && lst[0] == "REPLAY_START") |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
803 |
{ |
14906
8b5d06749026
Remove unused REPLAY_START cruft from frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14903
diff
changeset
|
804 |
netClientState = InRoom; |
8b5d06749026
Remove unused REPLAY_START cruft from frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14903
diff
changeset
|
805 |
m_demo_data_pending = true; |
8b5d06749026
Remove unused REPLAY_START cruft from frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14903
diff
changeset
|
806 |
emit EnteredGame(); |
8b5d06749026
Remove unused REPLAY_START cruft from frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14903
diff
changeset
|
807 |
emit roomMaster(false); |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
808 |
return; |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
809 |
} |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
810 |
|
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
811 |
if(netClientState == InRoom || netClientState == InGame || netClientState == InDemo) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
812 |
{ |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
813 |
if (lst[0] == "EM") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
814 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
815 |
if(lst.size() < 2) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
816 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
817 |
qWarning("Net: Bad EM message"); |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
818 |
m_demo_data_pending = false; |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
819 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
820 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
821 |
for(int i = 1; i < lst.size(); ++i) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
822 |
{ |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
823 |
QByteArray em = QByteArray::fromBase64(lst[i].toLatin1()); |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
824 |
emit FromNet(em); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
825 |
} |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
826 |
m_demo_data_pending = false; |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
827 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
828 |
} |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
829 |
} |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
830 |
|
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
831 |
if(netClientState == InRoom || netClientState == InGame) |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
832 |
{ |
8303
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
833 |
if (lst[0] == "ROUND_FINISHED") |
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
834 |
{ |
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
835 |
emit FromNet(QByteArray("\x01o")); |
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
836 |
return; |
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
837 |
} |
6331bceac95c
Pass ROUND_FINISHED to engine so it could stop syncing
unc0rr
parents:
8299
diff
changeset
|
838 |
|
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
839 |
if (lst[0] == "ADD_TEAM") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
840 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
841 |
if(lst.size() != 24) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
842 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
843 |
qWarning("Net: Bad ADDTEAM message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
844 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
845 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
846 |
QStringList tmp = lst; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
847 |
tmp.removeFirst(); |
10400
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10248
diff
changeset
|
848 |
HWTeam team(tmp); |
47e2189eae44
This should make frontend aware of your own teams in game on rejoin
unc0rr
parents:
10248
diff
changeset
|
849 |
emit AddNetTeam(team); |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
850 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
851 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
852 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
853 |
if (lst[0] == "REMOVE_TEAM") |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
854 |
{ |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
855 |
if(lst.size() != 2) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
856 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
857 |
qWarning("Net: Bad REMOVETEAM message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
858 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
859 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
860 |
emit RemoveNetTeam(HWTeam(lst[1])); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
861 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
862 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
863 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
864 |
if(lst[0] == "ROOMABANDONED") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
865 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
866 |
netClientState = InLobby; |
7732 | 867 |
m_playersModel->resetRoomFlags(); |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
868 |
emit LeftRoom(tr("Room destroyed")); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
869 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
870 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
871 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
872 |
if (lst[0] == "RUN_GAME") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
873 |
{ |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
874 |
if(m_demo_data_pending) |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
875 |
{ |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
876 |
netClientState = InDemo; |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
877 |
emit AskForOfficialServerDemo(); |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
878 |
} |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
879 |
else |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
880 |
{ |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
881 |
netClientState = InGame; |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
882 |
emit AskForRunGame(); |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
883 |
} |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
884 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
885 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
886 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
887 |
if (lst[0] == "TEAM_ACCEPTED") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
888 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
889 |
if (lst.size() != 2) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
890 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
891 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
892 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
893 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
894 |
emit TeamAccepted(lst[1]); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
895 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
896 |
} |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
897 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
898 |
if (lst[0] == "CFG") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
899 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
900 |
if(lst.size() < 3) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
901 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
902 |
qWarning("Net: Bad CFG message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
903 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
904 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
905 |
QStringList tmp = lst; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
906 |
tmp.removeFirst(); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
907 |
tmp.removeFirst(); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
908 |
if (lst[1] == "SCHEME") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
909 |
emit netSchemeConfig(tmp); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
910 |
else |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
911 |
emit paramChanged(lst[1], tmp); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
912 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
913 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
914 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
915 |
if (lst[0] == "HH_NUM") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
916 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
917 |
if (lst.size() != 3) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
918 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
919 |
qWarning("Net: Bad TEAM_ACCEPTED message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
920 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
921 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
922 |
HWTeam tmptm(lst[1]); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
923 |
tmptm.setNumHedgehogs(lst[2].toUInt()); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
924 |
emit hhnumChanged(tmptm); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
925 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
926 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
927 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
928 |
if (lst[0] == "TEAM_COLOR") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
929 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
930 |
if (lst.size() != 3) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
931 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
932 |
qWarning("Net: Bad TEAM_COLOR message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
933 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
934 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
935 |
HWTeam tmptm(lst[1]); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
936 |
tmptm.setColor(lst[2].toInt()); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
937 |
emit teamColorChanged(tmptm); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
938 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
939 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
940 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
941 |
if(lst[0] == "JOINED") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
942 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
943 |
if(lst.size() < 2) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
944 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
945 |
qWarning("Net: Bad JOINED message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
946 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
947 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
948 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
949 |
for(int i = 1; i < lst.size(); ++i) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
950 |
{ |
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
951 |
m_playersModel->playerJoinedRoom(lst[i], isChief && (lst[i] != mynick)); |
15993
64740eec84ad
requested change by andu. filtering out ignored player. lobby notice
nemo
parents:
15424
diff
changeset
|
952 |
if(!m_playersModel->isFlagSet(lst[i], PlayersListModel::Ignore)) |
64740eec84ad
requested change by andu. filtering out ignored player. lobby notice
nemo
parents:
15424
diff
changeset
|
953 |
emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
954 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
955 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
956 |
} |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
957 |
|
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
958 |
if(lst[0] == "LEFT") |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
959 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
960 |
if(lst.size() < 2) |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
961 |
{ |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
962 |
qWarning("Net: Bad LEFT message"); |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
963 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
964 |
} |
8891
bf67b4d7d7b4
- Better fix to friends joins/quits highlighting problem
unc0rr
parents:
8765
diff
changeset
|
965 |
|
15994 | 966 |
if(!m_playersModel->isFlagSet(lst[1], PlayersListModel::Ignore)) { |
967 |
if (lst.size() < 3) |
|
968 |
emit chatStringFromNet(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); |
|
969 |
else |
|
970 |
{ |
|
971 |
QString leaveMsg = QString(lst[2]); |
|
972 |
emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1]).arg(HWApplication::translate("server", leaveMsg.toLatin1().constData()))); |
|
973 |
} |
|
13673
1aa5e884326a
Fix some string/translation inconsistencies in strings related to leaving
Wuzzy <Wuzzy2@mail.ru>
parents:
13658
diff
changeset
|
974 |
} |
7731 | 975 |
m_playersModel->playerLeftRoom(lst[1]); |
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
976 |
return; |
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
977 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
978 |
} |
2340
3b35fd5f67c7
Fix a bug when you are unable to do anything in lobby when room is closed during round
unc0rr
parents:
2335
diff
changeset
|
979 |
|
7526
ff3a05e29ddd
Don't accept room messages when not in room state. Not tested even if it builds.
unc0rr
parents:
7130
diff
changeset
|
980 |
qWarning() << "Net: Unknown message or wrong state:" << lst; |
315 | 981 |
} |
982 |
||
352 | 983 |
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) |
984 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
985 |
if (isChief) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
986 |
RawSendNet(QString("HH_NUM%1%2%1%3") |
10695 | 987 |
.arg(delimiter) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
988 |
.arg(team.name()) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
989 |
.arg(team.numHedgehogs())); |
352 | 990 |
} |
991 |
||
372 | 992 |
void HWNewNet::onTeamColorChanged(const HWTeam& team) |
993 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
994 |
if (isChief) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
995 |
RawSendNet(QString("TEAM_COLOR%1%2%1%3") |
10695 | 996 |
.arg(delimiter) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
997 |
.arg(team.name()) |
7130 | 998 |
.arg(team.color())); |
372 | 999 |
} |
1000 |
||
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1866
diff
changeset
|
1001 |
void HWNewNet::onParamChanged(const QString & param, const QStringList & value) |
1782
e7589e37a6d6
Options for bonus box probability tuning and number of turn until sudden death
unc0rr
parents:
1742
diff
changeset
|
1002 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1003 |
if (isChief) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1004 |
RawSendNet( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1005 |
QString("CFG%1%2%1%3") |
10695 | 1006 |
.arg(delimiter) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1007 |
.arg(param) |
10695 | 1008 |
.arg(value.join(QString(delimiter))) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1009 |
); |
1797 | 1010 |
} |
1011 |
||
8765
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1012 |
void HWNewNet::chatLineToNetWithEcho(const QString& str) |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1013 |
{ |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1014 |
if(str != "") |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1015 |
{ |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1016 |
emit chatStringFromNet(HWProto::formatChatMsg(mynick, str)); |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1017 |
chatLineToNet(str); |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1018 |
} |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1019 |
} |
688062f1db59
fix/hack so that (own) messages sent in frontend are also visible in the game chat
sheepluva
parents:
8762
diff
changeset
|
1020 |
|
453 | 1021 |
void HWNewNet::chatLineToNet(const QString& str) |
1022 |
{ |
|
13322
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
1023 |
if(ByteLength(str)) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1024 |
{ |
10695 | 1025 |
RawSendNet(QString("CHAT") + delimiter + str); |
8759 | 1026 |
QString action = HWProto::chatStringToAction(str); |
1027 |
if (action != NULL) |
|
1028 |
emit(roomChatAction(mynick, action)); |
|
1029 |
else |
|
1030 |
emit(roomChatMessage(mynick, str)); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1031 |
} |
1568 | 1032 |
} |
1033 |
||
1034 |
void HWNewNet::chatLineToLobby(const QString& str) |
|
1035 |
{ |
|
13322
b77a9380dd0f
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
nemo
parents:
12897
diff
changeset
|
1036 |
if(ByteLength(str)) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1037 |
{ |
10695 | 1038 |
RawSendNet(QString("CHAT") + delimiter + str); |
8759 | 1039 |
QString action = HWProto::chatStringToAction(str); |
1040 |
if (action != NULL) |
|
1041 |
emit(lobbyChatAction(mynick, action)); |
|
1042 |
else |
|
1043 |
emit(lobbyChatMessage(mynick, str)); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1044 |
} |
453 | 1045 |
} |
1315 | 1046 |
|
2403 | 1047 |
void HWNewNet::SendTeamMessage(const QString& str) |
1048 |
{ |
|
10695 | 1049 |
RawSendNet(QString("TEAMCHAT") + delimiter + str); |
2403 | 1050 |
} |
1051 |
||
1315 | 1052 |
void HWNewNet::askRoomsList() |
1053 |
{ |
|
6036 | 1054 |
if(netClientState != InLobby) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1055 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1056 |
qWarning("Illegal try to get rooms list!"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1057 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1058 |
} |
11463 | 1059 |
//RawSendNet(QString("LIST")); //deprecated |
1315 | 1060 |
} |
1339 | 1061 |
|
6036 | 1062 |
HWNewNet::ClientState HWNewNet::clientState() |
2821 | 1063 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1064 |
return netClientState; |
2821 | 1065 |
} |
1066 |
||
1067 |
QString HWNewNet::getNick() |
|
1068 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1069 |
return mynick; |
2821 | 1070 |
} |
1071 |
||
1072 |
QString HWNewNet::getRoom() |
|
1073 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1074 |
return myroom; |
2821 | 1075 |
} |
1076 |
||
1077 |
QString HWNewNet::getHost() |
|
1078 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1079 |
return myhost; |
2821 | 1080 |
} |
1081 |
||
1339 | 1082 |
bool HWNewNet::isRoomChief() |
1083 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1084 |
return isChief; |
1339 | 1085 |
} |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
1086 |
|
4908
99d6797b7ff4
Frontend sends ROUNDFINISHED with information about whether the round was played till end (will be needed for stats)
unc0rr
parents:
4897
diff
changeset
|
1087 |
void HWNewNet::gameFinished(bool correctly) |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
1088 |
{ |
6739
97dab041f995
Send ROUND_FINISHED only once (only from in game mode)
unc0rr
parents:
6737
diff
changeset
|
1089 |
if (netClientState == InGame) |
97dab041f995
Send ROUND_FINISHED only once (only from in game mode)
unc0rr
parents:
6737
diff
changeset
|
1090 |
{ |
97dab041f995
Send ROUND_FINISHED only once (only from in game mode)
unc0rr
parents:
6737
diff
changeset
|
1091 |
netClientState = InRoom; |
10695 | 1092 |
RawSendNet(QString("ROUNDFINISHED%1%2").arg(delimiter).arg(correctly ? "1" : "0")); |
6739
97dab041f995
Send ROUND_FINISHED only once (only from in game mode)
unc0rr
parents:
6737
diff
changeset
|
1093 |
} |
14903
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1094 |
else if (netClientState == InDemo) |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1095 |
{ |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1096 |
netClientState = InLobby; |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1097 |
askRoomsList(); |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1098 |
emit LeftRoom(QString()); |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1099 |
m_playersModel->resetRoomFlags(); |
5119203470f3
Teach frontend how to deal with official server replays (/watch)
Wuzzy <Wuzzy2@mail.ru>
parents:
14866
diff
changeset
|
1100 |
} |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1339
diff
changeset
|
1101 |
} |
1378 | 1102 |
|
1860 | 1103 |
void HWNewNet::banPlayer(const QString & nick) |
1104 |
{ |
|
10695 | 1105 |
RawSendNet(QString("BAN%1%2").arg(delimiter).arg(nick)); |
1860 | 1106 |
} |
1107 |
||
8157 | 1108 |
void HWNewNet::banIP(const QString & ip, const QString & reason, int seconds) |
1109 |
{ |
|
10695 | 1110 |
RawSendNet(QString("BANIP%1%2%1%3%1%4").arg(delimiter).arg(ip).arg(reason).arg(seconds)); |
8157 | 1111 |
} |
1112 |
||
1113 |
void HWNewNet::banNick(const QString & nick, const QString & reason, int seconds) |
|
1114 |
{ |
|
10695 | 1115 |
RawSendNet(QString("BANNICK%1%2%1%3%1%4").arg(delimiter).arg(nick).arg(reason).arg(seconds)); |
8157 | 1116 |
} |
1117 |
||
1118 |
void HWNewNet::getBanList() |
|
1119 |
{ |
|
1120 |
RawSendNet(QByteArray("BANLIST")); |
|
1121 |
} |
|
1122 |
||
1123 |
void HWNewNet::removeBan(const QString & b) |
|
1124 |
{ |
|
10695 | 1125 |
RawSendNet(QString("UNBAN%1%2").arg(delimiter).arg(b)); |
8157 | 1126 |
} |
1127 |
||
1391 | 1128 |
void HWNewNet::kickPlayer(const QString & nick) |
1129 |
{ |
|
10695 | 1130 |
RawSendNet(QString("KICK%1%2").arg(delimiter).arg(nick)); |
1391 | 1131 |
} |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1132 |
|
11865
047be82b6f67
fix for Bug 91 - Make DELEGATE action available in frontend
sheepluva
parents:
11463
diff
changeset
|
1133 |
void HWNewNet::delegateToPlayer(const QString & nick) |
047be82b6f67
fix for Bug 91 - Make DELEGATE action available in frontend
sheepluva
parents:
11463
diff
changeset
|
1134 |
{ |
047be82b6f67
fix for Bug 91 - Make DELEGATE action available in frontend
sheepluva
parents:
11463
diff
changeset
|
1135 |
RawSendNet(QString("DELEGATE%1%2").arg(delimiter).arg(nick)); |
047be82b6f67
fix for Bug 91 - Make DELEGATE action available in frontend
sheepluva
parents:
11463
diff
changeset
|
1136 |
} |
047be82b6f67
fix for Bug 91 - Make DELEGATE action available in frontend
sheepluva
parents:
11463
diff
changeset
|
1137 |
|
1577 | 1138 |
void HWNewNet::infoPlayer(const QString & nick) |
1139 |
{ |
|
10695 | 1140 |
RawSendNet(QString("INFO%1%2").arg(delimiter).arg(nick)); |
1577 | 1141 |
} |
1142 |
||
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2543
diff
changeset
|
1143 |
void HWNewNet::followPlayer(const QString & nick) |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2543
diff
changeset
|
1144 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1145 |
if (!isInRoom()) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6539
diff
changeset
|
1146 |
{ |
10695 | 1147 |
RawSendNet(QString("FOLLOW%1%2").arg(delimiter).arg(nick)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1148 |
isChief = false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1149 |
} |
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2543
diff
changeset
|
1150 |
} |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2543
diff
changeset
|
1151 |
|
8396 | 1152 |
void HWNewNet::consoleCommand(const QString & cmd) |
1153 |
{ |
|
10695 | 1154 |
RawSendNet(QString("CMD%1%2").arg(delimiter).arg(cmd)); |
8396 | 1155 |
} |
1156 |
||
8416
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1157 |
bool HWNewNet::allPlayersReady() |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1158 |
{ |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1159 |
int ready = 0; |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1160 |
for (int i = 0; i < m_roomPlayersModel->rowCount(); i++) |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1161 |
if (m_roomPlayersModel->index(i, 0).data(PlayersListModel::Ready).toBool()) ready++; |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1162 |
|
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1163 |
return (ready == m_roomPlayersModel->rowCount()); |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1164 |
} |
e691acd778f5
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
dag10
parents:
8401
diff
changeset
|
1165 |
|
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1166 |
void HWNewNet::startGame() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1167 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1168 |
RawSendNet(QString("START_GAME")); |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1169 |
} |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1170 |
|
5126 | 1171 |
void HWNewNet::updateRoomName(const QString & name) |
1172 |
{ |
|
10695 | 1173 |
RawSendNet(QString("ROOM_NAME%1%2").arg(delimiter).arg(name)); |
5126 | 1174 |
} |
1175 |
||
1176 |
||
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1177 |
void HWNewNet::toggleRestrictJoins() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1178 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1179 |
RawSendNet(QString("TOGGLE_RESTRICT_JOINS")); |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1180 |
} |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1181 |
|
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1182 |
void HWNewNet::toggleRestrictTeamAdds() |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1183 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1184 |
RawSendNet(QString("TOGGLE_RESTRICT_TEAMS")); |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1405
diff
changeset
|
1185 |
} |
1592
5ee77ee470a6
Start converting network protocol to no-disconnecting religion
unc0rr
parents:
1591
diff
changeset
|
1186 |
|
8559 | 1187 |
void HWNewNet::toggleRegisteredOnly() |
1188 |
{ |
|
1189 |
RawSendNet(QString("TOGGLE_REGISTERED_ONLY")); |
|
1190 |
} |
|
1191 |
||
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2149
diff
changeset
|
1192 |
void HWNewNet::clearAccountsCache() |
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2149
diff
changeset
|
1193 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1194 |
RawSendNet(QString("CLEAR_ACCOUNTS_CACHE")); |
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2149
diff
changeset
|
1195 |
} |
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2149
diff
changeset
|
1196 |
|
1592
5ee77ee470a6
Start converting network protocol to no-disconnecting religion
unc0rr
parents:
1591
diff
changeset
|
1197 |
void HWNewNet::partRoom() |
5ee77ee470a6
Start converting network protocol to no-disconnecting religion
unc0rr
parents:
1591
diff
changeset
|
1198 |
{ |
6036 | 1199 |
netClientState = InLobby; |
7732 | 1200 |
m_playersModel->resetRoomFlags(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2821
diff
changeset
|
1201 |
RawSendNet(QString("PART")); |
1592
5ee77ee470a6
Start converting network protocol to no-disconnecting religion
unc0rr
parents:
1591
diff
changeset
|
1202 |
} |
1671 | 1203 |
|
1204 |
bool HWNewNet::isInRoom() |
|
1205 |
{ |
|
6036 | 1206 |
return netClientState >= InRoom; |
1671 | 1207 |
} |
1925 | 1208 |
|
3283 | 1209 |
void HWNewNet::setServerMessageNew(const QString & msg) |
1210 |
{ |
|
10695 | 1211 |
RawSendNet(QString("SET_SERVER_VAR%1MOTD_NEW%1%2").arg(delimiter).arg(msg)); |
3283 | 1212 |
} |
1213 |
||
1214 |
void HWNewNet::setServerMessageOld(const QString & msg) |
|
1925 | 1215 |
{ |
10695 | 1216 |
RawSendNet(QString("SET_SERVER_VAR%1MOTD_OLD%1%2").arg(delimiter).arg(msg)); |
1925 | 1217 |
} |
3283 | 1218 |
|
1219 |
void HWNewNet::setLatestProtocolVar(int proto) |
|
1220 |
{ |
|
10695 | 1221 |
RawSendNet(QString("SET_SERVER_VAR%1LATEST_PROTO%1%2").arg(delimiter).arg(proto)); |
3283 | 1222 |
} |
1223 |
||
1224 |
void HWNewNet::askServerVars() |
|
1225 |
{ |
|
3697 | 1226 |
RawSendNet(QString("GET_SERVER_VAR")); |
3343
6289df7747c0
Clarify an ambiguity as to what to do here if your name is already taken.
nemo
parents:
3283
diff
changeset
|
1227 |
} |
4879
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1228 |
|
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1229 |
void HWNewNet::handleNotice(int n) |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1230 |
{ |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1231 |
switch(n) |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1232 |
{ |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1233 |
case 0: |
5998
e8f44e9433f0
many many netclient/frondent changes (just the beginning though):
sheepluva
parents:
5959
diff
changeset
|
1234 |
emit NickTaken(mynick); |
4879
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1235 |
break; |
9549 | 1236 |
case 2: |
1237 |
emit askForRoomPassword(); |
|
1238 |
break; |
|
4879
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1239 |
} |
55f939e2c19c
Ask for another nickname on collision. Works only with new server.
unc0rr
parents:
4535
diff
changeset
|
1240 |
} |
6732
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
1241 |
|
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
1242 |
RoomsListModel * HWNewNet::roomsListModel() |
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
1243 |
{ |
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
1244 |
return m_roomsListModel; |
c906dc78091f
Start switching to rooms list model. To be continued.
unc0rr
parents:
6722
diff
changeset
|
1245 |
} |
7723 | 1246 |
|
7728 | 1247 |
QAbstractItemModel *HWNewNet::lobbyPlayersModel() |
7723 | 1248 |
{ |
1249 |
return m_lobbyPlayersModel; |
|
1250 |
} |
|
1251 |
||
7728 | 1252 |
QAbstractItemModel *HWNewNet::roomPlayersModel() |
7723 | 1253 |
{ |
1254 |
return m_roomPlayersModel; |
|
8436
b89aacebb9db
- Also pass unknown cmds to the server when in room
unc0rr
parents:
8416
diff
changeset
|
1255 |
} |
9549 | 1256 |
|
1257 |
void HWNewNet::roomPasswordEntered(const QString &password) |
|
1258 |
{ |
|
1259 |
if(!myroom.isEmpty()) |
|
1260 |
JoinRoom(myroom, password); |
|
1261 |
} |
|
10074 | 1262 |
|
1263 |
void HWNewNet::maybeSendPassword() |
|
1264 |
{ |
|
1265 |
/* When we got password hash, and server asked us for a password, perform mutual authentication: |
|
1266 |
* at this point we have salt chosen by server |
|
1267 |
* client sends client salt and hash of secret (password hash) salted with client salt, server salt, |
|
1268 |
* and static salt (predefined string + protocol number) |
|
1269 |
* server should respond with hash of the same set in different order. |
|
1270 |
*/ |
|
1271 |
||
1272 |
if(m_passwordHash.isEmpty() || m_serverSalt.isEmpty()) |
|
1273 |
return; |
|
1274 |
||
10076 | 1275 |
QString hash = QCryptographicHash::hash( |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1276 |
m_clientSalt.toLatin1() |
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1277 |
.append(m_serverSalt.toLatin1()) |
10074 | 1278 |
.append(m_passwordHash) |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1279 |
.append(cProtoVer->toLatin1()) |
10074 | 1280 |
.append("!hedgewars") |
10076 | 1281 |
, QCryptographicHash::Sha1).toHex(); |
10074 | 1282 |
|
1283 |
m_serverHash = QCryptographicHash::hash( |
|
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1284 |
m_serverSalt.toLatin1() |
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1285 |
.append(m_clientSalt.toLatin1()) |
10074 | 1286 |
.append(m_passwordHash) |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
11865
diff
changeset
|
1287 |
.append(cProtoVer->toLatin1()) |
10074 | 1288 |
.append("!hedgewars") |
10076 | 1289 |
, QCryptographicHash::Sha1).toHex(); |
10074 | 1290 |
|
10695 | 1291 |
RawSendNet(QString("PASSWORD%1%2%1%3").arg(delimiter).arg(hash).arg(m_clientSalt)); |
10074 | 1292 |
} |