[Protocol] Fixed quake 2 bug that version wouldn't always be present

This commit is contained in:
CosminPerRam 2023-07-22 16:17:52 +03:00
parent a81a6ef968
commit ada60f2376
3 changed files with 6 additions and 5 deletions

View file

@ -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<String>`.
# 0.3.0 - 18/07/2023
### Changes:

View file

@ -119,8 +119,7 @@ pub(crate) fn client_query<Client: QuakeClient>(
players,
version: server_vars
.remove("version")
.or(server_vars.remove("*version"))
.ok_or(GDError::PacketBad)?,
.or(server_vars.remove("*version")),
unused_entries: server_vars,
})
}

View file

@ -22,7 +22,7 @@ pub struct Response<P> {
/// Maximum number of players the server reports it can hold.
pub players_maximum: u8,
/// The server version.
pub version: String,
pub version: Option<String>,
/// Other server entries that weren't used.
pub unused_entries: HashMap<String, String>,
}
@ -35,10 +35,10 @@ impl<P: QuakePlayerType> CommonResponse for Response<P> {
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<Vec<&dyn CommonPlayer>> {
Some(