--- a/rust/hedgewars-server/src/core/server.rs Sat Apr 11 23:20:09 2020 +0300
+++ b/rust/hedgewars-server/src/core/server.rs Sun Apr 12 00:02:11 2020 +0300
@@ -989,12 +989,15 @@
if client_left {
client.set_is_in_game(false);
- let team_names: Vec<_> = room
- .client_teams(client.id)
- .map(|t| t.name.clone())
- .collect();
+ if let Some(ref mut info) = room.game_info {
+ let team_names: Vec<_> = info
+ .client_teams(client.id)
+ .map(|t| t.name.clone())
+ .collect();
- if let Some(ref mut info) = room.game_info {
+ info.left_teams.extend(team_names.iter().cloned());
+ info.ingame_teams_count -= team_names.len() as u8;
+
for team_name in &team_names {
let remove_msg =
utils::to_engine_msg(std::iter::once(b'F').chain(team_name.bytes()));
@@ -1008,7 +1011,7 @@
}
Some(team_names)
} else {
- unreachable!();
+ None
}
} else {
None
@@ -1125,6 +1128,7 @@
if !team_names.is_empty() {
info.left_teams.retain(|name| !team_names.contains(&name));
+ info.ingame_teams_count += team_names.len() as u8;
}
}
}