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), } }