# HG changeset patch # User alfadur # Date 1586545089 -10800 # Node ID 7478568cffbebf4baa64e7d32898e54a926c08dc # Parent 0b16baefefd193b1111ef01b41ce41868c0498b3 fix phantom rooms diff -r 0b16baefefd1 -r 7478568cffbe rust/hedgewars-server/src/core/server.rs --- a/rust/hedgewars-server/src/core/server.rs Thu Mar 12 15:09:16 2020 -0400 +++ b/rust/hedgewars-server/src/core/server.rs Fri Apr 10 21:58:09 2020 +0300 @@ -523,6 +523,7 @@ server: &'a mut HwServer, client_id: ClientId, room_id: RoomId, + is_room_removed: bool } impl<'a> HwRoomControl<'a> { @@ -533,6 +534,7 @@ server, client_id, room_id, + is_room_removed: false }) } else { None @@ -540,6 +542,13 @@ } #[inline] + pub fn cleanup_room(self) { + if self.is_room_removed { + self.server.rooms.remove(self.room_id); + } + } + + #[inline] pub fn server(&self) -> &HwServer { self.server } @@ -618,7 +627,7 @@ if !is_fixed { if room.players_number == 0 { - self.server.rooms.remove(self.room_id); + self.is_room_removed = true } else if room.master_id == None { let protocol_number = room.protocol_number; let new_master_id = self.server.room_client_ids(self.room_id).next(); diff -r 0b16baefefd1 -r 7478568cffbe rust/hedgewars-server/src/handlers/inroom.rs --- a/rust/hedgewars-server/src/handlers/inroom.rs Thu Mar 12 15:09:16 2020 -0400 +++ b/rust/hedgewars-server/src/handlers/inroom.rs Fri Apr 10 21:58:09 2020 +0300 @@ -120,6 +120,7 @@ result, response, ); + room_control.cleanup_room(); } Chat(msg) => { response.add(