Valve: Rename players-related fields

This commit is contained in:
CosminPerRam 2023-01-13 19:36:03 +02:00
parent 637252ca18
commit ff789fcb90
5 changed files with 23 additions and 21 deletions

View file

@ -15,6 +15,8 @@ Crate:
### Breaking:
Protocols:
- Valve: The rules field is now a `HashMap<String, String>` instead of a `Vec<ServerRule>` (where the `ServerRule` structure had a name and a value fields).
- Valve: `ServerInfo`'s `players`, `max_players` and `bots` have been renamed to `players_online`, `players_maximum` and `players_bots` respectively.
- Valve: `Response`'s `players`, `max_players` and `bots` have been renamed to `players_online`, `players_maximum` and `players_bots` respectively.
Errors:
- Besides the `BadGame` error, now no other errors returns details about what happened (as it was quite pointless).

View file

@ -28,10 +28,10 @@ Response (note that some games have a different structure):
name: "Team Fortress 2 Dedicated Server.",
map: "ctf_turbine",
game: "tf2",
players: 0,
players_online: 0,
players_details: [],
max_players: 69,
bots: 0,
players_maximum: 69,
players_bots: 0,
server_type: Dedicated,
has_password: false,
vac_secured: true,

View file

@ -60,10 +60,10 @@ impl Response {
name: response.info.name,
map: response.info.map,
game: response.info.game,
players: response.info.players,
players: response.info.players_online,
players_details: response.players.unwrap().iter().map(TheShipPlayer::new_from_valve_player).collect(),
max_players: response.info.max_players,
bots: response.info.bots,
max_players: response.info.players_maximum,
bots: response.info.players_bots,
server_type: response.info.server_type,
has_password: response.info.has_password,
vac_secured: response.info.vac_secured,

View file

@ -244,9 +244,9 @@ impl ValveProtocol {
folder,
game,
appid: 0, //not present in the obsolete response
players,
max_players,
bots,
players_online: players,
players_maximum: max_players,
players_bots: bots,
server_type,
environment_type,
has_password,
@ -343,9 +343,9 @@ impl ValveProtocol {
folder,
game,
appid,
players,
max_players,
bots,
players_online: players,
players_maximum: max_players,
players_bots: bots,
server_type,
environment_type,
has_password,

View file

@ -40,11 +40,11 @@ pub struct ServerInfo {
/// [Steam Application ID](https://developer.valvesoftware.com/wiki/Steam_Application_ID) of game.
pub appid: u32,
/// Number of players on the server.
pub players: u8,
pub players_online: u8,
/// Maximum number of players the server reports it can hold.
pub max_players: u8,
pub players_maximum: u8,
/// Number of bots on the server.
pub bots: u8,
pub players_bots: u8,
/// Dedicated, NonDedicated or SourceTV
pub server_type: Server,
/// The Operating System that the server is on.
@ -265,10 +265,10 @@ pub mod game {
pub name: String,
pub map: String,
pub game: String,
pub players: u8,
pub players_online: u8,
pub players_details: Vec<Player>,
pub max_players: u8,
pub bots: u8,
pub players_maximum: u8,
pub players_bots: u8,
pub server_type: Server,
pub has_password: bool,
pub vac_secured: bool,
@ -290,10 +290,10 @@ pub mod game {
name: response.info.name,
map: response.info.map,
game: response.info.game,
players: response.info.players,
players_online: response.info.players_online,
players_details: response.players.unwrap_or(vec![]).iter().map(Player::from_valve_response).collect(),
max_players: response.info.max_players,
bots: response.info.bots,
players_maximum: response.info.players_maximum,
players_bots: response.info.players_bots,
server_type: response.info.server_type,
has_password: response.info.has_password,
vac_secured: response.info.vac_secured,