From 5cf56152650e2d4139f5d175470082f3f7c5efe4 Mon Sep 17 00:00:00 2001 From: cosminperram Date: Wed, 19 Oct 2022 22:47:52 +0300 Subject: [PATCH] Initial the ship support --- src/games/mod.rs | 2 ++ src/games/the_ship.rs | 16 ++++++++++++++++ src/protocols/valve.rs | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/games/the_ship.rs diff --git a/src/games/mod.rs b/src/games/mod.rs index eee99b5..02ecf0d 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -1,4 +1,6 @@ pub mod tf2; +pub mod the_ship; pub use tf2::*; +pub use the_ship::*; diff --git a/src/games/the_ship.rs b/src/games/the_ship.rs new file mode 100644 index 0000000..6a159a5 --- /dev/null +++ b/src/games/the_ship.rs @@ -0,0 +1,16 @@ +use crate::errors::GDError; +use crate::valve::{ValveProtocol, App, GatheringSettings, Response}; + +pub struct TheShip; + +impl TheShip { + pub fn query(address: &str, port: Option) -> Result { + ValveProtocol::query(App::TheShip, address, match port { + None => 27015, + Some(port) => port + }, GatheringSettings { + players: false, + rules: false + }) + } +} diff --git a/src/protocols/valve.rs b/src/protocols/valve.rs index 84c8a8f..3870276 100644 --- a/src/protocols/valve.rs +++ b/src/protocols/valve.rs @@ -102,8 +102,8 @@ impl TryFrom for App { fn try_from(value: u16) -> Result { match value { x if x == App::TF2 as u16 => Ok(App::TF2), - x if x == App::TF2 as u16 => Ok(App::CSGO), - x if x == App::TF2 as u16 => Ok(App::TheShip), + x if x == App::CSGO as u16 => Ok(App::CSGO), + x if x == App::TheShip as u16 => Ok(App::TheShip), _ => Err(GDError::UnknownEnumCast), } }