Skip to content

Commit d92d376

Browse files
est31Loïc Blot
authored and
Loïc Blot
committedJul 7, 2015
Client: better m_proto_ver initialisation
Previously, m_proto_ver was set to the serialisation version inside the legacy init packet. Now, if the server doesn't send a protocol version (protocols < 25), we set m_proto_ver to some value < 25 and > 0.
1 parent a938387 commit d92d376

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed
 

‎src/client.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Client::Client(
229229
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
230230
m_device(device),
231231
m_server_ser_ver(SER_FMT_VER_INVALID),
232+
m_proto_ver(0),
232233
m_playeritem(0),
233234
m_inventory_updated(false),
234235
m_inventory_from_server(NULL),

‎src/client.h

+6
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,14 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
595595
Mapper *m_mapper;
596596
// Server serialization version
597597
u8 m_server_ser_ver;
598+
598599
// Used version of the protocol with server
600+
// Values smaller than 25 only mean they are smaller than 25,
601+
// and aren't accurate. We simply just don't know, because
602+
// the server didn't send the version back then.
603+
// If 0, server init hasn't been received yet.
599604
u8 m_proto_ver;
605+
600606
u16 m_playeritem;
601607
bool m_inventory_updated;
602608
Inventory *m_inventory_from_server;

‎src/network/clientpackethandler.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,23 @@ void Client::handleCommand_InitLegacy(NetworkPacket* pkt)
151151
if (pkt->getSize() < 1)
152152
return;
153153

154-
u8 deployed;
155-
*pkt >> deployed;
154+
u8 server_ser_ver;
155+
*pkt >> server_ser_ver;
156156

157157
infostream << "Client: TOCLIENT_INIT_LEGACY received with "
158-
"deployed=" << ((int)deployed & 0xff) << std::endl;
158+
"server_ser_ver=" << ((int)server_ser_ver & 0xff) << std::endl;
159159

160-
if (!ser_ver_supported(deployed)) {
160+
if (!ser_ver_supported(server_ser_ver)) {
161161
infostream << "Client: TOCLIENT_INIT_LEGACY: Server sent "
162162
<< "unsupported ser_fmt_ver"<< std::endl;
163163
return;
164164
}
165165

166-
m_server_ser_ver = deployed;
167-
m_proto_ver = deployed;
166+
m_server_ser_ver = server_ser_ver;
167+
168+
// We can be totally wrong with this guess
169+
// but we only need some value < 25.
170+
m_proto_ver = 24;
168171

169172
// Get player position
170173
v3s16 playerpos_s16(0, BS * 2 + BS * 20, 0);

0 commit comments

Comments
 (0)