From 3f58e99c284411904fb454e64d579bc551a3da00 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 26 Nov 2022 16:27:03 +0200 Subject: [PATCH] Rust support. --- CHANGELOG.md | 1 + GAMES.md | 1 + examples/master_querant.rs | 3 ++- src/games/mod.rs | 2 ++ src/games/rust.rs | 12 ++++++++++++ src/protocols/valve/types.rs | 2 ++ 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/games/rust.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ea515cd..07cbdb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Who knows what the future holds... [The Forest](https://store.steampowered.com/app/242760/The_Forest/) support. [Team Fortress Classic](https://store.steampowered.com/app/20/Team_Fortress_Classic/) support. [Sven Co-op](https://store.steampowered.com/app/225840/Sven_Coop/) support. +[Rust](https://store.steampowered.com/app/252490/Rust/) support. # 0.0.5 - 15/11/2022 Added `SocketBind` error, regarding failing to bind a socket. diff --git a/GAMES.md b/GAMES.md index 648796f..0542526 100644 --- a/GAMES.md +++ b/GAMES.md @@ -24,6 +24,7 @@ | TF | The Forest | Valve Protocol | Use the query port. | | TFC | Team Fortress Classic | Valve Protocol | | | SC | Sven Co-op | Valve Protocol | | +| RUST | Rust | Valve Protocol | | ## Planned to add support: _ diff --git a/examples/master_querant.rs b/examples/master_querant.rs index d230e69..03a268b 100644 --- a/examples/master_querant.rs +++ b/examples/master_querant.rs @@ -1,6 +1,6 @@ use std::env; -use gamedig::{aliens, ase, asrd, cscz, csgo, css, dod, dods, GDResult, gm, hl2dm, ins, insmic, inss, l4d, l4d2, mc, sc, sdtd, tf, tf2, tfc, ts, unturned}; +use gamedig::{aliens, ase, asrd, cscz, csgo, css, dod, dods, GDResult, gm, hl2dm, ins, insmic, inss, l4d, l4d2, mc, rust, sc, sdtd, tf, tf2, tfc, ts, unturned}; use gamedig::protocols::minecraft::{LegacyGroup, Server}; use gamedig::protocols::valve; use gamedig::protocols::valve::App; @@ -53,6 +53,7 @@ fn main() -> GDResult<()> { "tf" => println!("{:#?}", tf::query(ip, port)?), "tfc" => println!("{:#?}", tfc::query(ip, port)?), "sc" => println!("{:#?}", sc::query(ip, port)?), + "rust" => println!("{:#?}", rust::query(ip, port)?), "_src" => println!("{:#?}", valve::query(ip, 27015, App::Source(None), None, None)?), "_gld" => println!("{:#?}", valve::query(ip, 27015, App::GoldSrc(false), None, None)?), "_gld_f" => println!("{:#?}", valve::query(ip, 27015, App::GoldSrc(true), None, None)?), diff --git a/src/games/mod.rs b/src/games/mod.rs index 9023672..44fdf8c 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -47,3 +47,5 @@ pub mod tf; pub mod tfc; /// Sven Co-op pub mod sc; +/// Rust +pub mod rust; diff --git a/src/games/rust.rs b/src/games/rust.rs new file mode 100644 index 0000000..8f0e5a9 --- /dev/null +++ b/src/games/rust.rs @@ -0,0 +1,12 @@ +use crate::GDResult; +use crate::protocols::valve; +use crate::protocols::valve::{game, SteamID}; + +pub fn query(address: &str, port: Option) -> GDResult { + let valve_response = valve::query(address, match port { + None => 27015, + Some(port) => port + }, SteamID::RUST.as_app(), None, None)?; + + Ok(game::Response::new_from_valve_response(valve_response)) +} diff --git a/src/protocols/valve/types.rs b/src/protocols/valve/types.rs index cb55026..c38d76b 100644 --- a/src/protocols/valve/types.rs +++ b/src/protocols/valve/types.rs @@ -177,6 +177,8 @@ pub enum SteamID { INS = 222880, /// Sven Co-op SC = 225840, + /// Rust + RUST = 252490, /// The Forrest TF = 556450, //this is the id for the dedicated server, for the game its 242760 /// 7 Days To Die