Skip to content

Commit 366caa6

Browse files
committed
- Extra guards around lobby join
1 parent fd14b27 commit 366caa6

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

GenOnlineService/Controllers/Lobby/LobbyController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ public async Task<APIResult> Put(Int64 lobbyID)
698698

699699
if (playerSession != null)
700700
{
701+
// leave any lobby
702+
LobbyManager.LeaveAnyLobby(user_id);
703+
701704
string strDisplayName = await Database.Functions.Auth.GetDisplayName(GlobalDatabaseInstance.g_Database, user_id);
702705
bool bJoinedSuccessfully = await LobbyManager.JoinLobby(lobby, playerSession, strDisplayName, userPreferredPort, bHasMap);
703706

GenOnlineService/LobbyManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ public async Task Tick()
477477
private readonly SemaphoreSlim g_SlotLock = new SemaphoreSlim(1, 1);
478478
public async Task<bool> AddMember(UserSession playerSession, string strDisplayName, UInt16 userPreferredPort, bool bHasMap, UserLobbyPreferences lobbyPrefs)
479479
{
480+
LobbyMember? existingMember = GetMemberFromUserID(playerSession.m_UserID);
481+
if (existingMember != null) // we're already in this lobby
482+
{
483+
return false;
484+
}
485+
480486
// NOTE: AddMember is called async, so timing + slot determination could result in players being inserted in the same slot
481487
await g_SlotLock.WaitAsync();
482488
try

0 commit comments

Comments
 (0)