62 changes: 31 additions & 31 deletions src/clientiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@ class EmergeManager;
| |
\-----------------/
| depending of the incoming packet
+---------------------------------------
v v
+-----------------------------+ +-----------------------------+
|IN: | |IN: |
| TOSERVER_INIT_LEGACY |----- | TOSERVER_INIT | invalid playername,
+-----------------------------+ | +-----------------------------+ password (for _LEGACY),
| | | or denied by mod
| Auth ok -------------------+---------------------------------
v v |
+-----------------------------+ +-----------------------------+ |
|OUT: | |OUT: | |
| TOCLIENT_INIT_LEGACY | | TOCLIENT_HELLO | |
+-----------------------------+ +-----------------------------+ |
| | |
| | |
v v |
/-----------------\ /-----------------\ |
| | | | |
| AwaitingInit2 |<--------- | HelloSent | |
| | | | | |
\-----------------/ | \-----------------/ |
| | | |
+-----------------------------+ | *-----------------------------* Auth fails |
|IN: | | |Authentication, depending on |-----------------+
----------------------------------------
v
+-----------------------------+
|IN: |
| TOSERVER_INIT |
+-----------------------------+
| invalid playername
| or denied by mod
v
+-----------------------------+
|OUT: |
| TOCLIENT_HELLO |
+-----------------------------+
|
|
v
/-----------------\ /-----------------\
| | | |
| AwaitingInit2 |<--------- | HelloSent |
| | | | |
\-----------------/ | \-----------------/
| | |
+-----------------------------+ | *-----------------------------* Auth fails
|IN: | | |Authentication, depending on |------------------
| TOSERVER_INIT2 | | | packet sent by client | |
+-----------------------------+ | *-----------------------------* |
| | | |
Expand Down Expand Up @@ -101,18 +101,18 @@ class EmergeManager;
| | +-----------------------------+ |
| DefinitionsSent | |IN: | |
| | | TOSERVER_REQUEST_MEDIA | |
\-----------------/ | TOSERVER_RECEIVED_MEDIA | |
\-----------------/ | | |
| +-----------------------------+ |
| ^ | |
| ----------------------------- |
v |
v v
+-----------------------------+ --------------------------------+
|IN: | | |
|IN: | | ^
| TOSERVER_CLIENT_READY | v |
+-----------------------------+ +-------------------------------+ |
| |OUT: | |
v | TOCLIENT_ACCESS_DENIED_LEGAGY | |
+-----------------------------+ +-------------------------------+ |
+-----------------------------+ +------------------------+ |
| |OUT: | |
v | TOCLIENT_ACCESS_DENIED | |
+-----------------------------+ +------------------------+ |
|OUT: | | |
| TOCLIENT_MOVE_PLAYER | v |
| TOCLIENT_PRIVILEGES | /-----------------\ |
Expand Down
3 changes: 1 addition & 2 deletions src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("screenshot_quality", "0");
settings->setDefault("client_unload_unused_data_timeout", "600");
settings->setDefault("client_mapblock_limit", "5000");
settings->setDefault("enable_build_where_you_stand", "false" );
settings->setDefault("send_pre_v25_init", "false");
settings->setDefault("enable_build_where_you_stand", "false");
settings->setDefault("curl_timeout", "5000");
settings->setDefault("curl_parallel_limit", "8");
settings->setDefault("curl_file_download_timeout", "300000");
Expand Down
22 changes: 11 additions & 11 deletions src/network/clientopcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
null_command_handler, // 0x0D
null_command_handler, // 0x0E
null_command_handler, // 0x0F
{ "TOCLIENT_INIT", TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_InitLegacy }, // 0x10
null_command_handler, // 0x10
null_command_handler,
null_command_handler,
null_command_handler,
Expand Down Expand Up @@ -96,7 +96,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
{ "TOCLIENT_MOVEMENT", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Movement }, // 0x45
{ "TOCLIENT_SPAWN_PARTICLE", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_SpawnParticle }, // 0x46
{ "TOCLIENT_ADD_PARTICLESPAWNER", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_AddParticleSpawner }, // 0x47
{ "TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DeleteParticleSpawner }, // 0x48
null_command_handler,
{ "TOCLIENT_HUDADD", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudAdd }, // 0x49
{ "TOCLIENT_HUDRM", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudRemove }, // 0x4a
{ "TOCLIENT_HUDCHANGE", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudChange }, // 0x4b
Expand Down Expand Up @@ -143,7 +143,7 @@ const ServerCommandFactory serverCommandFactoryTable[TOSERVER_NUM_MSG_TYPES] =
null_command_factory, // 0x0d
null_command_factory, // 0x0e
null_command_factory, // 0x0F
{ "TOSERVER_INIT_LEGACY", 1, false }, // 0x10
null_command_factory, // 0x10
{ "TOSERVER_INIT2", 1, true }, // 0x11
null_command_factory, // 0x12
null_command_factory, // 0x13
Expand All @@ -166,22 +166,22 @@ const ServerCommandFactory serverCommandFactoryTable[TOSERVER_NUM_MSG_TYPES] =
{ "TOSERVER_GOTBLOCKS", 2, true }, // 0x24
{ "TOSERVER_DELETEDBLOCKS", 2, true }, // 0x25
null_command_factory, // 0x26
{ "TOSERVER_CLICK_OBJECT", 0, false }, // 0x27
{ "TOSERVER_GROUND_ACTION", 0, false }, // 0x28
{ "TOSERVER_RELEASE", 0, false }, // 0x29
null_command_factory, // 0x27
null_command_factory, // 0x28
null_command_factory, // 0x29
null_command_factory, // 0x2a
null_command_factory, // 0x2b
null_command_factory, // 0x2c
null_command_factory, // 0x2d
null_command_factory, // 0x2e
null_command_factory, // 0x2f
{ "TOSERVER_SIGNTEXT", 0, false }, // 0x30
null_command_factory, // 0x30
{ "TOSERVER_INVENTORY_ACTION", 0, true }, // 0x31
{ "TOSERVER_CHAT_MESSAGE", 0, true }, // 0x32
{ "TOSERVER_SIGNNODETEXT", 0, false }, // 0x33
{ "TOSERVER_CLICK_ACTIVEOBJECT", 0, false }, // 0x34
null_command_factory, // 0x33
null_command_factory, // 0x34
{ "TOSERVER_DAMAGE", 0, true }, // 0x35
{ "TOSERVER_PASSWORD_LEGACY", 0, true }, // 0x36
null_command_factory, // 0x36
{ "TOSERVER_PLAYERITEM", 0, true }, // 0x37
{ "TOSERVER_RESPAWN", 0, true }, // 0x38
{ "TOSERVER_INTERACT", 0, true }, // 0x39
Expand All @@ -192,7 +192,7 @@ const ServerCommandFactory serverCommandFactoryTable[TOSERVER_NUM_MSG_TYPES] =
null_command_factory, // 0x3e
null_command_factory, // 0x3f
{ "TOSERVER_REQUEST_MEDIA", 1, true }, // 0x40
{ "TOSERVER_RECEIVED_MEDIA", 1, true }, // 0x41
null_command_factory, // 0x41
{ "TOSERVER_BREATH", 0, true }, // 0x42 old TOSERVER_BREATH. Ignored by servers
{ "TOSERVER_CLIENT_READY", 0, true }, // 0x43
null_command_factory, // 0x44
Expand Down
145 changes: 39 additions & 106 deletions src/network/clientpackethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ void Client::handleCommand_Hello(NetworkPacket* pkt)
// we recieved a TOCLIENT_HELLO while auth was already going on
errorstream << "Client: TOCLIENT_HELLO while auth was already going on"
<< "(chosen_mech=" << m_chosen_auth_mech << ")." << std::endl;
if ((m_chosen_auth_mech == AUTH_MECHANISM_SRP)
|| (m_chosen_auth_mech == AUTH_MECHANISM_LEGACY_PASSWORD)) {
if (m_chosen_auth_mech == AUTH_MECHANISM_SRP) {
srp_user_delete((SRPUser *) m_auth_data);
m_auth_data = 0;
}
Expand Down Expand Up @@ -157,60 +156,6 @@ void Client::handleCommand_DenySudoMode(NetworkPacket* pkt)
// reset everything and be sad
deleteAuthData();
}
void Client::handleCommand_InitLegacy(NetworkPacket* pkt)
{
if (pkt->getSize() < 1)
return;

u8 server_ser_ver;
*pkt >> server_ser_ver;

infostream << "Client: TOCLIENT_INIT_LEGACY received with "
"server_ser_ver=" << ((int)server_ser_ver & 0xff) << std::endl;

if (!ser_ver_supported(server_ser_ver)) {
infostream << "Client: TOCLIENT_INIT_LEGACY: Server sent "
<< "unsupported ser_fmt_ver"<< std::endl;
return;
}

m_server_ser_ver = server_ser_ver;

// We can be totally wrong with this guess
// but we only need some value < 25.
m_proto_ver = 24;

// Get player position
v3s16 playerpos_s16(0, BS * 2 + BS * 20, 0);
if (pkt->getSize() >= 1 + 6) {
*pkt >> playerpos_s16;
}
v3f playerpos_f = intToFloat(playerpos_s16, BS) - v3f(0, BS / 2, 0);


// Set player position
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
player->setPosition(playerpos_f);

if (pkt->getSize() >= 1 + 6 + 8) {
// Get map seed
*pkt >> m_map_seed;
infostream << "Client: received map seed: " << m_map_seed << std::endl;
}

if (pkt->getSize() >= 1 + 6 + 8 + 4) {
*pkt >> m_recommended_send_interval;
infostream << "Client: received recommended send interval "
<< m_recommended_send_interval<<std::endl;
}

// Reply to server
NetworkPacket resp_pkt(TOSERVER_INIT2, 0);
Send(&resp_pkt);

m_state = LC_Init;
}

void Client::handleCommand_AccessDenied(NetworkPacket* pkt)
{
Expand All @@ -220,44 +165,44 @@ void Client::handleCommand_AccessDenied(NetworkPacket* pkt)
m_access_denied = true;
m_access_denied_reason = "Unknown";

if (pkt->getCommand() == TOCLIENT_ACCESS_DENIED) {
if (pkt->getSize() < 1)
return;

u8 denyCode = SERVER_ACCESSDENIED_UNEXPECTED_DATA;
*pkt >> denyCode;
if (denyCode == SERVER_ACCESSDENIED_SHUTDOWN ||
denyCode == SERVER_ACCESSDENIED_CRASH) {
*pkt >> m_access_denied_reason;
if (m_access_denied_reason.empty()) {
m_access_denied_reason = accessDeniedStrings[denyCode];
}
u8 reconnect;
*pkt >> reconnect;
m_access_denied_reconnect = reconnect & 1;
} else if (denyCode == SERVER_ACCESSDENIED_CUSTOM_STRING) {
*pkt >> m_access_denied_reason;
} else if (denyCode < SERVER_ACCESSDENIED_MAX) {
m_access_denied_reason = accessDeniedStrings[denyCode];
} else {
// Allow us to add new error messages to the
// protocol without raising the protocol version, if we want to.
// Until then (which may be never), this is outside
// of the defined protocol.
*pkt >> m_access_denied_reason;
if (m_access_denied_reason.empty()) {
m_access_denied_reason = "Unknown";
}
}
}
// 13/03/15 Legacy code from 0.4.12 and lesser. must stay 1 year
// for compat with old clients
else {
if (pkt->getCommand() != TOCLIENT_ACCESS_DENIED) {
// 13/03/15 Legacy code from 0.4.12 and lesser but is still used
// in some places of the server code
if (pkt->getSize() >= 2) {
std::wstring wide_reason;
*pkt >> wide_reason;
m_access_denied_reason = wide_to_utf8(wide_reason);
}
return;
}

if (pkt->getSize() < 1)
return;

u8 denyCode = SERVER_ACCESSDENIED_UNEXPECTED_DATA;
*pkt >> denyCode;
if (denyCode == SERVER_ACCESSDENIED_SHUTDOWN ||
denyCode == SERVER_ACCESSDENIED_CRASH) {
*pkt >> m_access_denied_reason;
if (m_access_denied_reason.empty()) {
m_access_denied_reason = accessDeniedStrings[denyCode];
}
u8 reconnect;
*pkt >> reconnect;
m_access_denied_reconnect = reconnect & 1;
} else if (denyCode == SERVER_ACCESSDENIED_CUSTOM_STRING) {
*pkt >> m_access_denied_reason;
} else if (denyCode < SERVER_ACCESSDENIED_MAX) {
m_access_denied_reason = accessDeniedStrings[denyCode];
} else {
// Allow us to add new error messages to the
// protocol without raising the protocol version, if we want to.
// Until then (which may be never), this is outside
// of the defined protocol.
*pkt >> m_access_denied_reason;
if (m_access_denied_reason.empty()) {
m_access_denied_reason = "Unknown";
}
}
}

Expand Down Expand Up @@ -1065,23 +1010,12 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt)

void Client::handleCommand_DeleteParticleSpawner(NetworkPacket* pkt)
{
u16 legacy_id;
u32 id;

// Modification set 13/03/15, 1 year of compat for protocol v24
if (pkt->getCommand() == TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY) {
*pkt >> legacy_id;
}
else {
*pkt >> id;
}

*pkt >> id;

ClientEvent *event = new ClientEvent();
event->type = CE_DELETE_PARTICLESPAWNER;
event->delete_particlespawner.id =
(pkt->getCommand() == TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY ?
(u32) legacy_id : id);
event->delete_particlespawner.id = id;

m_client_event_queue.push(event);
}
Expand Down Expand Up @@ -1360,9 +1294,8 @@ void Client::handleCommand_UpdatePlayerList(NetworkPacket* pkt)

void Client::handleCommand_SrpBytesSandB(NetworkPacket* pkt)
{
if ((m_chosen_auth_mech != AUTH_MECHANISM_LEGACY_PASSWORD)
&& (m_chosen_auth_mech != AUTH_MECHANISM_SRP)) {
errorstream << "Client: Recieved SRP S_B login message,"
if (m_chosen_auth_mech != AUTH_MECHANISM_SRP) {
errorstream << "Client: Received SRP S_B login message,"
<< " but wasn't supposed to (chosen_mech="
<< m_chosen_auth_mech << ")." << std::endl;
return;
Expand All @@ -1375,7 +1308,7 @@ void Client::handleCommand_SrpBytesSandB(NetworkPacket* pkt)
std::string B;
*pkt >> s >> B;

infostream << "Client: Recieved TOCLIENT_SRP_BYTES_S_B." << std::endl;
infostream << "Client: Received TOCLIENT_SRP_BYTES_S_B." << std::endl;

srp_user_process_challenge(usr, (const unsigned char *) s.c_str(), s.size(),
(const unsigned char *) B.c_str(), B.size(),
Expand Down
172 changes: 14 additions & 158 deletions src/network/networkprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// The minimal version depends on whether
// send_pre_v25_init is enabled or not
#define CLIENT_PROTOCOL_VERSION_MIN 36
#define CLIENT_PROTOCOL_VERSION_MIN_LEGACY 24
#define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION

// Constant that differentiates the protocol from random data and other protocols
Expand Down Expand Up @@ -235,26 +234,15 @@ enum ToClientCommand
/*
Signals client that sudo mode auth failed.
*/
TOCLIENT_INIT_LEGACY = 0x10,
/*
Server's reply to TOSERVER_INIT.
Sent second after connected.
[0] u16 TOSERVER_INIT
[2] u8 deployed version
[3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
[12] u64 map seed (new as of 2011-02-27)
[20] f1000 recommended send interval (in seconds) (new as of 14)
NOTE: The position in here is deprecated; position is
explicitly sent afterwards
*/
TOCLIENT_ACCESS_DENIED = 0x0A,
/*
u8 reason
std::string custom reason (if needed, otherwise "")
u8 (bool) reconnect
*/

TOCLIENT_INIT_LEGACY = 0x10, // Obsolete

TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
TOCLIENT_ADDNODE = 0x21,
/*
Expand All @@ -265,34 +253,9 @@ enum ToClientCommand
TOCLIENT_REMOVENODE = 0x22,

TOCLIENT_PLAYERPOS = 0x23, // Obsolete
/*
[0] u16 command
// Followed by an arbitary number of these:
// Number is determined from packet length.
[N] u16 peer_id
[N+2] v3s32 position*100
[N+2+12] v3s32 speed*100
[N+2+12+12] s32 pitch*100
[N+2+12+12+4] s32 yaw*100
*/

TOCLIENT_PLAYERINFO = 0x24, // Obsolete
/*
[0] u16 command
// Followed by an arbitary number of these:
// Number is determined from packet length.
[N] u16 peer_id
[N] char[20] name
*/

TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete

TOCLIENT_SECTORMETA = 0x26, // Obsolete
/*
[0] u16 command
[2] u8 sector count
[3...] v2s16 pos + sector metadata
*/

TOCLIENT_INVENTORY = 0x27,
/*
Expand All @@ -301,21 +264,6 @@ enum ToClientCommand
*/

TOCLIENT_OBJECTDATA = 0x28, // Obsolete
/*
Sent as unreliable.
u16 number of player positions
for each player:
u16 peer_id
v3s32 position*100
v3s32 speed*100
s32 pitch*100
s32 yaw*100
u16 count of blocks
for each block:
v3s16 blockpos
block objects
*/

TOCLIENT_TIME_OF_DAY = 0x29,
/*
Expand All @@ -341,11 +289,7 @@ enum ToClientCommand
wstring message
*/

TOCLIENT_CHAT_MESSAGE_OLD = 0x30, // Deprecated by proto v35
/*
u16 length
wstring message
*/
TOCLIENT_CHAT_MESSAGE_OLD = 0x30, // Obsolete

TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
/*
Expand Down Expand Up @@ -391,14 +335,6 @@ enum ToClientCommand
*/

TOCLIENT_PLAYERITEM = 0x36, // Obsolete
/*
u16 count of player items
for all player items {
u16 peer id
u16 length of serialized item
string serialized item
}
*/

TOCLIENT_DEATHSCREEN = 0x37,
/*
Expand Down Expand Up @@ -557,10 +493,7 @@ enum ToClientCommand
u8 collision_removal
*/

TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48,
/*
u16 id
*/
TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48, // Obsolete

TOCLIENT_HUDADD = 0x49,
/*
Expand Down Expand Up @@ -679,7 +612,7 @@ enum ToClientCommand

TOCLIENT_SRP_BYTES_S_B = 0x60,
/*
Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP.
Belonging to AUTH_MECHANISM_SRP.
std::string bytes_s
std::string bytes_B
Expand All @@ -701,17 +634,7 @@ enum ToServerCommand
std::string player name
*/

TOSERVER_INIT_LEGACY = 0x10,
/*
Sent first after connected.
[0] u16 TOSERVER_INIT_LEGACY
[2] u8 SER_FMT_VER_HIGHEST_READ
[3] u8[20] player_name
[23] u8[28] password (new in some version)
[51] u16 minimum supported network protocol version (added sometime)
[53] u16 maximum supported network protocol version (added later than the previous one)
*/
TOSERVER_INIT_LEGACY = 0x10, // Obsolete

TOSERVER_INIT2 = 0x11,
/*
Expand All @@ -721,7 +644,7 @@ enum ToServerCommand
[0] u16 TOSERVER_INIT2
*/

TOSERVER_GETBLOCK=0x20, // Obsolete
TOSERVER_GETBLOCK = 0x20, // Obsolete
TOSERVER_ADDNODE = 0x21, // Obsolete
TOSERVER_REMOVENODE = 0x22, // Obsolete

Expand Down Expand Up @@ -756,48 +679,10 @@ enum ToServerCommand
*/

TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
/*
[0] u16 command
[2] v3s16 pos
[8] u16 i
*/

TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
/*
length: 13
[0] u16 command
[2] u8 button (0=left, 1=right)
[3] v3s16 blockpos
[9] s16 id
[11] u16 item
*/

TOSERVER_GROUND_ACTION = 0x28, // Obsolete
/*
length: 17
[0] u16 command
[2] u8 action
[3] v3s16 nodepos_undersurface
[9] v3s16 nodepos_abovesurface
[15] u16 item
actions:
0: start digging (from undersurface)
1: place block (to abovesurface)
2: stop digging (all parameters ignored)
3: digging completed
*/

TOSERVER_RELEASE = 0x29, // Obsolete

// (oops, there is some gap here)

TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
/*
v3s16 blockpos
s16 id
u16 textlen
textdata
*/
TOSERVER_SIGNTEXT = 0x30, // Obsolete

TOSERVER_INVENTORY_ACTION = 0x31,
/*
Expand All @@ -810,35 +695,15 @@ enum ToServerCommand
wstring message
*/

TOSERVER_SIGNNODETEXT = 0x33, // obsolete
/*
v3s16 p
u16 textlen
textdata
*/

TOSERVER_SIGNNODETEXT = 0x33, // Obsolete
TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
/*
length: 7
[0] u16 command
[2] u8 button (0=left, 1=right)
[3] u16 id
[5] u16 item
*/

TOSERVER_DAMAGE = 0x35,
/*
u8 amount
*/

TOSERVER_PASSWORD_LEGACY = 0x36,
/*
Sent to change password.
[0] u16 TOSERVER_PASSWORD
[2] u8[28] old password
[30] u8[28] new password
*/
TOSERVER_PASSWORD_LEGACY = 0x36, // Obsolete

TOSERVER_PLAYERITEM = 0x37,
/*
Expand Down Expand Up @@ -866,8 +731,6 @@ enum ToServerCommand
2: digging completed
3: place block or item (to abovesurface)
4: use item
(Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
*/

TOSERVER_REMOVED_SOUNDS = 0x3a,
Expand Down Expand Up @@ -908,17 +771,10 @@ enum ToServerCommand
u16 length of name
string name
}
*/

TOSERVER_RECEIVED_MEDIA = 0x41,
/*
<no payload data>
*/

TOSERVER_RECEIVED_MEDIA = 0x41, // Obsolete
TOSERVER_BREATH = 0x42, // Obsolete
/*
u16 breath
*/

TOSERVER_CLIENT_READY = 0x43,
/*
Expand All @@ -941,7 +797,7 @@ enum ToServerCommand

TOSERVER_SRP_BYTES_A = 0x51,
/*
Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP,
Belonging to AUTH_MECHANISM_SRP,
depending on current_login_based_on.
std::string bytes_A
Expand All @@ -952,7 +808,7 @@ enum ToServerCommand

TOSERVER_SRP_BYTES_M = 0x52,
/*
Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP.
Belonging to AUTH_MECHANISM_SRP.
std::string bytes_M
*/
Expand Down
30 changes: 15 additions & 15 deletions src/network/serveropcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] =
null_command_handler, // 0x0d
null_command_handler, // 0x0e
null_command_handler, // 0x0f
{ "TOSERVER_INIT_LEGACY", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init_Legacy }, // 0x10
null_command_handler, // 0x10
{ "TOSERVER_INIT2", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init2 }, // 0x11
null_command_handler, // 0x12
null_command_handler, // 0x13
Expand All @@ -63,22 +63,22 @@ const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] =
{ "TOSERVER_GOTBLOCKS", TOSERVER_STATE_STARTUP, &Server::handleCommand_GotBlocks }, // 0x24
{ "TOSERVER_DELETEDBLOCKS", TOSERVER_STATE_INGAME, &Server::handleCommand_DeletedBlocks }, // 0x25
null_command_handler, // 0x26
{ "TOSERVER_CLICK_OBJECT", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x27
{ "TOSERVER_GROUND_ACTION", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x28
{ "TOSERVER_RELEASE", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x29
null_command_handler, // 0x27
null_command_handler, // 0x28
null_command_handler, // 0x29
null_command_handler, // 0x2a
null_command_handler, // 0x2b
null_command_handler, // 0x2c
null_command_handler, // 0x2d
null_command_handler, // 0x2e
null_command_handler, // 0x2f
{ "TOSERVER_SIGNTEXT", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x30
null_command_handler, // 0x30
{ "TOSERVER_INVENTORY_ACTION", TOSERVER_STATE_INGAME, &Server::handleCommand_InventoryAction }, // 0x31
{ "TOSERVER_CHAT_MESSAGE", TOSERVER_STATE_INGAME, &Server::handleCommand_ChatMessage }, // 0x32
{ "TOSERVER_SIGNNODETEXT", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x33
{ "TOSERVER_CLICK_ACTIVEOBJECT", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x34
null_command_handler, // 0x33
null_command_handler, // 0x34
{ "TOSERVER_DAMAGE", TOSERVER_STATE_INGAME, &Server::handleCommand_Damage }, // 0x35
{ "TOSERVER_PASSWORD_LEGACY", TOSERVER_STATE_INGAME, &Server::handleCommand_Password }, // 0x36
null_command_handler, // 0x36
{ "TOSERVER_PLAYERITEM", TOSERVER_STATE_INGAME, &Server::handleCommand_PlayerItem }, // 0x37
{ "TOSERVER_RESPAWN", TOSERVER_STATE_INGAME, &Server::handleCommand_Respawn }, // 0x38
{ "TOSERVER_INTERACT", TOSERVER_STATE_INGAME, &Server::handleCommand_Interact }, // 0x39
Expand All @@ -89,8 +89,8 @@ const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] =
null_command_handler, // 0x3e
null_command_handler, // 0x3f
{ "TOSERVER_REQUEST_MEDIA", TOSERVER_STATE_STARTUP, &Server::handleCommand_RequestMedia }, // 0x40
{ "TOSERVER_RECEIVED_MEDIA", TOSERVER_STATE_STARTUP, &Server::handleCommand_Deprecated }, // 0x41 not used by the server since protocol version 23
{ "TOSERVER_BREATH", TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x42 Old breath model which is now deprecated for anticheating
null_command_handler, // 0x41
null_command_handler, // 0x42
{ "TOSERVER_CLIENT_READY", TOSERVER_STATE_STARTUP, &Server::handleCommand_ClientReady }, // 0x43
null_command_handler, // 0x44
null_command_handler, // 0x45
Expand Down Expand Up @@ -161,18 +161,18 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
null_command_factory,
null_command_factory,
{ "TOCLIENT_CHAT_MESSAGE", 0, true }, // 0x2F
{ "TOCLIENT_CHAT_MESSAGE_OLD", 0, true }, // 0x30
null_command_factory, // 0x30
{ "TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", 0, true }, // 0x31
{ "TOCLIENT_ACTIVE_OBJECT_MESSAGES", 0, true }, // 0x32 Special packet, sent by 0 (rel) and 1 (unrel) channel
{ "TOCLIENT_HP", 0, true }, // 0x33
{ "TOCLIENT_MOVE_PLAYER", 0, true }, // 0x34
{ "TOCLIENT_ACCESS_DENIED_LEGACY", 0, true }, // 0x35
{ "TOCLIENT_PLAYERITEM", 0, false }, // 0x36 obsolete
null_command_factory, // 0x36
{ "TOCLIENT_DEATHSCREEN", 0, true }, // 0x37
{ "TOCLIENT_MEDIA", 2, true }, // 0x38
{ "TOCLIENT_TOOLDEF", 0, false }, // 0x39 obsolete
null_command_factory, // 0x39
{ "TOCLIENT_NODEDEF", 0, true }, // 0x3a
{ "TOCLIENT_CRAFTITEMDEF", 0, false }, // 0x3b obsolete
null_command_factory, // 0x3b
{ "TOCLIENT_ANNOUNCE_MEDIA", 0, true }, // 0x3c
{ "TOCLIENT_ITEMDEF", 0, true }, // 0x3d
null_command_factory,
Expand All @@ -185,7 +185,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
{ "TOCLIENT_MOVEMENT", 0, true }, // 0x45
{ "TOCLIENT_SPAWN_PARTICLE", 0, true }, // 0x46
{ "TOCLIENT_ADD_PARTICLESPAWNER", 0, true }, // 0x47
{ "TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY", 0, true }, // 0x48
null_command_factory, // 0x48
{ "TOCLIENT_HUDADD", 1, true }, // 0x49
{ "TOCLIENT_HUDRM", 1, true }, // 0x4a
{ "TOCLIENT_HUDCHANGE", 0, true }, // 0x4b
Expand Down
351 changes: 9 additions & 342 deletions src/network/serverpackethandler.cpp

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/script/lua_api/l_mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,7 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_get_min_supp_proto(lua_State *L)
{
u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ?
CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN;
lua_pushinteger(L, proto_version_min);
lua_pushinteger(L, CLIENT_PROTOCOL_VERSION_MIN);
return 1;
}

Expand Down
29 changes: 7 additions & 22 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,6 @@ void Server::SendInventory(PlayerSAO* playerSAO)

void Server::SendChatMessage(u16 peer_id, const ChatMessage &message)
{
NetworkPacket legacypkt(TOCLIENT_CHAT_MESSAGE_OLD, 0, peer_id);
legacypkt << message.message;

NetworkPacket pkt(TOCLIENT_CHAT_MESSAGE, 0, peer_id);
u8 version = 1;
u8 type = message.type;
Expand All @@ -1547,12 +1544,9 @@ void Server::SendChatMessage(u16 peer_id, const ChatMessage &message)
if (!player)
return;

if (player->protocol_version < 35)
Send(&legacypkt);
else
Send(&pkt);
Send(&pkt);
} else {
m_clients.sendToAllCompat(&pkt, &legacypkt, 35);
m_clients.sendToAll(&pkt);
}
}

Expand Down Expand Up @@ -1668,17 +1662,15 @@ void Server::SendAddParticleSpawner(u16 peer_id, u16 protocol_version,

void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id)
{
NetworkPacket pkt(TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY, 2, peer_id);
NetworkPacket pkt(TOCLIENT_DELETE_PARTICLESPAWNER, 4, peer_id);

// Ugly error in this packet
pkt << (u16) id;
pkt << id;

if (peer_id != PEER_ID_INEXISTENT) {
if (peer_id != PEER_ID_INEXISTENT)
Send(&pkt);
}
else {
else
m_clients.sendToAll(&pkt);
}

}

Expand Down Expand Up @@ -2572,14 +2564,7 @@ void Server::DenySudoAccess(u16 peer_id)
void Server::DenyAccessVerCompliant(u16 peer_id, u16 proto_ver, AccessDeniedCode reason,
const std::string &str_reason, bool reconnect)
{
if (proto_ver >= 25) {
SendAccessDenied(peer_id, reason, str_reason, reconnect);
} else {
std::wstring wreason = utf8_to_wide(
reason == SERVER_ACCESSDENIED_CUSTOM_STRING ? str_reason :
accessDeniedStrings[(u8)reason]);
SendAccessDenied_Legacy(peer_id, wreason);
}
SendAccessDenied(peer_id, reason, str_reason, reconnect);

m_clients.event(peer_id, CSE_SetDenied);
m_con->DisconnectPeer(peer_id);
Expand Down
1 change: 0 additions & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class Server : public con::PeerHandler, public MapEventReceiver,
void handleCommand_Null(NetworkPacket* pkt) {};
void handleCommand_Deprecated(NetworkPacket* pkt);
void handleCommand_Init(NetworkPacket* pkt);
void handleCommand_Init_Legacy(NetworkPacket* pkt);
void handleCommand_Init2(NetworkPacket* pkt);
void handleCommand_RequestMedia(NetworkPacket* pkt);
void handleCommand_ClientReady(NetworkPacket* pkt);
Expand Down
3 changes: 1 addition & 2 deletions src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ std::vector<ServerListSpec> getOnline()
{
std::ostringstream geturl;

u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ?
CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN;
u16 proto_version_min = CLIENT_PROTOCOL_VERSION_MIN;

geturl << g_settings->get("serverlist_url") <<
"/list?proto_version_min=" << proto_version_min <<
Expand Down