mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
Counter-Strike support.
This commit is contained in:
parent
645582868d
commit
aec145a847
6 changed files with 21 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ Who knows what the future holds...
|
|||
[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.
|
||||
[Counter-Strike](https://store.steampowered.com/app/10/CounterStrike/) support.
|
||||
|
||||
# 0.0.5 - 15/11/2022
|
||||
Added `SocketBind` error, regarding failing to bind a socket.
|
||||
|
|
|
|||
1
GAMES.md
1
GAMES.md
|
|
@ -25,6 +25,7 @@
|
|||
| TFC | Team Fortress Classic | Valve Protocol | |
|
||||
| SC | Sven Co-op | Valve Protocol | |
|
||||
| RUST | Rust | Valve Protocol | |
|
||||
| CS | Counter-Strike | Valve Protocol | |
|
||||
|
||||
## Planned to add support:
|
||||
_
|
||||
|
|
|
|||
|
|
@ -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, rust, sc, sdtd, tf, tf2, tfc, ts, unturned};
|
||||
use gamedig::{aliens, ase, asrd, cs, 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;
|
||||
|
|
@ -54,6 +54,7 @@ fn main() -> GDResult<()> {
|
|||
"tfc" => println!("{:#?}", tfc::query(ip, port)?),
|
||||
"sc" => println!("{:#?}", sc::query(ip, port)?),
|
||||
"rust" => println!("{:#?}", rust::query(ip, port)?),
|
||||
"cs" => println!("{:#?}", cs::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)?),
|
||||
|
|
|
|||
12
src/games/cs.rs
Normal file
12
src/games/cs.rs
Normal 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::CS.as_app(), None, None)?;
|
||||
|
||||
Ok(game::Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
@ -49,3 +49,5 @@ pub mod tfc;
|
|||
pub mod sc;
|
||||
/// Rust
|
||||
pub mod rust;
|
||||
/// Counter-Strike
|
||||
pub mod cs;
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ pub enum Request {
|
|||
#[repr(u32)]
|
||||
#[derive(PartialEq, Clone)]
|
||||
pub enum SteamID {
|
||||
/// Counter-Strike
|
||||
CS = 10,
|
||||
/// Team Fortress Classic
|
||||
TFC = 20,
|
||||
/// Day of Defeat
|
||||
|
|
@ -197,7 +199,7 @@ impl SteamID {
|
|||
/// Get ID as App (the engine is specified).
|
||||
pub fn as_app(&self) -> App {
|
||||
match self {
|
||||
SteamID::TFC | SteamID::DOD | SteamID::CSCZ | SteamID::SC => App::GoldSrc(false),
|
||||
SteamID::CS | SteamID::TFC | SteamID::DOD | SteamID::CSCZ | SteamID::SC => App::GoldSrc(false),
|
||||
x => App::Source(Some(x.clone() as u32))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue