From ada60f2376d6877d40e37a70eea4248cbec3b1f1 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 22 Jul 2023 16:17:52 +0300 Subject: [PATCH] [Protocol] Fixed quake 2 bug that version wouldn't always be present --- CHANGELOG.md | 4 +++- src/protocols/quake/client.rs | 3 +-- src/protocols/quake/types.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9d133..cf674bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,13 @@ Who knows what the future holds... # 0.X.Y - DD/MM/2023 ### Changes: -To be made... +Protocols: +- Quake 2: Fixed a bug where the version tag wouldn't always be present. ### Breaking... Protocols: - Gamespy 1: Renamed the players `frags` field to `score` to be more inline with the other protocols. +- Quake: The `version` field has been changed from `String`to `Option`. # 0.3.0 - 18/07/2023 ### Changes: diff --git a/src/protocols/quake/client.rs b/src/protocols/quake/client.rs index a2beb4a..3902d1c 100644 --- a/src/protocols/quake/client.rs +++ b/src/protocols/quake/client.rs @@ -119,8 +119,7 @@ pub(crate) fn client_query( players, version: server_vars .remove("version") - .or(server_vars.remove("*version")) - .ok_or(GDError::PacketBad)?, + .or(server_vars.remove("*version")), unused_entries: server_vars, }) } diff --git a/src/protocols/quake/types.rs b/src/protocols/quake/types.rs index 9bb23b7..2479b6d 100644 --- a/src/protocols/quake/types.rs +++ b/src/protocols/quake/types.rs @@ -22,7 +22,7 @@ pub struct Response

{ /// Maximum number of players the server reports it can hold. pub players_maximum: u8, /// The server version. - pub version: String, + pub version: Option, /// Other server entries that weren't used. pub unused_entries: HashMap, } @@ -35,10 +35,10 @@ impl CommonResponse for Response

{ fn as_original(&self) -> GenericResponse { GenericResponse::Quake(P::version(self)) } fn name(&self) -> Option<&str> { Some(&self.name) } + fn game_version(&self) -> Option<&str> { self.version.as_deref() } fn map(&self) -> Option<&str> { Some(&self.map) } fn players_maximum(&self) -> u64 { self.players_maximum.into() } fn players_online(&self) -> u64 { self.players_online.into() } - fn game_version(&self) -> Option<&str> { Some(&self.version) } fn players(&self) -> Option> { Some(