Rust support.

This commit is contained in:
CosminPerRam 2022-11-26 16:27:03 +02:00
parent de3ac9aad5
commit 3f58e99c28
6 changed files with 20 additions and 1 deletions

View file

@ -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.

View file

@ -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:
_

View file

@ -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)?),

View file

@ -47,3 +47,5 @@ pub mod tf;
pub mod tfc;
/// Sven Co-op
pub mod sc;
/// Rust
pub mod rust;

12
src/games/rust.rs Normal file
View file

@ -0,0 +1,12 @@
use crate::GDResult;
use crate::protocols::valve;
use crate::protocols::valve::{game, SteamID};
pub fn query(address: &str, port: Option<u16>) -> GDResult<game::Response> {
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))
}

View file

@ -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