diff --git a/src/games/definitions.rs b/src/games/definitions.rs index d05496e..daa4571 100644 --- a/src/games/definitions.rs +++ b/src/games/definitions.rs @@ -9,6 +9,7 @@ use crate::protocols::{ }; use crate::Game; +use crate::protocols::types::ProprietaryProtocol; use phf::{phf_map, Map}; macro_rules! game { @@ -51,7 +52,7 @@ pub static GAMES: Map<&'static str, Game> = phf_map! { "dods" => game!("Day of Defeat: Source", 27015, Protocol::Valve(SteamApp::DODS)), "doi" => game!("Day of Infamy", 27015, Protocol::Valve(SteamApp::DOI)), "dst" => game!("Don't Starve Together", 27016, Protocol::Valve(SteamApp::DST)), - "ffow" => game!("Frontlines: Fuel of War", 5478, Protocol::FFOW), + "ffow" => game!("Frontlines: Fuel of War", 5478, Protocol::PROPRIETARY(ProprietaryProtocol::FFOW)), "gm" => game!("Garry's Mod", 27016, Protocol::Valve(SteamApp::GM)), "hl2dm" => game!("Half-Life 2 Deathmatch", 27015, Protocol::Valve(SteamApp::HL2DM)), "haloce" => game!("Halo: Combat Evolved", 2302, Protocol::Gamespy(GameSpyVersion::Two)), @@ -77,9 +78,9 @@ pub static GAMES: Map<&'static str, Game> = phf_map! { "tf" => game!("The Forest", 27016, Protocol::Valve(SteamApp::TF)), "tf2" => game!("Team Fortress 2", 27015, Protocol::Valve(SteamApp::TF2)), "tfc" => game!("Team Fortress Classic", 27015, Protocol::Valve(SteamApp::TFC)), - "ts" => game!("The Ship", 27015, Protocol::TheShip), + "ts" => game!("The Ship", 27015, Protocol::PROPRIETARY(ProprietaryProtocol::TheShip)), "unturned" => game!("Unturned", 27015, Protocol::Valve(SteamApp::UNTURNED)), "ut" => game!("Unreal Tournament", 7778, Protocol::Gamespy(GameSpyVersion::One)), "vr" => game!("V Rising", 27016, Protocol::Valve(SteamApp::VR)), - "jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::JC2MP), + "jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2MP)), }; diff --git a/src/games/mod.rs b/src/games/mod.rs index 944d971..0d5741d 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -114,7 +114,7 @@ pub mod vr; use crate::protocols::gamespy::GameSpyVersion; use crate::protocols::quake::QuakeVersion; -use crate::protocols::types::CommonResponse; +use crate::protocols::types::{CommonResponse, ProprietaryProtocol}; use crate::protocols::{self, Protocol}; use crate::GDResult; use std::net::{IpAddr, SocketAddr}; @@ -172,8 +172,12 @@ pub fn query(game: &Game, address: &IpAddr, port: Option) -> GDResult protocols::quake::three::query(&socket_addr, None).map(Box::new)?, } } - Protocol::TheShip => ts::query(address, port).map(Box::new)?, - Protocol::FFOW => ffow::query(address, port).map(Box::new)?, - Protocol::JC2MP => jc2mp::query(address, port).map(Box::new)?, + Protocol::PROPRIETARY(protocol) => { + match protocol { + ProprietaryProtocol::TheShip => ts::query(address, port).map(Box::new)?, + ProprietaryProtocol::FFOW => ffow::query(address, port).map(Box::new)?, + ProprietaryProtocol::JC2MP => jc2mp::query(address, port).map(Box::new)?, + } + } }) } diff --git a/src/protocols/types.rs b/src/protocols/types.rs index b761453..f02f383 100644 --- a/src/protocols/types.rs +++ b/src/protocols/types.rs @@ -6,6 +6,15 @@ use std::time::Duration; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +/// Enumeration of all custom protocols +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[derive(Debug, Clone, PartialEq)] +pub enum ProprietaryProtocol { + TheShip, + FFOW, + JC2MP, +} + /// Enumeration of all valid protocol types #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, PartialEq)] @@ -15,10 +24,7 @@ pub enum Protocol { Quake(quake::QuakeVersion), Valve(valve::SteamApp), #[cfg(not(feature = "no_games"))] - TheShip, - #[cfg(not(feature = "no_games"))] - FFOW, - JC2MP, + PROPRIETARY(ProprietaryProtocol), } /// All response types