mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Reduce game implementation repetition (#122)
* [Games] Add macro to replace valve game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all valve game query functions. * [Games] Add macro to replace gamespy game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all gamespy game query functions. * [Games] Add macro to replace quake game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all quake game query functions. * [Games] Move all valve game modules into a single file using macros Vastly reduces the number of files. However does break the game definition-per-file test, so that was removed. * [Games] Move all quake game modules into a single file using macros * [Games] Move all gamespy game modules into a single file using macros * [Docs] Update CHANGELOG * [Docs] Improve game query function generation macro documentation * [Games] Add missed Halo: Combat Evolved to gamespy
This commit is contained in:
parent
c8a93357cf
commit
3b9c784e70
61 changed files with 250 additions and 872 deletions
|
|
@ -10,6 +10,12 @@ Protocols:
|
||||||
- Minecraft Java: Add derives to `RequestSettings` and add `new_just_hostname` that creates new settings just by specifying
|
- Minecraft Java: Add derives to `RequestSettings` and add `new_just_hostname` that creates new settings just by specifying
|
||||||
the hostname, `protocol_version` defaults to -1.
|
the hostname, `protocol_version` defaults to -1.
|
||||||
|
|
||||||
|
Games:
|
||||||
|
- Organised game modules into protocols (when protocol used by other games),
|
||||||
|
you can now access a game by its name or by its protocol name:
|
||||||
|
- `use gamedig::games::teamfortress2;`
|
||||||
|
- `use gamedig::games::valve::teamfortress2;`
|
||||||
|
|
||||||
Generics:
|
Generics:
|
||||||
- Added standard derives to `ProprietaryProtocol`, `CommonResponseJson`, `CommonPlayerJson`, `TimeoutSettings` and
|
- Added standard derives to `ProprietaryProtocol`, `CommonResponseJson`, `CommonPlayerJson`, `TimeoutSettings` and
|
||||||
`ExtraRequestSettings`.
|
`ExtraRequestSettings`.
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(2304)),
|
|
||||||
SteamApp::A2OA.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::ALIENSWARM.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::AOC.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::ASE.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(2304)),
|
|
||||||
SteamApp::ASRD.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27020)),
|
|
||||||
SteamApp::AVORION.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::BALLISTICOVERKILL.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
use crate::protocols::gamespy;
|
|
||||||
use crate::protocols::gamespy::one::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(23000)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::BLACKMESA.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::BRAINBREAD2.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::CODENAMECURE.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27004)),
|
|
||||||
SteamApp::COLONYSURVIVAL.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::COUNTERSTRIKE.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
use crate::protocols::gamespy;
|
|
||||||
use crate::protocols::gamespy::three::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
|
||||||
gamespy::three::query(&SocketAddr::new(*address, port.unwrap_or(64100)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::CSCZ.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::CSGO.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::CSS.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -89,31 +89,3 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
|
||||||
"jc2m" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2M)),
|
"jc2m" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2M)),
|
||||||
"warsow" => game!("Warsow", 44400, Protocol::Quake(QuakeVersion::Three)),
|
"warsow" => game!("Warsow", 44400, Protocol::Quake(QuakeVersion::Three)),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::GAMES;
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn check_game_files_match_defs() {
|
|
||||||
let ignore = [
|
|
||||||
"mod", // Module file
|
|
||||||
"definitions", // This file
|
|
||||||
"minecraft", // Has various defs
|
|
||||||
"sd2d", // Module names cannot start with numbers
|
|
||||||
];
|
|
||||||
|
|
||||||
for file in fs::read_dir("./src/games/").unwrap() {
|
|
||||||
let file = file.unwrap();
|
|
||||||
let metadata = file.metadata().unwrap();
|
|
||||||
if metadata.is_file() {
|
|
||||||
if let Some(file_name) = file.file_name().into_string().unwrap().strip_suffix(".rs") {
|
|
||||||
if !ignore.contains(&file_name) && !GAMES.contains_key(file_name) {
|
|
||||||
panic!("Expected GAMES to contain a definition to match {file_name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::DOD.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::DODS.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::DOI.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::DST.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
9
src/games/gamespy.rs
Normal file
9
src/games/gamespy.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
//! Gamespy game query modules
|
||||||
|
|
||||||
|
use crate::protocols::gamespy::game_query_mod;
|
||||||
|
|
||||||
|
game_query_mod!(battlefield1942, "Battlefield 1942", one, 23000);
|
||||||
|
game_query_mod!(crysiswars, "Crysis Wars", three, 64100);
|
||||||
|
game_query_mod!(hce, "Halo: Combat Evolved", two, 2302);
|
||||||
|
game_query_mod!(serioussam, "Serious Sam", one, 25601);
|
||||||
|
game_query_mod!(unrealtournament, "Unreal Tournament", one, 7778);
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::GARRYSMOD.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
use crate::protocols::gamespy;
|
|
||||||
use crate::protocols::gamespy::two::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
|
||||||
gamespy::two::query(&SocketAddr::new(*address, port.unwrap_or(2302)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::HL2D.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::HLDS.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(26420)),
|
|
||||||
SteamApp::HLL.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::IMIC.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::INSURGENCY.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27131)),
|
|
||||||
SteamApp::INSURGENCYSANDSTORM.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::LEFT4DEAD.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::LEFT4DEAD2.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
110
src/games/mod.rs
110
src/games/mod.rs
|
|
@ -3,118 +3,24 @@
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// ARMA 2: Operation Arrowhead
|
pub mod gamespy;
|
||||||
pub mod a2oa;
|
pub mod quake;
|
||||||
/// Alien Swarm
|
pub mod valve;
|
||||||
pub mod alienswarm;
|
|
||||||
/// Age of Chivalry
|
pub use gamespy::*;
|
||||||
pub mod aoc;
|
pub use quake::*;
|
||||||
/// ARK: Survival Evolved
|
pub use valve::*;
|
||||||
pub mod ase;
|
|
||||||
/// Alien Swarm: Reactive Drop
|
|
||||||
pub mod asrd;
|
|
||||||
/// Avorion
|
|
||||||
pub mod avorion;
|
|
||||||
/// Ballistic Overkill
|
|
||||||
pub mod ballisticoverkill;
|
|
||||||
/// Battalion 1944
|
/// Battalion 1944
|
||||||
pub mod battalion1944;
|
pub mod battalion1944;
|
||||||
/// Battlefield 1942
|
|
||||||
pub mod battlefield1942;
|
|
||||||
/// Black Mesa
|
|
||||||
pub mod blackmesa;
|
|
||||||
/// BrainBread 2
|
|
||||||
pub mod brainbread2;
|
|
||||||
/// Codename CURE
|
|
||||||
pub mod codenamecure;
|
|
||||||
/// Colony Survival
|
|
||||||
pub mod colonysurvival;
|
|
||||||
/// Counter-Strike
|
|
||||||
pub mod counterstrike;
|
|
||||||
/// Creativerse
|
|
||||||
pub mod creativerse;
|
|
||||||
/// Crysis Wars
|
|
||||||
pub mod crysiswars;
|
|
||||||
/// Counter Strike: Condition Zero
|
|
||||||
pub mod cscz;
|
|
||||||
/// Counter-Strike: Global Offensive
|
|
||||||
pub mod csgo;
|
|
||||||
/// Counter-Strike: Source
|
|
||||||
pub mod css;
|
|
||||||
/// Day of Defeat
|
|
||||||
pub mod dod;
|
|
||||||
/// Day of Defeat: Source
|
|
||||||
pub mod dods;
|
|
||||||
/// Day of Infamy
|
|
||||||
pub mod doi;
|
|
||||||
/// Don't Starve Together
|
|
||||||
pub mod dst;
|
|
||||||
/// Frontlines: Fuel of War
|
/// Frontlines: Fuel of War
|
||||||
pub mod ffow;
|
pub mod ffow;
|
||||||
/// Garry's Mod
|
|
||||||
pub mod garrysmod;
|
|
||||||
/// Halo: Combat Evolved
|
|
||||||
pub mod hce;
|
|
||||||
/// Half-Life 2 Deathmatch
|
|
||||||
pub mod hl2d;
|
|
||||||
/// Half-Life Deathmatch: Source
|
|
||||||
pub mod hlds;
|
|
||||||
/// Hell Let Loose
|
|
||||||
pub mod hll;
|
|
||||||
/// Insurgency: Modern Infantry Combat
|
|
||||||
pub mod imic;
|
|
||||||
/// Insurgency
|
|
||||||
pub mod insurgency;
|
|
||||||
/// Insurgency: Sandstorm
|
|
||||||
pub mod insurgencysandstorm;
|
|
||||||
/// Just Cause 2: Multiplayer
|
/// Just Cause 2: Multiplayer
|
||||||
pub mod jc2m;
|
pub mod jc2m;
|
||||||
/// Left 4 Dead
|
|
||||||
pub mod left4dead;
|
|
||||||
/// Left 4 Dead 2
|
|
||||||
pub mod left4dead2;
|
|
||||||
/// Minecraft
|
/// Minecraft
|
||||||
pub mod minecraft;
|
pub mod minecraft;
|
||||||
/// Operation: Harsh Doorstop
|
|
||||||
pub mod ohd;
|
|
||||||
/// Onset
|
|
||||||
pub mod onset;
|
|
||||||
/// Project Zomboid
|
|
||||||
pub mod projectzomboid;
|
|
||||||
/// Quake 1
|
|
||||||
pub mod quake1;
|
|
||||||
/// Quake 2
|
|
||||||
pub mod quake2;
|
|
||||||
/// Quake 3: Arena
|
|
||||||
pub mod quake3;
|
|
||||||
/// Risk of Rain 2
|
|
||||||
pub mod ror2;
|
|
||||||
/// Rust
|
|
||||||
pub mod rust;
|
|
||||||
/// Sven Co-op
|
|
||||||
pub mod sco;
|
|
||||||
/// 7 Days To Die
|
|
||||||
pub mod sd2d;
|
|
||||||
/// Serious Sam
|
|
||||||
pub mod serioussam;
|
|
||||||
/// Soldier of Fortune 2
|
|
||||||
pub mod sof2;
|
|
||||||
/// Team Fortress 2
|
|
||||||
pub mod teamfortress2;
|
|
||||||
/// Team Fortress Classic
|
|
||||||
pub mod tfc;
|
|
||||||
/// The Forest
|
|
||||||
pub mod theforest;
|
|
||||||
/// The Ship
|
/// The Ship
|
||||||
pub mod theship;
|
pub mod theship;
|
||||||
/// Unreal Tournament
|
|
||||||
pub mod unrealtournament;
|
|
||||||
/// Unturned
|
|
||||||
pub mod unturned;
|
|
||||||
/// V Rising
|
|
||||||
pub mod vrising;
|
|
||||||
/// Warsow
|
|
||||||
pub mod warsow;
|
|
||||||
|
|
||||||
use crate::protocols::gamespy::GameSpyVersion;
|
use crate::protocols::gamespy::GameSpyVersion;
|
||||||
use crate::protocols::quake::QuakeVersion;
|
use crate::protocols::quake::QuakeVersion;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27005)),
|
|
||||||
SteamApp::OHD.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(7776)),
|
|
||||||
SteamApp::ONSET.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(16261)),
|
|
||||||
SteamApp::PROJECTZOMBOID.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
9
src/games/quake.rs
Normal file
9
src/games/quake.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
//! Quake game query modules
|
||||||
|
|
||||||
|
use crate::protocols::quake::game_query_mod;
|
||||||
|
|
||||||
|
game_query_mod!(quake1, "Quake 1", one, 27500);
|
||||||
|
game_query_mod!(quake2, "Quake 2", two, 27910);
|
||||||
|
game_query_mod!(quake3, "Quake 3: Arena", three, 27960);
|
||||||
|
game_query_mod!(sof2, "Soldier of Fortune 2", three, 20100);
|
||||||
|
game_query_mod!(warsow, "Warsow", three, 44400);
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::protocols::quake;
|
|
||||||
use crate::protocols::quake::one::Player;
|
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
|
||||||
quake::one::query(&SocketAddr::new(*address, port.unwrap_or(27500)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::protocols::quake;
|
|
||||||
use crate::protocols::quake::two::Player;
|
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
|
||||||
quake::two::query(&SocketAddr::new(*address, port.unwrap_or(27910)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::protocols::quake;
|
|
||||||
use crate::protocols::quake::two::Player;
|
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
|
||||||
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(27960)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::ROR2.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::RUST.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::SCO.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(26900)),
|
|
||||||
SteamApp::SD2D.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
use crate::protocols::gamespy;
|
|
||||||
use crate::protocols::gamespy::one::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(25601)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::protocols::quake;
|
|
||||||
use crate::protocols::quake::two::Player;
|
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
|
||||||
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(20100)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::TEAMFORTRESS2.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::TFC.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::THEFOREST.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
use crate::protocols::gamespy;
|
|
||||||
use crate::protocols::gamespy::one::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
|
||||||
gamespy::one::query(&SocketAddr::new(*address, port.unwrap_or(7778)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
|
||||||
SteamApp::UNTURNED.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
55
src/games/valve.rs
Normal file
55
src/games/valve.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
//! Valve game query modules
|
||||||
|
|
||||||
|
use crate::protocols::valve::game_query_mod;
|
||||||
|
|
||||||
|
game_query_mod!(a2oa, "ARMA 2: Operation Arrowhead", A2OA, 2304);
|
||||||
|
game_query_mod!(alienswarm, "Alien Swarm", ALIENSWARM, 27015);
|
||||||
|
game_query_mod!(aoc, "Age of Chivalry", AOC, 27015);
|
||||||
|
game_query_mod!(ase, "ARK: Survival Evolved", ASE, 27015);
|
||||||
|
game_query_mod!(asrd, "Alien Swarm: Reactive Drop", ASRD, 2304);
|
||||||
|
game_query_mod!(avorion, "Avorion", AVORION, 27020);
|
||||||
|
game_query_mod!(
|
||||||
|
ballisticoverkill,
|
||||||
|
"Ballistic Overkill",
|
||||||
|
BALLISTICOVERKILL,
|
||||||
|
27016
|
||||||
|
);
|
||||||
|
game_query_mod!(blackmesa, "Black Mesa", BLACKMESA, 27015);
|
||||||
|
game_query_mod!(brainbread2, "BrainBread 2", BRAINBREAD2, 27015);
|
||||||
|
game_query_mod!(codenamecure, "Codename CURE", CODENAMECURE, 27015);
|
||||||
|
game_query_mod!(colonysurvival, "Colony Survival", COLONYSURVIVAL, 27004);
|
||||||
|
game_query_mod!(counterstrike, "Counter-Strike", COUNTERSTRIKE, 27015);
|
||||||
|
game_query_mod!(creativerse, "Creativerse", CREATIVERSE, 26901);
|
||||||
|
game_query_mod!(cscz, "Counter Strike: Condition Zero", CSCZ, 27015);
|
||||||
|
game_query_mod!(csgo, "Counter-Strike: Global Offensive", CSGO, 27015);
|
||||||
|
game_query_mod!(css, "Counter-Strike: Source", CSS, 27015);
|
||||||
|
game_query_mod!(dod, "Day of Defeat", DOD, 27015);
|
||||||
|
game_query_mod!(dods, "Day of Defeat: Source", DODS, 27015);
|
||||||
|
game_query_mod!(doi, "Day of Infamy", DOI, 27015);
|
||||||
|
game_query_mod!(dst, "Don't Starve Together", DST, 27016);
|
||||||
|
game_query_mod!(garrysmod, "Garry's Mod", GARRYSMOD, 27016);
|
||||||
|
game_query_mod!(hl2d, "Half-Life 2 Deathmatch", HL2D, 27015);
|
||||||
|
game_query_mod!(hlds, "Half-Life Deathmatch: Source", HLDS, 27015);
|
||||||
|
game_query_mod!(hll, "Hell Let Loose", HLL, 26420);
|
||||||
|
game_query_mod!(imic, "Insurgency: Modern Infantry Combat", IMIC, 27015);
|
||||||
|
game_query_mod!(insurgency, "Insurgency", INSURGENCY, 27015);
|
||||||
|
game_query_mod!(
|
||||||
|
insurgencysandstorm,
|
||||||
|
"Insurgency: Sandstorm",
|
||||||
|
INSURGENCYSANDSTORM,
|
||||||
|
27131
|
||||||
|
);
|
||||||
|
game_query_mod!(left4dead, "Left 4 Dead", LEFT4DEAD, 27015);
|
||||||
|
game_query_mod!(left4dead2, "Left 4 Dead 2", LEFT4DEAD2, 27015);
|
||||||
|
game_query_mod!(ohd, "Operation: Harsh Doorstop", OHD, 27005);
|
||||||
|
game_query_mod!(onset, "Onset", ONSET, 7776);
|
||||||
|
game_query_mod!(projectzomboid, "Project Zomboid", PROJECTZOMBOID, 16261);
|
||||||
|
game_query_mod!(ror2, "Risk of Rain 2", ROR2, 27016);
|
||||||
|
game_query_mod!(rust, "Rust", RUST, 27015);
|
||||||
|
game_query_mod!(sco, "Sven Co-op", SCO, 27015);
|
||||||
|
game_query_mod!(sd2d, "7 Days To Die", SD2D, 26900);
|
||||||
|
game_query_mod!(teamfortress2, "Team Fortress 2", TEAMFORTRESS2, 27015);
|
||||||
|
game_query_mod!(tfc, "Team Fortress Classic", TFC, 27015);
|
||||||
|
game_query_mod!(theforest, "The Forest", THEFOREST, 27016);
|
||||||
|
game_query_mod!(unturned, "Unturned", UNTURNED, 27015);
|
||||||
|
game_query_mod!(vrising, "V Rising", VRISING, 27016);
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{
|
|
||||||
protocols::valve::{self, game, SteamApp},
|
|
||||||
GDResult,
|
|
||||||
};
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
|
|
||||||
let valve_response = valve::query(
|
|
||||||
&SocketAddr::new(*address, port.unwrap_or(27016)),
|
|
||||||
SteamApp::VRISING.as_engine(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(game::Response::new_from_valve_response(valve_response))
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::protocols::quake;
|
|
||||||
use crate::protocols::quake::two::Player;
|
|
||||||
use crate::protocols::quake::Response;
|
|
||||||
use crate::GDResult;
|
|
||||||
use std::net::{IpAddr, SocketAddr};
|
|
||||||
|
|
||||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response<Player>> {
|
|
||||||
quake::three::query(&SocketAddr::new(*address, port.unwrap_or(44400)), None)
|
|
||||||
}
|
|
||||||
|
|
@ -31,3 +31,56 @@ pub enum VersionedPlayer<'a> {
|
||||||
Two(&'a two::Player),
|
Two(&'a two::Player),
|
||||||
Three(&'a three::Player),
|
Three(&'a three::Player),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generate a module containing a query function for a gamespy game.
|
||||||
|
///
|
||||||
|
/// * `mod_name` - The name to be given to the game module (see ID naming
|
||||||
|
/// conventions in CONTRIBUTING.md).
|
||||||
|
/// * `pretty_name` - The full name of the game, will be used as the
|
||||||
|
/// documentation for the created module.
|
||||||
|
/// * `gamespy_ver`, `default_port` - Passed through to [game_query_fn].
|
||||||
|
macro_rules! game_query_mod {
|
||||||
|
($mod_name: ident, $pretty_name: expr, $gamespy_ver: ident, $default_port: literal) => {
|
||||||
|
#[doc = $pretty_name]
|
||||||
|
pub mod $mod_name {
|
||||||
|
crate::protocols::gamespy::game_query_fn!($gamespy_ver, $default_port);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_mod;
|
||||||
|
|
||||||
|
// Allow generating doc comments:
|
||||||
|
// https://users.rust-lang.org/t/macros-filling-text-in-comments/20473
|
||||||
|
/// Generate a query function for a gamespy game.
|
||||||
|
///
|
||||||
|
/// * `gamespy_ver` - The name of the [module](crate::protocols::gamespy) for
|
||||||
|
/// the gamespy version the game uses.
|
||||||
|
/// * `default_port` - The default port the game uses.
|
||||||
|
///
|
||||||
|
/// ```rust,ignore
|
||||||
|
/// use crate::protocols::gamespy::game_query_fn;
|
||||||
|
/// game_query_fn!(one, 7778);
|
||||||
|
/// ```
|
||||||
|
macro_rules! game_query_fn {
|
||||||
|
($gamespy_ver: ident, $default_port: literal) => {
|
||||||
|
crate::protocols::gamespy::game_query_fn! {@gen $gamespy_ver, $default_port, concat!(
|
||||||
|
"Make a gamespy ", stringify!($gamespy_ver), " query with default timeout settings.\n\n",
|
||||||
|
"If port is `None`, then the default port (", stringify!($default_port), ") will be used.")}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@gen $gamespy_ver: ident, $default_port: literal, $doc: expr) => {
|
||||||
|
#[doc = $doc]
|
||||||
|
pub fn query(
|
||||||
|
address: &std::net::IpAddr,
|
||||||
|
port: Option<u16>,
|
||||||
|
) -> crate::GDResult<crate::protocols::gamespy::$gamespy_ver::Response> {
|
||||||
|
crate::protocols::gamespy::$gamespy_ver::query(
|
||||||
|
&std::net::SocketAddr::new(*address, port.unwrap_or($default_port)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_fn;
|
||||||
|
|
|
||||||
|
|
@ -18,3 +18,57 @@ pub enum QuakeVersion {
|
||||||
Two,
|
Two,
|
||||||
Three,
|
Three,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generate a module containing a query function for a quake game.
|
||||||
|
///
|
||||||
|
/// * `mod_name` - The name to be given to the game module (see ID naming
|
||||||
|
/// conventions in CONTRIBUTING.md).
|
||||||
|
/// * `pretty_name` - The full name of the game, will be used as the
|
||||||
|
/// documentation for the created module.
|
||||||
|
/// * `quake_ver`, `default_port` - Passed through to [game_query_fn].
|
||||||
|
macro_rules! game_query_mod {
|
||||||
|
($mod_name: ident, $pretty_name: expr, $quake_ver: ident, $default_port: literal) => {
|
||||||
|
#[doc = $pretty_name]
|
||||||
|
pub mod $mod_name {
|
||||||
|
crate::protocols::quake::game_query_fn!($quake_ver, $default_port);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_mod;
|
||||||
|
|
||||||
|
// Allow generating doc comments:
|
||||||
|
// https://users.rust-lang.org/t/macros-filling-text-in-comments/20473
|
||||||
|
/// Generate a query function for a quake game.
|
||||||
|
///
|
||||||
|
/// * `quake_ver` - The name of the [module](crate::protocols::quake) for the
|
||||||
|
/// quake version the game uses.
|
||||||
|
/// * `default_port` - The default port the game uses.
|
||||||
|
///
|
||||||
|
/// ```rust,ignore
|
||||||
|
/// use crate::protocols::quake::game_query_fn;
|
||||||
|
/// game_query_fn!(one, 27500);
|
||||||
|
/// ```
|
||||||
|
macro_rules! game_query_fn {
|
||||||
|
($quake_ver: ident, $default_port: literal) => {
|
||||||
|
use crate::protocols::quake::$quake_ver::Player;
|
||||||
|
crate::protocols::quake::game_query_fn! {@gen $quake_ver, Player, $default_port, concat!(
|
||||||
|
"Make a quake ", stringify!($quake_ver), " query with default timeout settings.\n\n",
|
||||||
|
"If port is `None`, then the default port (", stringify!($default_port), ") will be used.")}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@gen $quake_ver: ident, $player_type: ty, $default_port: literal, $doc: expr) => {
|
||||||
|
#[doc = $doc]
|
||||||
|
pub fn query(
|
||||||
|
address: &std::net::IpAddr,
|
||||||
|
port: Option<u16>,
|
||||||
|
) -> crate::GDResult<crate::protocols::quake::Response<$player_type>> {
|
||||||
|
crate::protocols::quake::$quake_ver::query(
|
||||||
|
&std::net::SocketAddr::new(*address, port.unwrap_or($default_port)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_fn;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
use crate::protocols::quake::client::{client_query, QuakeClient};
|
use crate::protocols::quake::client::{client_query, QuakeClient};
|
||||||
use crate::protocols::quake::two::{Player, QuakeTwo};
|
use crate::protocols::quake::two::QuakeTwo;
|
||||||
use crate::protocols::quake::Response;
|
use crate::protocols::quake::Response;
|
||||||
use crate::protocols::types::TimeoutSettings;
|
use crate::protocols::types::TimeoutSettings;
|
||||||
use crate::GDResult;
|
use crate::GDResult;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
|
|
||||||
|
pub use crate::protocols::quake::two::Player;
|
||||||
|
|
||||||
struct QuakeThree;
|
struct QuakeThree;
|
||||||
impl QuakeClient for QuakeThree {
|
impl QuakeClient for QuakeThree {
|
||||||
type Player = Player;
|
type Player = Player;
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,56 @@ pub mod types;
|
||||||
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
|
||||||
|
/// Generate a module containing a query function for a valve game.
|
||||||
|
///
|
||||||
|
/// * `mod_name` - The name to be given to the game module (see ID naming
|
||||||
|
/// conventions in CONTRIBUTING.md).
|
||||||
|
/// * `pretty_name` - The full name of the game, will be used as the
|
||||||
|
/// documentation for the created module.
|
||||||
|
/// * `steam_app`, `default_port` - Passed through to [game_query_fn].
|
||||||
|
macro_rules! game_query_mod {
|
||||||
|
($mod_name: ident, $pretty_name: expr, $steam_app: ident, $default_port: literal) => {
|
||||||
|
#[doc = $pretty_name]
|
||||||
|
pub mod $mod_name {
|
||||||
|
crate::protocols::valve::game_query_fn!($steam_app, $default_port);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_mod;
|
||||||
|
|
||||||
|
// Allow generating doc comments:
|
||||||
|
// https://users.rust-lang.org/t/macros-filling-text-in-comments/20473
|
||||||
|
/// Generate a query function for a valve game.
|
||||||
|
///
|
||||||
|
/// * `steam_app` - The entry in the [SteamApp] enum that the game uses.
|
||||||
|
/// * `default_port` - The default port the game uses.
|
||||||
|
///
|
||||||
|
/// ```rust,ignore
|
||||||
|
/// use crate::protocols::valve::game_query_fn;
|
||||||
|
/// game_query_fn!(TEAMFORTRESS2, 27015);
|
||||||
|
/// ```
|
||||||
|
macro_rules! game_query_fn {
|
||||||
|
($steam_app: ident, $default_port: literal) => {
|
||||||
|
crate::protocols::valve::game_query_fn!{@gen $steam_app, $default_port, concat!(
|
||||||
|
"Make a valve query for ", stringify!($steam_app), " with default timeout settings and default extra request settings.\n\n",
|
||||||
|
"If port is `None`, then the default port (", stringify!($default_port), ") will be used.")}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@gen $steam_app: ident, $default_port: literal, $doc: expr) => {
|
||||||
|
#[doc = $doc]
|
||||||
|
pub fn query(address: &std::net::IpAddr, port: Option<u16>) -> crate::GDResult<crate::protocols::valve::game::Response> {
|
||||||
|
let valve_response = crate::protocols::valve::query(
|
||||||
|
&std::net::SocketAddr::new(*address, port.unwrap_or($default_port)),
|
||||||
|
crate::protocols::valve::SteamApp::$steam_app.as_engine(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(crate::protocols::valve::game::Response::new_from_valve_response(valve_response))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use game_query_fn;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue