Skip to content

Commit

Permalink
Check for duplicate login in TOSERVER_INIT handler (#11017)
Browse files Browse the repository at this point in the history
i.e. checks for duplicate logins before sending all media data to the client.
  • Loading branch information
LizzyFleckenstein03 committed Mar 19, 2021
1 parent 59a1b53 commit 492110a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/network/serverpackethandler.cpp
Expand Up @@ -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

Expand Down

0 comments on commit 492110a

Please sign in to comment.