rust-gamedig/src/protocols/gamespy/common.rs
CosminPerRam 786da81ea5
[Protocol] Add GameSpy 3 support. (#25)
* [Protocol] Gamespy3 initial code

* [Protocol] Add rest of challenge solving

* [Protocol] Remove unused stuff

* [Protocol] Remove adding unused bytes

* [Protocol] Clean up code

* [Protocol] Make gs3 a struct

* [Protocol] Add initial key-value parsing

* [Protocol] Manage multiple packets

* [Protocol] Split server vars and other vars

* Revert "[Protocol] Split server vars and other vars"

This reverts commit 9a930aeb68802fcf3d0908a2e031dfea054d37d0.

* [Protocol] Proper packet management and initial response struct

* [Protocol] Fix players_minimum

* [Protocol] Fix server vars to parse only the first packet

* [Protocol] Update CHANGELOG.md

* [Protocol] Initial player parsing

* [Protocol] Split GS one and three

* [Protocol] Add common code file

* [Protocol] Change static to const

* [Protocol] Fix players_online and break on data to map on empty key

* [Protocol] Remove unused types and printlns

* [Protocol] Add teams parsing

* [Protocol] Split key_values and parsing data

* [Crate] Update PROTOCOLS.md
2023-04-17 15:10:51 +03:00

17 lines
468 B
Rust

use crate::{GDError, GDResult};
use std::collections::HashMap;
pub fn has_password(server_vars: &mut HashMap<String, String>) -> GDResult<bool> {
let password_value = server_vars
.remove("password")
.ok_or(GDError::PacketBad)?
.to_lowercase();
if let Ok(has) = password_value.parse::<bool>() {
return Ok(has);
}
let as_numeral: u8 = password_value.parse().map_err(|_| GDError::TypeParse)?;
Ok(as_numeral != 0)
}