From 21b7d91ee6b012e594b5b22e5200ad550978310b Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 26 Nov 2022 16:08:47 +0200 Subject: [PATCH] The Forest support. --- CHANGELOG.md | 3 ++- GAMES.md | 3 ++- examples/master_querant.rs | 3 ++- src/games/mod.rs | 2 ++ src/games/tf.rs | 12 ++++++++++++ src/protocols/valve/types.rs | 2 ++ 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/games/tf.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa95a3..b94f5e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ Who knows what the future holds... [Minecraft](https://www.minecraft.com) implementation (bedrock not supported yet). [7 Days To Die](https://store.steampowered.com/app/251570/7_Days_to_Die/) support. [ARK: Survival Evolved](https://store.steampowered.com/app/346110/ARK_Survival_Evolved/) support. -[Unturned](https://store.steampowered.com/app/304930/Unturned/) support. +[Unturned](https://store.steampowered.com/app/304930/Unturned/) support. +[The Forest](https://store.steampowered.com/app/242760/The_Forest/) 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 742049d..73a222e 100644 --- a/GAMES.md +++ b/GAMES.md @@ -13,7 +13,7 @@ | ALIENS | Alien Swarm | Valve Protocol | Not tested. | | ASRD | Alien Swarm: Reactive Drop | Valve Protocol | | | INS | Insurgency | Valve Protocol | | -| INSS | Insurgency: Sandstorm | Valve Protocol | Use the query port, not the server port. | +| INSS | Insurgency: Sandstorm | Valve Protocol | Use the query port. | | INSMIC | Insurgency: Modern Infantry Combat | Valve Protocol | Not tested. | | CSCZ | Counter-Strike: Condition Zero | Valve Protocol | | | DOD | Day of Defeat | Valve Protocol | | @@ -21,6 +21,7 @@ | SDTD | 7 Days To Die | Valve Protocol | | | ASE | ARK: Survival Evolved | Valve Protocol | | | UNTURNED | Unturned | Valve Protocol | | +| TF | The Forest | Valve Protocol | Use the query port. | ## Planned to add support: _ diff --git a/examples/master_querant.rs b/examples/master_querant.rs index 64d3d9b..62b4d57 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, sdtd, tf2, ts, unturned}; +use gamedig::{aliens, ase, asrd, cscz, csgo, css, dod, dods, GDResult, gm, hl2dm, ins, insmic, inss, l4d, l4d2, mc, sdtd, tf, tf2, ts, unturned}; use gamedig::protocols::minecraft::{LegacyGroup, Server}; use gamedig::protocols::valve; use gamedig::protocols::valve::App; @@ -50,6 +50,7 @@ fn main() -> GDResult<()> { "7dtd" => println!("{:#?}", sdtd::query(ip, port)?), "ase" => println!("{:#?}", ase::query(ip, port)?), "unturned" => println!("{:#?}", unturned::query(ip, port)?), + "tf" => println!("{:#?}", tf::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 31db2ab..7f60cc8 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -41,3 +41,5 @@ pub mod sdtd; pub mod ase; /// Unturned pub mod unturned; +/// The Forest +pub mod tf; diff --git a/src/games/tf.rs b/src/games/tf.rs new file mode 100644 index 0000000..e5088e4 --- /dev/null +++ b/src/games/tf.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::TF.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 408c728..76e3367 100644 --- a/src/protocols/valve/types.rs +++ b/src/protocols/valve/types.rs @@ -173,6 +173,8 @@ pub enum SteamID { INSMIC = 17700, /// Insurgency INS = 222880, + /// The Forrest + TF = 556450, //this is the id for the dedicated server, for the game its 242760 /// 7 Days To Die SDTD = 251570, /// Unturned