mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-30 00:38: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
|
||||
foreach (Room room in Rooms)
|
||||
{
|
||||
foreach (User player in room.Players.Where(player => player.Status.StatusType == StatusType.Offline))
|
||||
{
|
||||
room.Players.Remove(player);
|
||||
}
|
||||
// do not shorten, this prevents collection modified errors
|
||||
List<User> playersToRemove = room.Players.Where(player => player.Status.StatusType == StatusType.Offline).ToList();
|
||||
foreach (User user in playersToRemove) room.Players.Remove(user);
|
||||
}
|
||||
|
||||
// Delete old rooms based on host
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue