Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ void CPacketHandler::Packet_ServerDisconnected(NetBitStreamInterface& bitStream)
strReason = _("Disconnected: Serial verification failed");
strErrorCode = _E("CD44");
break;
case ePlayerDisconnectType::SERIAL_DUPLICATE:
strReason = _("Disconnected: Serial already in use");
strErrorCode = _E("CD50");
break;
case ePlayerDisconnectType::CONNECTION_DESYNC:
strReason = _("Disconnected: Connection desync %s");
strErrorCode = _E("CD45");
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CPacketHandler
ELEMENT_FAILURE,
GENERAL_REFUSED,
SERIAL_VERIFICATION,
SERIAL_DUPLICATE,
CONNECTION_DESYNC,
BAN,
KICK,
Expand Down
13 changes: 13 additions & 0 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,19 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)
return;
}

// Check if another player is using the same serial
CPlayer* playerExisting = m_pPlayerManager->GetBySerial(strSerial);

if (playerExisting)
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Serial already in use) (%s)\n", szNick, strIPAndSerial.c_str());

// Tell the player the problem
DisconnectPlayer(this, *pPlayer, CPlayerDisconnectedPacket::SERIAL_DUPLICATE);
return;
}

// Check the nick is valid
if (!CheckNickProvided(szNick))
{
Expand Down
13 changes: 13 additions & 0 deletions Server/mods/deathmatch/logic/CPlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ CPlayer* CPlayerManager::Get(const char* szNick, bool bCaseSensitive)
return NULL;
}

CPlayer* CPlayerManager::GetBySerial(const SString& serial) const noexcept
{
for (auto& player : m_Players)
{
if (player->GetSerial() == serial)
{
return player;
}
}

return nullptr;
}

void CPlayerManager::DeleteAll()
{
// Delete all the items in the list
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CPlayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CPlayerManager

CPlayer* Get(const NetServerPlayerID& PlayerSocket);
CPlayer* Get(const char* szNick, bool bCaseSensitive = false);
CPlayer* GetBySerial(const SString& serial) const noexcept;

std::list<CPlayer*>::const_iterator IterBegin() { return m_Players.begin(); };
std::list<CPlayer*>::const_iterator IterEnd() { return m_Players.end(); };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CPlayerDisconnectedPacket final : public CPacket
ELEMENT_FAILURE,
GENERAL_REFUSED,
SERIAL_VERIFICATION,
SERIAL_DUPLICATE,
CONNECTION_DESYNC,
BAN,
KICK,
Expand Down
Loading