From 6f0752c2471e7c4ff5d203550f8904966cad8508 Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 25 Jul 2022 20:31:19 -0400 Subject: [PATCH] Fix room deletions --- ProjectLighthouse/Match/Rooms/RoomHelper.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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