From e16efee488118456468601d59d00392eb48d435c Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 18 Feb 2023 18:25:17 +0200 Subject: [PATCH] Games: BrainBread 2 support. --- CHANGELOG.md | 1 + GAMES.md | 1 + examples/master_querant.rs | 3 ++- src/games/bb2.rs | 12 ++++++++++++ src/games/mod.rs | 2 ++ src/protocols/valve/types.rs | 2 ++ 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/games/bb2.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 905669e..1b64c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Games: - [Onset](https://store.steampowered.com/app/1105810/Onset/) support. - [Codename CURE](https://store.steampowered.com/app/355180/Codename_CURE/) support. - [Ballistic Overkill](https://store.steampowered.com/app/296300/Ballistic_Overkill/) support. +- [BrainBread 2](https://store.steampowered.com/app/346330/BrainBread_2/) support. ### Breaking: Nothing. diff --git a/GAMES.md b/GAMES.md index a5a9f94..cfdda17 100644 --- a/GAMES.md +++ b/GAMES.md @@ -41,6 +41,7 @@ Beware of the `Notes` column, as it contains information about query port offset | Onset | ONSET | Valve Protocol | Query port is 7776. | | Codename CURE | CCURE | Valve Protocol | | | Ballistic Overkill | BO | Valve Protocol | Query port is 27016. | +| BrainBread 2 | BB2 | Valve Protocol | | ## Planned to add support: _ diff --git a/examples/master_querant.rs b/examples/master_querant.rs index a461300..0878adb 100644 --- a/examples/master_querant.rs +++ b/examples/master_querant.rs @@ -1,6 +1,6 @@ use std::env; -use gamedig::{aliens, aoc, arma2oa, ase, asrd, bat1944, bm, bo, ccure, cosu, cs, cscz, csgo, css, dod, dods, doi, dst, GDResult, gm, hl2dm, hldms, ins, insmic, inss, l4d, l4d2, mc, onset, pz, ror2, rust, sc, sdtd, tf, tf2, tfc, ts, unturned}; +use gamedig::{aliens, aoc, arma2oa, ase, asrd, bat1944, bb2, bm, bo, ccure, cosu, cs, cscz, csgo, css, dod, dods, doi, dst, GDResult, gm, hl2dm, hldms, ins, insmic, inss, l4d, l4d2, mc, onset, pz, ror2, rust, sc, sdtd, tf, tf2, tfc, ts, unturned}; use gamedig::protocols::minecraft::LegacyGroup; use gamedig::protocols::valve; use gamedig::protocols::valve::App; @@ -79,6 +79,7 @@ fn main() -> GDResult<()> { "onset" => println!("{:#?}", onset::query(ip, port)?), "ccure" => println!("{:#?}", ccure::query(ip, port)?), "bo" => println!("{:#?}", bo::query(ip, port)?), + "bb2" => println!("{:#?}", bb2::query(ip, port)?), _ => panic!("Undefined game: {}", args[1]) }; diff --git a/src/games/bb2.rs b/src/games/bb2.rs new file mode 100644 index 0000000..14dc9e1 --- /dev/null +++ b/src/games/bb2.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::BB2.as_app(), None, None)?; + + Ok(game::Response::new_from_valve_response(valve_response)) +} diff --git a/src/games/mod.rs b/src/games/mod.rs index 7e1578b..8dea30d 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -77,3 +77,5 @@ pub mod onset; pub mod ccure; /// Ballistic Overkill pub mod bo; +/// BrainBread 2 +pub mod bb2; diff --git a/src/protocols/valve/types.rs b/src/protocols/valve/types.rs index a98c61e..704c57e 100644 --- a/src/protocols/valve/types.rs +++ b/src/protocols/valve/types.rs @@ -189,6 +189,8 @@ pub enum SteamID { BO = 296300, /// Don't Starve Together DST = 322320, + /// BrainBread 2 + BB2 = 346330, /// Codename CURE CCURE = 355180, /// Black Mesa