diff --git a/ProjectLighthouse/Match/Rooms/RoomHelper.cs b/ProjectLighthouse/Match/Rooms/RoomHelper.cs index 2e0c998d..8726c216 100644 --- a/ProjectLighthouse/Match/Rooms/RoomHelper.cs +++ b/ProjectLighthouse/Match/Rooms/RoomHelper.cs @@ -227,6 +227,13 @@ public class RoomHelper roomsToUpdate.Add(room); } + // DO NOT REMOVE ROOMS BEFORE THIS POINT! + // this will cause the room to be added back to the database + foreach (Room room in roomsToUpdate) + { + rooms.Update(room); + } + // Delete old rooms based on host if (hostId != null) { @@ -247,17 +254,11 @@ public class RoomHelper { foreach (int newRoomPlayer in newRoom.PlayerIds) { - if (room.PlayerIds.Contains(newRoomPlayer)) - rooms.Remove(room); + if (room.PlayerIds.Contains(newRoomPlayer)) rooms.Remove(room); } } } - foreach (Room room in roomsToUpdate) - { - rooms.Update(room); - } - rooms.RemoveAll(r => r.PlayerIds.Count == 0); // Remove empty rooms rooms.RemoveAll(r => r.HostId == -1); // Remove rooms with broken hosts rooms.RemoveAll(r => r.PlayerIds.Count > 4); // Remove obviously bogus rooms