mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-30 16:58:38 +00:00
Fix collection modified error when cleaning up rooms
This commit is contained in:
parent
41dde8eed2
commit
7b5ce09fb4
1 changed files with 3 additions and 4 deletions
|
@ -192,10 +192,9 @@ public class RoomHelper
|
||||||
// Remove offline players from rooms
|
// Remove offline players from rooms
|
||||||
foreach (Room room in Rooms)
|
foreach (Room room in Rooms)
|
||||||
{
|
{
|
||||||
foreach (User player in room.Players.Where(player => player.Status.StatusType == StatusType.Offline))
|
// do not shorten, this prevents collection modified errors
|
||||||
{
|
List<User> playersToRemove = room.Players.Where(player => player.Status.StatusType == StatusType.Offline).ToList();
|
||||||
room.Players.Remove(player);
|
foreach (User user in playersToRemove) room.Players.Remove(user);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete old rooms based on host
|
// Delete old rooms based on host
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue