Skip to content

Commit 1a9d402

Browse files
committed
New enum & logic
New enum called SERIAL_DUPLICATE and logic that checks if there are no other players on the server having the same serial
1 parent 3864cee commit 1a9d402

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ void CPacketHandler::Packet_ServerDisconnected(NetBitStreamInterface& bitStream)
572572
strReason = _("Disconnected: Serial verification failed");
573573
strErrorCode = _E("CD44");
574574
break;
575+
case ePlayerDisconnectType::SERIAL_DUPLICATE:
576+
strReason = _("Disconnected: Serial already in use");
577+
strErrorCode = _E("CD50");
578+
break;
575579
case ePlayerDisconnectType::CONNECTION_DESYNC:
576580
strReason = _("Disconnected: Connection desync %s");
577581
strErrorCode = _E("CD45");

Client/mods/deathmatch/logic/CPacketHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CPacketHandler
3838
ELEMENT_FAILURE,
3939
GENERAL_REFUSED,
4040
SERIAL_VERIFICATION,
41+
SERIAL_DUPLICATE,
4142
CONNECTION_DESYNC,
4243
BAN,
4344
KICK,

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,19 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)
17981798
return;
17991799
}
18001800

1801+
// Check if another player is using the same serial
1802+
CPlayer* playerExisting = m_pPlayerManager->GetBySerial(strSerial);
1803+
1804+
if (playerExisting)
1805+
{
1806+
// Tell the console
1807+
CLogger::LogPrintf("CONNECT: %s failed to connect (Serial already in use) (%s)\n", szNick, strIPAndSerial.c_str());
1808+
1809+
// Tell the player the problem
1810+
DisconnectPlayer(this, *pPlayer, CPlayerDisconnectedPacket::SERIAL_DUPLICATE);
1811+
return;
1812+
}
1813+
18011814
// Check the nick is valid
18021815
if (!CheckNickProvided(szNick))
18031816
{

Server/mods/deathmatch/logic/packets/CPlayerDisconnectedPacket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class CPlayerDisconnectedPacket final : public CPacket
3535
ELEMENT_FAILURE,
3636
GENERAL_REFUSED,
3737
SERIAL_VERIFICATION,
38+
SERIAL_DUPLICATE,
3839
CONNECTION_DESYNC,
3940
BAN,
4041
KICK,

0 commit comments

Comments
 (0)