mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-15 22:22:27 +00:00
Eliminate duplicate rooms
This commit is contained in:
parent
5d6e339fa8
commit
be592bbacb
3 changed files with 27 additions and 7 deletions
|
@ -46,4 +46,17 @@ public class RoomVisualizerController : ControllerBase
|
|||
return this.Redirect("/debug/roomVisualizer");
|
||||
#endif
|
||||
}
|
||||
|
||||
[HttpGet("createRoomsWithDuplicatePlayers")]
|
||||
public async Task<IActionResult> CreateRoomsWithDuplicatePlayers()
|
||||
{
|
||||
#if !DEBUG
|
||||
return this.NotFound();
|
||||
#else
|
||||
List<int> users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(1).Select(u => u.UserId).ToListAsync();
|
||||
RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2, Platform.PS3);
|
||||
RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2, Platform.PS3);
|
||||
return this.Redirect("/debug/roomVisualizer");
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -44,6 +44,10 @@
|
|||
<div class="ui blue button">Create Fake Room</div>
|
||||
</a>
|
||||
|
||||
<a href="/debug/roomVisualizer/createRoomsWithDuplicatePlayers">
|
||||
<div class="ui blue button">Create Rooms With Duplicate Players</div>
|
||||
</a>
|
||||
|
||||
<a href="/debug/roomVisualizer/deleteRooms">
|
||||
<div class="ui red button">Nuke all rooms</div>
|
||||
</a>
|
||||
|
|
|
@ -225,7 +225,7 @@ public class RoomHelper
|
|||
{
|
||||
try
|
||||
{
|
||||
rooms.RemoveAll(r => r.HostId == hostId);
|
||||
rooms.RemoveAll(r => r.PlayerIds.Contains((int)hostId));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -233,14 +233,17 @@ public class RoomHelper
|
|||
}
|
||||
}
|
||||
|
||||
// Remove players in this new room from other rooms
|
||||
// Remove rooms containing players in this new room
|
||||
if (newRoom != null)
|
||||
foreach (Room room in rooms)
|
||||
{
|
||||
if (room == newRoom) continue;
|
||||
|
||||
foreach (int newRoomPlayer in newRoom.PlayerIds) room.PlayerIds.RemoveAll(p => p == newRoomPlayer);
|
||||
roomsToUpdate.Add(room);
|
||||
foreach (Room room in rooms.Where(room => room != newRoom))
|
||||
{
|
||||
foreach (int newRoomPlayer in newRoom.PlayerIds)
|
||||
{
|
||||
if (room.PlayerIds.Contains(newRoomPlayer))
|
||||
rooms.Remove(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Room room in roomsToUpdate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue