diff --git a/crates/lib/src/protocols/unreal2/protocol.rs b/crates/lib/src/protocols/unreal2/protocol.rs index 19f5389c..46f16c81 100644 --- a/crates/lib/src/protocols/unreal2/protocol.rs +++ b/crates/lib/src/protocols/unreal2/protocol.rs @@ -226,14 +226,14 @@ impl StringDecoder for Unreal2StringDecoder { // For UCS-2 strings, some unreal 2 games randomly insert an extra 0x01 here, // not included in the length. Skip it if present (hopefully this never happens // legitimately) - if let Some(1) = data[start..].first() { + if let Some(1) = data[start ..].first() { start += 1; } } // If UCS2 the first byte is the masked length of the string let result = if ucs2 { - let string_data = &data[start..start + length]; + let string_data = &data[start .. start + length]; if string_data.len() != length { return Err(PacketBad.context("Not enough data in buffer to read string")); } @@ -262,7 +262,7 @@ impl StringDecoder for Unreal2StringDecoder { length = position + 1; // Decode as latin1 - let (result, _, invalid_sequences) = WINDOWS_1252.decode(&data[0..position]); + let (result, _, invalid_sequences) = WINDOWS_1252.decode(&data[0 .. position]); if invalid_sequences { return Err(PacketBad.context("latin1 string contained invalid character(s)")); diff --git a/crates/lib/src/protocols/unreal2/types.rs b/crates/lib/src/protocols/unreal2/types.rs index 8501e588..f7dd5a15 100644 --- a/crates/lib/src/protocols/unreal2/types.rs +++ b/crates/lib/src/protocols/unreal2/types.rs @@ -148,9 +148,7 @@ impl Players { } /// Length of both players and bots. - pub fn total_len(&self) -> usize { - self.players.len() + self.bots.len() - } + pub fn total_len(&self) -> usize { self.players.len() + self.bots.len() } } /// Unreal 2 player info. @@ -165,17 +163,11 @@ pub struct Player { } impl CommonPlayer for Player { - fn name(&self) -> &str { - &self.name - } + fn name(&self) -> &str { &self.name } - fn score(&self) -> Option { - Some(self.score) - } + fn score(&self) -> Option { Some(self.score) } - fn as_original(&self) -> GenericPlayer { - GenericPlayer::Unreal2(self) - } + fn as_original(&self) -> GenericPlayer { GenericPlayer::Unreal2(self) } } /// Unreal 2 response. @@ -188,25 +180,15 @@ pub struct Response { } impl CommonResponse for Response { - fn map(&self) -> Option<&str> { - Some(&self.server_info.map) - } + fn map(&self) -> Option<&str> { Some(&self.server_info.map) } - fn name(&self) -> Option<&str> { - Some(&self.server_info.name) - } + fn name(&self) -> Option<&str> { Some(&self.server_info.name) } - fn game_mode(&self) -> Option<&str> { - Some(&self.server_info.game_type) - } + fn game_mode(&self) -> Option<&str> { Some(&self.server_info.game_type) } - fn players_online(&self) -> u32 { - self.server_info.num_players - } + fn players_online(&self) -> u32 { self.server_info.num_players } - fn players_maximum(&self) -> u32 { - self.server_info.max_players - } + fn players_maximum(&self) -> u32 { self.server_info.max_players } fn players(&self) -> Option> { Some( @@ -218,9 +200,7 @@ impl CommonResponse for Response { ) } - fn as_original(&self) -> GenericResponse { - GenericResponse::Unreal2(self) - } + fn as_original(&self) -> GenericResponse { GenericResponse::Unreal2(self) } } /// What data to gather, purely used only with the query function. @@ -252,9 +232,7 @@ impl GatheringSettings { } impl Default for GatheringSettings { - fn default() -> Self { - GatheringSettings::default() - } + fn default() -> Self { GatheringSettings::default() } } impl From for GatheringSettings {