diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-13 14:14:48 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-13 14:28:20 +0100 |
commit | 9f3fc7201beedc66f974d54415b8e3fedb13ccb3 (patch) | |
tree | 2c4920975d365ff1531b0fbf84fe1b94f4883f71 /src/network/packethandlers | |
parent | 126f36c2e6c153f2791db743a8ceca44b6b36b10 (diff) | |
download | minetest-9f3fc7201beedc66f974d54415b8e3fedb13ccb3.tar.gz minetest-9f3fc7201beedc66f974d54415b8e3fedb13ccb3.tar.bz2 minetest-9f3fc7201beedc66f974d54415b8e3fedb13ccb3.zip |
Handle the newly added TOCLIENT_ACCESS_DENIED and TOCLIENT_DELETE_PARTICLESPAWNER
* Rename the handlers from _Legacy to regular, because here we can use same handlers
* Fix some packet names and pseudo handlers
Diffstat (limited to 'src/network/packethandlers')
-rw-r--r-- | src/network/packethandlers/client.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/network/packethandlers/client.cpp b/src/network/packethandlers/client.cpp index 7b3adeda4..ae24157e0 100644 --- a/src/network/packethandlers/client.cpp +++ b/src/network/packethandlers/client.cpp @@ -89,15 +89,32 @@ void Client::handleCommand_Init(NetworkPacket* pkt) m_state = LC_Init; } -void Client::handleCommand_AccessDenied_Legacy(NetworkPacket* pkt) +void Client::handleCommand_AccessDenied(NetworkPacket* pkt) { // The server didn't like our password. Note, this needs // to be processed even if the serialisation format has // not been agreed yet, the same as TOCLIENT_INIT. m_access_denied = true; m_access_denied_reason = L"Unknown"; - if (pkt->getSize() >= 2) { - *pkt >> m_access_denied_reason; + + if (pkt->getCommand() == TOCLIENT_ACCESS_DENIED) { + u8 denyCode = SERVER_ACCESSDENIED_UNEXPECTED_DATA; + if(pkt->getSize() >= 1) { + *pkt >> denyCode; + } + if (denyCode == SERVER_ACCESSDENIED_CUSTOM_STRING) { + *pkt >> m_access_denied_reason; + } + else if (denyCode < SERVER_ACCESSDENIED_MAX) { + m_access_denied_reason = accessDeniedStrings[denyCode]; + } + } + // 13/03/15 Legacy code from 0.4.12 and lesser. must stay 1 year + // for compat with old clients + else { + if (pkt->getSize() >= 2) { + *pkt >> m_access_denied_reason; + } } } @@ -822,15 +839,24 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) } -void Client::handleCommand_DeleteParticleSpawner_Legacy(NetworkPacket* pkt) +void Client::handleCommand_DeleteParticleSpawner(NetworkPacket* pkt) { - u16 id; + 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; event.type = CE_DELETE_PARTICLESPAWNER; - event.delete_particlespawner.id = (u32) id; + event.delete_particlespawner.id = + (pkt->getCommand() == TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY ? (u32) legacy_id : id); m_client_event_queue.push(event); } |