From 76a3ac2f7860657e606b3ce7e4e147387e3e0031 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 3 Sep 2023 12:12:14 +0300 Subject: [PATCH] [Game] Add Creativerse support. --- CHANGELOG.md | 3 + GAMES.md | 113 ++++++++++++++++++----------------- examples/master_querant.rs | 2 + src/games/creativerse.rs | 16 +++++ src/games/definitions.rs | 1 + src/games/mod.rs | 2 + src/protocols/valve/types.rs | 3 + 7 files changed, 84 insertions(+), 56 deletions(-) create mode 100644 src/games/creativerse.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a09d9..3753d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Who knows what the future holds... # 0.X.Y - DD/MM/2023 ### Changes: +Games: +- [Creativerse](https://store.steampowered.com/app/280790/Creativerse/) support. + Protocols: - Quake 2: Fixed a bug where the version tag wouldn't always be present. - Valve: Added the field `check_app_id` to `GatherSettings` which controls if the app id specified to the request and diff --git a/GAMES.md b/GAMES.md index 3cf8a4b..5914e24 100644 --- a/GAMES.md +++ b/GAMES.md @@ -3,62 +3,63 @@ one of the implemented protocols might work too, but that isn't guaranteed. Beware of the `Notes` column, as it contains information about query port offsets or other query requirements/information. # Supported games: -| Game | Use name | Protocol | Notes | -|------------------------------------|----------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Team Fortress 2 | TF2 | Valve | | -| The Ship | TS | Valve (*Altered) | | -| Counter-Strike: Global Offensive | CSGO | Valve | The server must have the cvar `host_players_show` set to `2` to get the full player list. | -| Counter-Strike: Source | CSS | Valve | | -| Day of Defeat: Source | DODS | Valve | | -| Left 4 Dead | L4D | Valve | | -| Left 4 Dead 2 | L4D2 | Valve | | -| Half-Life 2 Deathmatch | HL2DM | Valve | | -| Alien Swarm | ALIENS | Valve | | -| Alien Swarm: Reactive Drop | ASRD | Valve | | -| Insurgency | INS | Valve | | -| Insurgency: Sandstorm | INSS | Valve | Query port offset: 1. | -| Insurgency: Modern Infantry Combat | INSMIC | Valve | | -| Counter-Strike: Condition Zero | CSCZ | Valve GoldSrc | | -| Day of Defeat | DOD | Valve GoldSrc | | -| Minecraft | MC | Proprietary | Bedrock edition provides a different response compared to the Java edition, query specifically for bedrock to get them, otherwise, only matching fields will be provided. | -| 7 Days To Die | SDTD | Valve | | -| ARK: Survival Evolved | ASE | Valve | | -| Unturned | UNTURNED | Valve | | -| The Forest | TF | Valve GoldSrc | Query port offset: 1. | -| Team Fortress Classic | TFC | Valve | | -| Sven Co-op | SC | Valve GoldSrc | | -| Rust | RUST | Valve | | -| Counter-Strike | CS | Valve GoldSrc | | -| Arma 2: Operation Arrowhead | ARMA2OA | Valve | Query port offset: 1. | -| Day of Infamy | DOI | Valve | | -| Half-Life Deathmatch: Source | HLDMS | Valve | | -| Risk of Rain 2 | ROR2 | Valve | Query port offset: 1. | -| Battalion 1944 | BAT1944 | Valve | Query port offset: 3. It is strongly recommended to also query the rules, as it sends basic server info in them. | -| Black Mesa | BM | Valve | | -| Project Zomboid | PZ | Valve | | -| Age of Chivalry | AOC | Valve | | -| Don't Starve Together | DST | Valve | Query port is 27016. | -| Colony Survival | COLU | Valve | | -| Onset | ONSET | Valve | Query port is 7776. | -| Codename CURE | CCURE | Valve | | -| Ballistic Overkill | BO | Valve | Query port is 27016. | -| BrainBread 2 | BB2 | Valve | | -| Avorion | AVORION | Valve | Query port is 27020. | -| Operation: Harsh Doorstop | OHD | Valve | Query port is 27005. | -| V Rising | VR | Valve | Query port is 27016. | -| Unreal Tournament | UT | GameSpy 1 | Query Port offset: 1. | -| Battlefield 1942 | BF1942 | GameSpy 1 | Query port is 23000. | -| Serious Sam | SS | GameSpy 1 | Query Port offset: 1. | -| Frontlines: Fuel of War | FFOW | Valve (*Altered) | Query Port offset: 2. | -| Crysis Wars | CW | GameSpy 3 | | -| Quake 2 | QUAKE2 | Quake 2 | | -| Quake 1 | QUAKE1 | Quake 1 | | -| Quake 3: Arena | QUAKE3A | Quake 3 | | -| Hell Let Loose | HLL | Valve Protocol | Query port is 26420. Note that on this port it might not send players data, as there might be another query port that does send players data. | -| Soldier of Fortune 2 | SOF2 | Quake 3 | | -| Halo: Combat Evolved | HALOCE | GameSpy 2 | | -| Just Cause 2: Multiplayer | JC2MP | GameSpy 3 (*Altered) | | -| Warsow | WARSOW | Quake 3 | | +| Game | Use name | Protocol | Notes | +|------------------------------------|-------------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Team Fortress 2 | TF2 | Valve | | +| The Ship | TS | Valve (*Altered) | | +| Counter-Strike: Global Offensive | CSGO | Valve | The server must have the cvar `host_players_show` set to `2` to get the full player list. | +| Counter-Strike: Source | CSS | Valve | | +| Day of Defeat: Source | DODS | Valve | | +| Left 4 Dead | L4D | Valve | | +| Left 4 Dead 2 | L4D2 | Valve | | +| Half-Life 2 Deathmatch | HL2DM | Valve | | +| Alien Swarm | ALIENS | Valve | | +| Alien Swarm: Reactive Drop | ASRD | Valve | | +| Insurgency | INS | Valve | | +| Insurgency: Sandstorm | INSS | Valve | Query port offset: 1. | +| Insurgency: Modern Infantry Combat | INSMIC | Valve | | +| Counter-Strike: Condition Zero | CSCZ | Valve GoldSrc | | +| Day of Defeat | DOD | Valve GoldSrc | | +| Minecraft | MC | Proprietary | Bedrock edition provides a different response compared to the Java edition, query specifically for bedrock to get them, otherwise, only matching fields will be provided. | +| 7 Days To Die | SDTD | Valve | | +| ARK: Survival Evolved | ASE | Valve | | +| Unturned | UNTURNED | Valve | | +| The Forest | TF | Valve GoldSrc | Query port offset: 1. | +| Team Fortress Classic | TFC | Valve | | +| Sven Co-op | SC | Valve GoldSrc | | +| Rust | RUST | Valve | | +| Counter-Strike | CS | Valve GoldSrc | | +| Arma 2: Operation Arrowhead | ARMA2OA | Valve | Query port offset: 1. | +| Day of Infamy | DOI | Valve | | +| Half-Life Deathmatch: Source | HLDMS | Valve | | +| Risk of Rain 2 | ROR2 | Valve | Query port offset: 1. | +| Battalion 1944 | BAT1944 | Valve | Query port offset: 3. It is strongly recommended to also query the rules, as it sends basic server info in them. | +| Black Mesa | BM | Valve | | +| Project Zomboid | PZ | Valve | | +| Age of Chivalry | AOC | Valve | | +| Don't Starve Together | DST | Valve | Query port is 27016. | +| Colony Survival | COLU | Valve | | +| Onset | ONSET | Valve | Query port is 7776. | +| Codename CURE | CCURE | Valve | | +| Ballistic Overkill | BO | Valve | Query port is 27016. | +| BrainBread 2 | BB2 | Valve | | +| Avorion | AVORION | Valve | Query port is 27020. | +| Operation: Harsh Doorstop | OHD | Valve | Query port is 27005. | +| V Rising | VR | Valve | Query port is 27016. | +| Unreal Tournament | UT | GameSpy 1 | Query Port offset: 1. | +| Battlefield 1942 | BF1942 | GameSpy 1 | Query port is 23000. | +| Serious Sam | SS | GameSpy 1 | Query Port offset: 1. | +| Frontlines: Fuel of War | FFOW | Valve (*Altered) | Query Port offset: 2. | +| Crysis Wars | CW | GameSpy 3 | | +| Quake 2 | QUAKE2 | Quake 2 | | +| Quake 1 | QUAKE1 | Quake 1 | | +| Quake 3: Arena | QUAKE3A | Quake 3 | | +| Hell Let Loose | HLL | Valve Protocol | Query port is 26420. Note that on this port it might not send players data, as there might be another query port that does send players data. | +| Soldier of Fortune 2 | SOF2 | Quake 3 | | +| Halo: Combat Evolved | HALOCE | GameSpy 2 | | +| Just Cause 2: Multiplayer | JC2MP | GameSpy 3 (*Altered) | | +| Warsow | WARSOW | Quake 3 | | +| Creativerse | CREATIVERSE | Valve | Query Port offset: 1. | ## Planned to add support: _ diff --git a/examples/master_querant.rs b/examples/master_querant.rs index 9bf9d18..b701764 100644 --- a/examples/master_querant.rs +++ b/examples/master_querant.rs @@ -16,6 +16,7 @@ use gamedig::{ bo, ccure, cosu, + creativerse, cs, cscz, csgo, @@ -193,6 +194,7 @@ fn main() -> GDResult<()> { "haloce" => println!("{:#?}", haloce::query(ip, port)?), "jc2mp" => println!("{:#?}", jc2mp::query(ip, port)?), "warsow" => println!("{:#?}", warsow::query(ip, port)?), + "creativerse" => println!("{:#?}", creativerse::query(ip, port)?), _ => panic!("Undefined game: {}", args[1]), }; diff --git a/src/games/creativerse.rs b/src/games/creativerse.rs new file mode 100644 index 0000000..9df2abb --- /dev/null +++ b/src/games/creativerse.rs @@ -0,0 +1,16 @@ +use crate::{ + protocols::valve::{self, game, SteamApp}, + GDResult, +}; +use std::net::{IpAddr, SocketAddr}; + +pub fn query(address: &IpAddr, port: Option) -> GDResult { + let valve_response = valve::query( + &SocketAddr::new(*address, port.unwrap_or(26901)), + SteamApp::CREATIVERSE.as_engine(), + None, + None, + )?; + + Ok(game::Response::new_from_valve_response(valve_response)) +} diff --git a/src/games/definitions.rs b/src/games/definitions.rs index 81ea4ae..bb4951f 100644 --- a/src/games/definitions.rs +++ b/src/games/definitions.rs @@ -47,6 +47,7 @@ pub static GAMES: Map<&'static str, Game> = phf_map! { "cscz" => game!("Counter Strike: Condition Zero", 27015, Protocol::Valve(SteamApp::CSCZ)), "csgo" => game!("Counter-Strike: Global Offensive", 27015, Protocol::Valve(SteamApp::CSGO)), "css" => game!("Counter-Strike: Source", 27015, Protocol::Valve(SteamApp::CSS)), + "creativerse" => game!("Creativerse", 26901, Protocol::Valve(SteamApp::CREATIVERSE)), "cw" => game!("Crysis Wars", 64100, Protocol::Gamespy(GameSpyVersion::Three)), "dod" => game!("Day of Defeat", 27015, Protocol::Valve(SteamApp::DOD)), "dods" => game!("Day of Defeat: Source", 27015, Protocol::Valve(SteamApp::DODS)), diff --git a/src/games/mod.rs b/src/games/mod.rs index f3bdae3..16a4c67 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -29,6 +29,8 @@ pub mod bo; pub mod ccure; /// Colony Survival pub mod cosu; +/// Creativerse +pub mod creativerse; /// Counter-Strike pub mod cs; /// Counter Strike: Condition Zero diff --git a/src/protocols/valve/types.rs b/src/protocols/valve/types.rs index fde61f0..500aa07 100644 --- a/src/protocols/valve/types.rs +++ b/src/protocols/valve/types.rs @@ -255,6 +255,8 @@ impl Request { pub enum SteamApp { /// Counter-Strike CS, + /// Creativerse + CREATIVERSE, /// Team Fortress Classic TFC, /// Day of Defeat @@ -361,6 +363,7 @@ impl SteamApp { Self::INS => Engine::new_source(222_880), Self::SDTD => Engine::new_source(251_570), Self::RUST => Engine::new_source(252_490), + Self::CREATIVERSE => Engine::new_source(280_790), Self::BO => Engine::new_source(296_300), Self::DST => Engine::new_source(322_320), Self::BB2 => Engine::new_source(346_330),