Ticket #3949: unique_guid_rev1.patch

File unique_guid_rev1.patch, 2.6 KB (added by sbirmi, 7 years ago)

First attempt at adding a "unique" guid check when a new client is completing authentication

  • binaries/data/mods/public/gui/common/network.js

     
    7171    case 6: return translate("You have been banned");
    7272    case 7: return translate("Playername in use. If you were disconnected, retry in few seconds");
    7373    case 8: return translate("Server full");
     74    case 9: return translate("Player identifier in use, retry connecting");
    7475    default:
    7576        warn("Unknown disconnect-reason ID received: " + id);
    7677        return sprintf(translate("\\[Invalid value %(id)s]"), { "id": id });
  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    176176            {"nick": "Sandarac"},
    177177            {"nick": "sanderd17", "name": "Sander Deryckere"},
    178178            {"nick": "sathyam", "name": "Sathyam Vellal"},
     179            {"nick": "sbirmi", "name": "Sharad Birmiwal"},
    179180            {"nick": "sbte", "name": "Sven Baars"},
    180181            {"nick": "scroogie", "name": "André Gemünd"},
    181182            {"nick": "scythetwirler", "name": "Casey X."},
  • source/network/NetHost.h

     
    6767    NDR_KICKED,
    6868    NDR_BANNED,
    6969    NDR_PLAYERNAME_IN_USE,
    70     NDR_SERVER_FULL
     70    NDR_SERVER_FULL,
     71    NDR_PLAYERGUID_IN_USE
    7172};
    7273
    7374class CNetHost
  • source/network/NetServer.cpp

     
    903903
    904904    CAuthenticateMessage* message = (CAuthenticateMessage*)event->GetParamRef();
    905905    CStrW username = SanitisePlayerName(message->m_Name);
     906    CStr guid = message->m_GUID;
    906907
    907908    // Either deduplicate or prohibit join if name is in use
    908909    bool duplicatePlayernames = false;
     
    919920        return true;
    920921    }
    921922
     923    // Disconnect user if the provided GUID is already in use
     924    if (std::find_if(
     925        server.m_Sessions.begin(), server.m_Sessions.end(),
     926        [&guid] (const CNetServerSession* session)
     927        { return session->GetGUID() == guid; }) != server.m_Sessions.end())
     928    {
     929        session->Disconnect(NDR_PLAYERGUID_IN_USE);
     930        return true;
     931    }
     932
    922933    // Disconnect banned usernames
    923934    if (std::find(server.m_BannedPlayers.begin(), server.m_BannedPlayers.end(), username) != server.m_BannedPlayers.end())
    924935    {