Make the playername-deduplication ("User" -> "User (2)") optional.
Have it disabled by default to fix #3604. Prevents players from rejoining as late-observers in case they timed-out on the client-side but not on the server-side. This was SVN commit r17851.
This commit is contained in:
parent
c0f321b52e
commit
f2ed0098ee
@ -349,6 +349,9 @@ xpartamupp = "wfgbot20" ; Name of the server-side xmpp client that m
|
||||
[mod]
|
||||
enabledmods = "mod public"
|
||||
|
||||
[network]
|
||||
duplicatePlayernames = false ; Rename joining player to "User (2)" if "User" is already connected, otherwise prohibit join.
|
||||
|
||||
[overlay]
|
||||
fps = "false" ; Show frames per second in top right corner
|
||||
realtime = "false" ; Show current system time in top right corner
|
||||
|
@ -57,6 +57,7 @@ function getDisconnectReason(id)
|
||||
case 4: return translate("Game has already started, no observers allowed");
|
||||
case 5: return translate("You have been kicked");
|
||||
case 6: return translate("You have been banned");
|
||||
case 7: return translate("Playername in use. If you were disconnected, retry in few seconds");
|
||||
default:
|
||||
warn("Unknown disconnect-reason ID received: " + id);
|
||||
return sprintf(translate("\\[Invalid value %(id)s]"), { "id": id });
|
||||
|
@ -65,7 +65,8 @@ enum NetDisconnectReason
|
||||
NDR_SERVER_LOADING,
|
||||
NDR_SERVER_ALREADY_IN_GAME,
|
||||
NDR_KICKED,
|
||||
NDR_BANNED
|
||||
NDR_BANNED,
|
||||
NDR_PLAYERNAME_IN_USE
|
||||
};
|
||||
|
||||
class CNetHost
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#define PS_PROTOCOL_MAGIC 0x5073013f // 'P', 's', 0x01, '?'
|
||||
#define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121 // 'P', 'c', 0x01, '!'
|
||||
#define PS_PROTOCOL_VERSION 0x01010009 // Arbitrary protocol
|
||||
#define PS_PROTOCOL_VERSION 0x01010010 // Arbitrary protocol
|
||||
#define PS_DEFAULT_PORT 0x5073 // 'P', 's'
|
||||
|
||||
// Defines the list of message types. The order of the list must not change.
|
||||
|
@ -901,7 +901,22 @@ bool CNetServerWorker::OnAuthenticate(void* context, CFsmEvent* event)
|
||||
}
|
||||
|
||||
CAuthenticateMessage* message = (CAuthenticateMessage*)event->GetParamRef();
|
||||
CStrW username = server.DeduplicatePlayerName(SanitisePlayerName(message->m_Name));
|
||||
CStrW username = SanitisePlayerName(message->m_Name);
|
||||
|
||||
// Either deduplicate or prohibit join if name is in use
|
||||
bool duplicatePlayernames = false;
|
||||
CFG_GET_VAL("network.duplicatePlayernames", duplicatePlayernames);
|
||||
if (duplicatePlayernames)
|
||||
username = server.DeduplicatePlayerName(username);
|
||||
else if (std::find_if(
|
||||
server.m_Sessions.begin(), server.m_Sessions.end(),
|
||||
[&username] (const CNetServerSession* session)
|
||||
{ return session->GetUserName() == username; })
|
||||
!= server.m_Sessions.end())
|
||||
{
|
||||
session->Disconnect(NDR_PLAYERNAME_IN_USE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disconnect banned usernames
|
||||
if (std::find(server.m_BannedPlayers.begin(), server.m_BannedPlayers.end(), username) != server.m_BannedPlayers.end())
|
||||
|
Loading…
Reference in New Issue
Block a user