diff --git a/ProjectLighthouse/Controllers/GameApi/LoginController.cs b/ProjectLighthouse/Controllers/GameApi/LoginController.cs index 8e95ed4e..20ec33ae 100644 --- a/ProjectLighthouse/Controllers/GameApi/LoginController.cs +++ b/ProjectLighthouse/Controllers/GameApi/LoginController.cs @@ -141,7 +141,7 @@ public class LoginController : ControllerBase await this.database.SaveChangesAsync(); // Create a new room on LBP2/3/Vita - if (token.GameVersion != GameVersion.LittleBigPlanet1) RoomHelper.CreateRoom(user, token.GameVersion); + if (token.GameVersion != GameVersion.LittleBigPlanet1) RoomHelper.CreateRoom(user, token.GameVersion, token.Platform); return this.Ok ( diff --git a/ProjectLighthouse/Controllers/GameApi/Matching/MatchController.cs b/ProjectLighthouse/Controllers/GameApi/Matching/MatchController.cs index f173e1bc..d250fb44 100644 --- a/ProjectLighthouse/Controllers/GameApi/Matching/MatchController.cs +++ b/ProjectLighthouse/Controllers/GameApi/Matching/MatchController.cs @@ -81,7 +81,7 @@ public class MatchController : ControllerBase if (matchData is UpdateMyPlayerData playerData) { MatchHelper.SetUserLocation(user.UserId, gameToken.UserLocation); - Room? room = RoomHelper.FindRoomByUser(user, gameToken.GameVersion, true); + Room? room = RoomHelper.FindRoomByUser(user, gameToken.GameVersion, gameToken.Platform, true); if (playerData.RoomState != null) if (room != null && Equals(room.Host, user)) @@ -90,7 +90,7 @@ public class MatchController : ControllerBase if (matchData is FindBestRoom && MatchHelper.UserLocations.Count > 1) { - FindBestRoomResponse? response = RoomHelper.FindBestRoom(user, gameToken.GameVersion, gameToken.UserLocation); + FindBestRoomResponse? response = RoomHelper.FindBestRoom(user, gameToken.GameVersion, gameToken.Platform, gameToken.UserLocation); if (response == null) return this.NotFound(); @@ -112,7 +112,7 @@ public class MatchController : ControllerBase } // Create a new one as requested - RoomHelper.CreateRoom(users, gameToken.GameVersion, createRoom.RoomSlot); + RoomHelper.CreateRoom(users, gameToken.GameVersion, gameToken.Platform, createRoom.RoomSlot); } if (matchData is UpdatePlayersInRoom updatePlayersInRoom) diff --git a/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs b/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs index 854f05c9..cc690c93 100644 --- a/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs +++ b/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs @@ -26,7 +26,7 @@ public class RoomVisualizerController : ControllerBase return this.NotFound(); #else List users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(2).ToListAsync(); - RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2); + RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2, Platform.PS3); foreach (User user in users) { diff --git a/ProjectLighthouse/Helpers/RoomHelper.cs b/ProjectLighthouse/Helpers/RoomHelper.cs index 0ae4343c..cbf3dc8a 100644 --- a/ProjectLighthouse/Helpers/RoomHelper.cs +++ b/ProjectLighthouse/Helpers/RoomHelper.cs @@ -42,7 +42,7 @@ public class RoomHelper internal static int RoomIdIncrement => roomIdIncrement++; - public static FindBestRoomResponse? FindBestRoom(User? user, GameVersion roomVersion, string? location) + public static FindBestRoomResponse? FindBestRoom(User? user, GameVersion roomVersion, Platform? platform, string? location) { if (roomVersion == GameVersion.LittleBigPlanet1 || roomVersion == GameVersion.LittleBigPlanetPSP) { @@ -60,6 +60,7 @@ public class RoomHelper } rooms = rooms.Where(r => r.RoomVersion == roomVersion).ToList(); + if (platform != null) rooms = rooms.Where(r => r.RoomPlatform == platform).ToList(); foreach (Room room in rooms) // Look for rooms looking for players before moving on to rooms that are idle. @@ -133,7 +134,7 @@ public class RoomHelper return null; } - public static Room CreateRoom(User user, GameVersion roomVersion, RoomSlot? slot = null) + public static Room CreateRoom(User user, GameVersion roomVersion, Platform roomPlatform, RoomSlot? slot = null) => CreateRoom ( new List @@ -141,9 +142,10 @@ public class RoomHelper user, }, roomVersion, + roomPlatform, slot ); - public static Room CreateRoom(List users, GameVersion roomVersion, RoomSlot? slot = null) + public static Room CreateRoom(List users, GameVersion roomVersion, Platform roomPlatform, RoomSlot? slot = null) { Room room = new() { @@ -152,6 +154,7 @@ public class RoomHelper State = RoomState.Idle, Slot = slot ?? PodSlot, RoomVersion = roomVersion, + RoomPlatform = roomPlatform, }; CleanupRooms(room.Host, room); @@ -161,13 +164,13 @@ public class RoomHelper return room; } - public static Room? FindRoomByUser(User user, GameVersion roomVersion, bool createIfDoesNotExist = false) + public static Room? FindRoomByUser(User user, GameVersion roomVersion, Platform roomPlatform, bool createIfDoesNotExist = false) { lock(Rooms) foreach (Room room in Rooms.Where(room => room.Players.Any(player => user == player))) return room; - return createIfDoesNotExist ? CreateRoom(user, roomVersion) : null; + return createIfDoesNotExist ? CreateRoom(user, roomVersion, roomPlatform) : null; } public static Room? FindRoomByUserId(int userId) diff --git a/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml b/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml index 0316b86c..265b4951 100644 --- a/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml +++ b/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml @@ -52,7 +52,7 @@ { if (version == GameVersion.LittleBigPlanet1 || version == GameVersion.LittleBigPlanetPSP || version == GameVersion.Unknown) continue; - FindBestRoomResponse? response = RoomHelper.FindBestRoom(null, version, null); + FindBestRoomResponse? response = RoomHelper.FindBestRoom(null, version, null, null); string text = response == null ? "No room found." : "Room " + response.RoomId;

Best room for @version.ToPrettyString(): @text

@@ -72,7 +72,7 @@ You are currently in this room.

} -

@room.Players.Count players, state is @room.State, version is @room.RoomVersion.ToPrettyString()

+

@room.Players.Count players, state is @room.State, version is @room.RoomVersion.ToPrettyString()on paltform @room.RoomPlatform

Slot type: @room.Slot.SlotType, slot id: @room.Slot.SlotId

@foreach (User player in room.Players) { diff --git a/ProjectLighthouse/Types/Match/Room.cs b/ProjectLighthouse/Types/Match/Room.cs index 1541cb10..63128150 100644 --- a/ProjectLighthouse/Types/Match/Room.cs +++ b/ProjectLighthouse/Types/Match/Room.cs @@ -15,6 +15,9 @@ public class Room [JsonIgnore] public GameVersion RoomVersion { get; set; } + [JsonIgnore] + public Platform RoomPlatform { get; set; } + public RoomSlot Slot { get; set; } public RoomState State { get; set; }