From dda082c29b8813b0d8c0619737f83015ea2ec86d Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 17 Sep 2023 20:26:34 -0400 Subject: [PATCH] Check property duplicate login names * Check for duplicate login in TOSERVER_INIT handler backported https://github.com/minetest/minetest/commit/492110a640dd8d01838e95aba00f650b37b7ed11 i.e. checks for duplicate logins before sending all media data to the client --- src/network/serverpackethandler.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 768cdb734..f3134821b 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -175,6 +175,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