mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-22 01:09:01 +00:00
Random findBestRoom list, clear recent dive-in list if rooms are unavailable
This commit is contained in:
parent
be592bbacb
commit
b30195c5ba
2 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,8 @@ public static class MatchHelper
|
||||||
return recentlyDivedIn.Contains(otherUserId);
|
return recentlyDivedIn.Contains(otherUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool ClearUserRecentDiveIns(int userId) => UserRecentlyDivedIn.Remove(userId);
|
||||||
|
|
||||||
// This is the function used to show people how laughably awful LBP's protocol is. Beware.
|
// This is the function used to show people how laughably awful LBP's protocol is. Beware.
|
||||||
public static IMatchCommand? Deserialize(string data)
|
public static IMatchCommand? Deserialize(string data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
@ -47,10 +48,10 @@ public class RoomHelper
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<Room> rooms = Rooms;
|
Random random = new();
|
||||||
|
IEnumerable<Room> rooms = Rooms.OrderBy(_ => random.Next());
|
||||||
|
|
||||||
rooms = rooms.OrderBy(r => r.IsLookingForPlayers);
|
rooms = rooms.OrderBy(r => r.IsLookingForPlayers);
|
||||||
|
|
||||||
rooms = rooms.Where(r => r.RoomVersion == roomVersion).ToList();
|
rooms = rooms.Where(r => r.RoomVersion == roomVersion).ToList();
|
||||||
if (platform != null) rooms = rooms.Where(r => r.RoomPlatform == platform).ToList();
|
if (platform != null) rooms = rooms.Where(r => r.RoomPlatform == platform).ToList();
|
||||||
|
|
||||||
|
@ -137,6 +138,12 @@ public class RoomHelper
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
MatchHelper.ClearUserRecentDiveIns(user.UserId);
|
||||||
|
Logger.Info($"Cleared {user.Username} (id: {user.UserId})'s recent dive-ins", LogArea.Match);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue