Ticket #3604: t3604_stop_rejoin_confusion_v4.patch

File t3604_stop_rejoin_confusion_v4.patch, 4.1 KB (added by elexis, 8 years ago)

Following a discussion with Itms: doesn't remove the DeduplicatePlayer implementation but makes it optional for developers. Adds a hint to the disconnect reason that players should retry if they got disconnected.

  • binaries/data/config/default.cfg

    server = "lobby.wildfiregames.com" ; Ad  
    347347xpartamupp = "wfgbot20"             ; Name of the server-side xmpp client that manage games
    348348
    349349[mod]
    350350enabledmods = "mod public"
    351351
     352[network]
     353prohibitIdenticalPlayernames = true ; Disable joins as "User (2)" in case someone with the name "User" is already connected
     354
    352355[overlay]
    353356fps = "false"                     ; Show frames per second in top right corner
    354357realtime = "false"                ; Show current system time in top right corner
    355358netwarnings = "true"              ; Show warnings if the network connection is bad
    356359
  • binaries/data/mods/public/gui/common/network.js

    function getDisconnectReason(id)  
    5555    case 2: return translate("Incorrect network protocol version");
    5656    case 3: return translate("Game is loading, please try later");
    5757    case 4: return translate("Game has already started, no observers allowed");
    5858    case 5: return translate("You have been kicked");
    5959    case 6: return translate("You have been banned");
     60    case 7: return translate("Playername in use. If you were disconnected, retry in few seconds");
    6061    default:
    6162        warn("Unknown disconnect-reason ID received: " + id);
    6263        return sprintf(translate("\\[Invalid value %(id)s]"), { "id": id });
    6364    }
    6465}
  • source/network/NetHost.h

    enum NetDisconnectReason  
    6363    NDR_SERVER_SHUTDOWN,
    6464    NDR_INCORRECT_PROTOCOL_VERSION,
    6565    NDR_SERVER_LOADING,
    6666    NDR_SERVER_ALREADY_IN_GAME,
    6767    NDR_KICKED,
    68     NDR_BANNED
     68    NDR_BANNED,
     69    NDR_PLAYERNAME_IN_USE
    6970};
    7071
    7172class CNetHost
    7273{
    7374public:
  • source/network/NetMessages.h

     
    2626#include "ps/CStr.h"
    2727#include "scriptinterface/ScriptVal.h"
    2828
    2929#define PS_PROTOCOL_MAGIC               0x5073013f      // 'P', 's', 0x01, '?'
    3030#define PS_PROTOCOL_MAGIC_RESPONSE      0x50630121      // 'P', 'c', 0x01, '!'
    31 #define PS_PROTOCOL_VERSION             0x01010009      // Arbitrary protocol
     31#define PS_PROTOCOL_VERSION             0x01010010      // Arbitrary protocol
    3232#define PS_DEFAULT_PORT                 0x5073          // 'P', 's'
    3333
    3434// Defines the list of message types. The order of the list must not change.
    3535// The message types having a negative value are used internally and not sent
    3636// over the network. The message types used for network communication have
  • source/network/NetServer.cpp

    bool CNetServerWorker::OnAuthenticate(vo  
    899899        session->Disconnect(NDR_SERVER_LOADING);
    900900        return true;
    901901    }
    902902
    903903    CAuthenticateMessage* message = (CAuthenticateMessage*)event->GetParamRef();
    904     CStrW username = server.DeduplicatePlayerName(SanitisePlayerName(message->m_Name));
     904    CStrW username = SanitisePlayerName(message->m_Name);
     905
     906    // Check for duplicate names
     907    bool prohibitIdenticalPlayernames = false;
     908    CFG_GET_VAL("network.prohibitIdenticalPlayernames", prohibitIdenticalPlayernames);
     909    if (!prohibitIdenticalPlayernames)
     910        username = server.DeduplicatePlayerName(username);
     911    else if (std::find_if(
     912            server.m_Sessions.begin(), server.m_Sessions.end(),
     913            [&username] (const CNetServerSession* session)
     914            { return session->GetUserName() == username; })
     915        != server.m_Sessions.end())
     916    {
     917        session->Disconnect(NDR_PLAYERNAME_IN_USE);
     918        return true;
     919    }
    905920
    906921    // Disconnect banned usernames
    907922    if (std::find(server.m_BannedPlayers.begin(), server.m_BannedPlayers.end(), username) != server.m_BannedPlayers.end())
    908923    {
    909924        session->Disconnect(NDR_BANNED);