Added network protocol version number in protocol
This commit is contained in:
parent
cdadbdbd17
commit
24a662705c
|
@ -415,8 +415,9 @@ void Client::step(float dtime)
|
||||||
// [0] u16 TOSERVER_INIT
|
// [0] u16 TOSERVER_INIT
|
||||||
// [2] u8 SER_FMT_VER_HIGHEST
|
// [2] u8 SER_FMT_VER_HIGHEST
|
||||||
// [3] u8[20] player_name
|
// [3] u8[20] player_name
|
||||||
// [23] u8[28] password
|
// [23] u8[28] password (new in some version)
|
||||||
SharedBuffer<u8> data(2+1+PLAYERNAME_SIZE+PASSWORD_SIZE);
|
// [51] u16 client network protocol version (new in some version)
|
||||||
|
SharedBuffer<u8> data(2+1+PLAYERNAME_SIZE+PASSWORD_SIZE+2);
|
||||||
writeU16(&data[0], TOSERVER_INIT);
|
writeU16(&data[0], TOSERVER_INIT);
|
||||||
writeU8(&data[2], SER_FMT_VER_HIGHEST);
|
writeU8(&data[2], SER_FMT_VER_HIGHEST);
|
||||||
|
|
||||||
|
@ -428,6 +429,9 @@ void Client::step(float dtime)
|
||||||
|
|
||||||
memset((char*)&data[23], 0, PASSWORD_SIZE);
|
memset((char*)&data[23], 0, PASSWORD_SIZE);
|
||||||
snprintf((char*)&data[23], PASSWORD_SIZE, "%s", m_password.c_str());
|
snprintf((char*)&data[23], PASSWORD_SIZE, "%s", m_password.c_str());
|
||||||
|
|
||||||
|
// This should be incremented in each version
|
||||||
|
writeU16(&data[51], 1);
|
||||||
|
|
||||||
// Send as unreliable
|
// Send as unreliable
|
||||||
Send(0, data, false);
|
Send(0, data, false);
|
||||||
|
|
|
@ -171,7 +171,8 @@ enum ToServerCommand
|
||||||
[0] u16 TOSERVER_INIT
|
[0] u16 TOSERVER_INIT
|
||||||
[2] u8 SER_FMT_VER_HIGHEST
|
[2] u8 SER_FMT_VER_HIGHEST
|
||||||
[3] u8[20] player_name
|
[3] u8[20] player_name
|
||||||
[23] u8[28] password
|
[23] u8[28] password (new in some version)
|
||||||
|
[51] u16 client network protocol version (new in some version)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TOSERVER_INIT2 = 0x11,
|
TOSERVER_INIT2 = 0x11,
|
||||||
|
|
|
@ -1966,6 +1966,23 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
derr_server<<DTIME<<"Server: Cannot negotiate "
|
derr_server<<DTIME<<"Server: Cannot negotiate "
|
||||||
"serialization version with peer "
|
"serialization version with peer "
|
||||||
<<peer_id<<std::endl;
|
<<peer_id<<std::endl;
|
||||||
|
SendAccessDenied(m_con, peer_id,
|
||||||
|
L"Your client is too old (map format)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check network protocol version
|
||||||
|
*/
|
||||||
|
u16 net_proto_version = 0;
|
||||||
|
if(datasize >= 2+1+PLAYERNAME_SIZE+PASSWORD_SIZE+2)
|
||||||
|
{
|
||||||
|
net_proto_version = readU16(&data[2+1+PLAYERNAME_SIZE+PASSWORD_SIZE]);
|
||||||
|
}
|
||||||
|
if(net_proto_version == 0)
|
||||||
|
{
|
||||||
|
SendAccessDenied(m_con, peer_id,
|
||||||
|
L"Your client is too old (network protocol)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1999,7 +2016,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
// Get password
|
// Get password
|
||||||
char password[PASSWORD_SIZE];
|
char password[PASSWORD_SIZE];
|
||||||
if(datasize == 2+1+PLAYERNAME_SIZE)
|
if(datasize >= 2+1+PLAYERNAME_SIZE)
|
||||||
{
|
{
|
||||||
// old version - assume blank password
|
// old version - assume blank password
|
||||||
password[0] = 0;
|
password[0] = 0;
|
||||||
|
|
Loading…
Reference in New Issue