diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2021-03-19 21:45:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 21:45:29 +0100 |
commit | 492110a640dd8d01838e95aba00f650b37b7ed11 (patch) | |
tree | a0fe2050dcdd7a4a915fd769f4746a100b770fe4 | |
parent | 59a1b53d675ee404cb32564262282a3ecf69d94c (diff) | |
download | minetest-492110a640dd8d01838e95aba00f650b37b7ed11.tar.gz minetest-492110a640dd8d01838e95aba00f650b37b7ed11.tar.bz2 minetest-492110a640dd8d01838e95aba00f650b37b7ed11.zip |
Check for duplicate login in TOSERVER_INIT handler (#11017)
i.e. checks for duplicate logins before sending all media data to the client.
-rw-r--r-- | src/network/serverpackethandler.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index b863e1828..5b378a083 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -174,6 +174,16 @@ void Server::handleCommand_Init(NetworkPacket* pkt) return; } + RemotePlayer *player = m_env->getPlayer(playername); + + // If player is already connected, cancel + if (player && player->getPeerId() != PEER_ID_INEXISTENT) { + actionstream << "Server: Player with name \"" << playername << + "\" tried to connect, but player with same name is already connected" << std::endl; + DenyAccess(peer_id, SERVER_ACCESSDENIED_ALREADY_CONNECTED); + return; + } + m_clients.setPlayerName(peer_id, playername); //TODO (later) case insensitivity |