mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-16 06:32:28 +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");
|
return this.Redirect("/debug/roomVisualizer");
|
||||||
#endif
|
#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>
|
<div class="ui blue button">Create Fake Room</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a href="/debug/roomVisualizer/createRoomsWithDuplicatePlayers">
|
||||||
|
<div class="ui blue button">Create Rooms With Duplicate Players</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a href="/debug/roomVisualizer/deleteRooms">
|
<a href="/debug/roomVisualizer/deleteRooms">
|
||||||
<div class="ui red button">Nuke all rooms</div>
|
<div class="ui red button">Nuke all rooms</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -225,7 +225,7 @@ public class RoomHelper
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rooms.RemoveAll(r => r.HostId == hostId);
|
rooms.RemoveAll(r => r.PlayerIds.Contains((int)hostId));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -233,15 +233,18 @@ public class RoomHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove players in this new room from other rooms
|
// Remove rooms containing players in this new room
|
||||||
if (newRoom != null)
|
if (newRoom != null)
|
||||||
foreach (Room room in rooms)
|
{
|
||||||
|
foreach (Room room in rooms.Where(room => room != newRoom))
|
||||||
{
|
{
|
||||||
if (room == newRoom) continue;
|
foreach (int newRoomPlayer in newRoom.PlayerIds)
|
||||||
|
{
|
||||||
foreach (int newRoomPlayer in newRoom.PlayerIds) room.PlayerIds.RemoveAll(p => p == newRoomPlayer);
|
if (room.PlayerIds.Contains(newRoomPlayer))
|
||||||
roomsToUpdate.Add(room);
|
rooms.Remove(room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Room room in roomsToUpdate)
|
foreach (Room room in roomsToUpdate)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue