[Games] Update game definitions to match node-gamedig names (#100)

* [Games] Update game definitions to match node-gamedig names

* Update game file names to match definitions

* [Games] rename minecraft definitions to better match node

* [Games] Add test that all game files match definition name

* Update SteamApp to match node names

* [Games] Update the forest to match node-GameDig#367

* Clippy fix in games test

* [Docs] Update GAMES.md with new names

* [DOCS] Update changelog
This commit is contained in:
Tom 2023-09-22 21:20:01 +00:00 committed by GitHub
parent 14c3f4525b
commit 52750fba76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 319 additions and 281 deletions

View file

@ -28,6 +28,10 @@ Generics:
- Changed `players_maximum` and `players_online` (and their functions) types from `u64` to `u32`.
- Changed `score` type (and the function) of player from `u32` to `i32`.
Games:
- Renamed game definitions to better match node-gamedig
- Renamed game implementations to match new definition names
Protocols:
- Valve:
1. Renamed `protocol` to `protocol_version`.
@ -36,6 +40,7 @@ Protocols:
4. Fixed `player`'s `score` field being `u32` when it needed to be `i32`, as specified in the protocol.
5. Added the field `check_app_id` to `GatherSettings` which controls if the app id specified to the request and
reported by the server are the same, errors if not, enabled by default.
6. Valve: Renamed SteamApp enum variants to match new definition names
- GameSpy (1, 2, 3):
1. Renamed `version` to `game_version`.

View file

@ -6,27 +6,27 @@ Beware of the `Notes` column, as it contains information about query port offset
| Game | Use name | Protocol | Notes |
|------------------------------------|-------------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Team Fortress 2 | TF2 | Valve | |
| The Ship | TS | Valve (*Altered) | |
| The Ship | SHIP | 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 | |
| Left 4 Dead | LEFT4DEAD | Valve | |
| Left 4 Dead 2 | LEFT4DEAD2 | Valve | |
| Half-Life 2 Deathmatch | HL2DM | Valve | |
| Alien Swarm | ALIENS | Valve | |
| Alien Swarm | ALIENSWARM | Valve | |
| Alien Swarm: Reactive Drop | ASRD | Valve | |
| Insurgency | INS | Valve | |
| Insurgency: Sandstorm | INSS | Valve | Query port offset: 1. |
| Insurgency: Modern Infantry Combat | INSMIC | Valve | |
| Insurgency | INSURGENCY | Valve | |
| Insurgency: Sandstorm | INSURGENCYSANDSTORM | Valve | Query port offset: 1. |
| Insurgency: Modern Infantry Combat | INSURGENCYMIC | 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 | |
| Minecraft | MINECRAFT | 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 | SD2D | Valve | |
| ARK: Survival Evolved | ARKSE | Valve | |
| Unturned | UNTURNED | Valve | |
| The Forest | TF | Valve GoldSrc | Query port offset: 1. |
| The Forest | THEFOREST | Valve GoldSrc | Query port offset: 1. |
| Team Fortress Classic | TFC | Valve | |
| Sven Co-op | SC | Valve GoldSrc | |
| Sven Co-op | SVENCOOP | Valve GoldSrc | |
| Rust | RUST | Valve | |
| Counter-Strike | CS | Valve GoldSrc | |
| Arma 2: Operation Arrowhead | ARMA2OA | Valve | Query port offset: 1. |
@ -34,32 +34,33 @@ Beware of the `Notes` column, as it contains information about query port offset
| 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 | |
| Black Mesa | BLACKMESA | Valve | |
| Project Zomboid | PRZOMBOID | Valve | |
| Age of Chivalry | AGEOFCHIVALRY | Valve | |
| Don't Starve Together | DST | Valve | Query port is 27016. |
| Colony Survival | COLU | Valve | |
| Colony Survival | COLONYSURVIVAL | Valve | |
| Onset | ONSET | Valve | Query port is 7776. |
| Codename CURE | CCURE | Valve | |
| Ballistic Overkill | BO | Valve | Query port is 27016. |
| BrainBread 2 | BB2 | Valve | |
| Codename CURE | CODENAMECURE | Valve | |
| Ballistic Overkill | BALLISTICOVERKILL | Valve | Query port is 27016. |
| BrainBread 2 | BRAINBREAD2 | 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. |
| V Rising | VRISING | 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 | |
| Crysis Wars | CRYSISWARS | GameSpy 3 | |
| Quake 2 | QUAKE2 | Quake 2 | |
| Quake 1 | QUAKE1 | Quake 1 | |
| Quake 3: Arena | QUAKE3A | Quake 3 | |
| Quake 3: Arena | QUAKE3 | 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. |
| Garry's Mod | GARRYSMOD | Valve |
## Planned to add support:
_

View file

@ -82,13 +82,13 @@ mod test {
fn battlefield() { test_game("bf1942"); }
#[test]
fn minecraft() { test_game("mc"); }
fn minecraft() { test_game("minecraft"); }
#[test]
fn tf2() { test_game("tf2"); }
#[test]
fn quake() { test_game("quake3a"); }
fn quake() { test_game("quake3"); }
#[test]
fn all_games() {

View file

@ -3,61 +3,61 @@ use gamedig::protocols::valve;
use gamedig::protocols::valve::Engine;
use gamedig::protocols::{gamespy, quake};
use gamedig::{
aliens,
aoc,
ageofchivalry,
alienswarm,
arkse,
arma2oa,
ase,
asrd,
avorion,
ballisticoverkill,
bat1944,
bb2,
bf1942,
bm,
bo,
ccure,
cosu,
blackmesa,
brainbread2,
codenamecure,
colonysurvival,
creativerse,
crysiswars,
cs,
cscz,
csgo,
css,
cw,
dod,
dods,
doi,
dst,
ffow,
gm,
garrysmod,
haloce,
hl2dm,
hldms,
hll,
ins,
insmic,
inss,
insurgency,
insurgencymic,
insurgencysandstorm,
jc2mp,
l4d,
l4d2,
left4dead,
left4dead2,
mc,
ohd,
onset,
pz,
przomboid,
quake1,
quake2,
quake3a,
quake3,
ror2,
rust,
sc,
sdtd,
sd2d,
ship,
sof2,
ss,
tf,
svencoop,
tf2,
tfc,
ts,
theforest,
unturned,
ut,
vr,
vrising,
warsow,
GDResult,
};
@ -92,20 +92,20 @@ fn main() -> GDResult<()> {
let address = &SocketAddr::new(*ip, port.unwrap_or(0));
match args[1].as_str() {
"aliens" => println!("{:#?}", aliens::query(ip, port)?),
"alienswarm" => println!("{:#?}", alienswarm::query(ip, port)?),
"asrd" => println!("{:#?}", asrd::query(ip, port)?),
"csgo" => println!("{:#?}", csgo::query(ip, port)?),
"css" => println!("{:#?}", css::query(ip, port)?),
"dods" => println!("{:#?}", dods::query(ip, port)?),
"gm" => println!("{:#?}", gm::query(ip, port)?),
"garrysmod" => println!("{:#?}", garrysmod::query(ip, port)?),
"hl2dm" => println!("{:#?}", hl2dm::query(ip, port)?),
"tf2" => println!("{:#?}", tf2::query(ip, port)?),
"insmic" => println!("{:#?}", insmic::query(ip, port)?),
"ins" => println!("{:#?}", ins::query(ip, port)?),
"inss" => println!("{:#?}", inss::query(ip, port)?),
"l4d" => println!("{:#?}", l4d::query(ip, port)?),
"l4d2" => println!("{:#?}", l4d2::query(ip, port)?),
"ts" => println!("{:#?}", ts::query(ip, port)?),
"insurgencymic" => println!("{:#?}", insurgencymic::query(ip, port)?),
"insurgency" => println!("{:#?}", insurgency::query(ip, port)?),
"insurgencysandstorm" => println!("{:#?}", insurgencysandstorm::query(ip, port)?),
"left4dead" => println!("{:#?}", left4dead::query(ip, port)?),
"left4dead2" => println!("{:#?}", left4dead2::query(ip, port)?),
"ship" => println!("{:#?}", ship::query(ip, port)?),
"cscz" => println!("{:#?}", cscz::query(ip, port)?),
"dod" => println!("{:#?}", dod::query(ip, port)?),
"_src" => {
@ -148,12 +148,12 @@ fn main() -> GDResult<()> {
mc::query_legacy_specific(LegacyGroup::V1_6, ip, port)?
)
}
"7dtd" => println!("{:#?}", sdtd::query(ip, port)?),
"ase" => println!("{:#?}", ase::query(ip, port)?),
"7dtd" => println!("{:#?}", sd2d::query(ip, port)?),
"arkse" => println!("{:#?}", arkse::query(ip, port)?),
"unturned" => println!("{:#?}", unturned::query(ip, port)?),
"tf" => println!("{:#?}", tf::query(ip, port)?),
"theforest" => println!("{:#?}", theforest::query(ip, port)?),
"tfc" => println!("{:#?}", tfc::query(ip, port)?),
"sc" => println!("{:#?}", sc::query(ip, port)?),
"svencoop" => println!("{:#?}", svencoop::query(ip, port)?),
"rust" => println!("{:#?}", rust::query(ip, port)?),
"cs" => println!("{:#?}", cs::query(ip, port)?),
"arma2oa" => println!("{:#?}", arma2oa::query(ip, port)?),
@ -161,18 +161,18 @@ fn main() -> GDResult<()> {
"hldms" => println!("{:#?}", hldms::query(ip, port)?),
"ror2" => println!("{:#?}", ror2::query(ip, port)?),
"bat1944" => println!("{:#?}", bat1944::query(ip, port)?),
"bm" => println!("{:#?}", bm::query(ip, port)?),
"pz" => println!("{:#?}", pz::query(ip, port)?),
"aoc" => println!("{:#?}", aoc::query(ip, port)?),
"blackmesa" => println!("{:#?}", blackmesa::query(ip, port)?),
"przomboid" => println!("{:#?}", przomboid::query(ip, port)?),
"ageofchivalry" => println!("{:#?}", ageofchivalry::query(ip, port)?),
"dst" => println!("{:#?}", dst::query(ip, port)?),
"cosu" => println!("{:#?}", cosu::query(ip, port)?),
"colonysurvival" => println!("{:#?}", colonysurvival::query(ip, port)?),
"onset" => println!("{:#?}", onset::query(ip, port)?),
"ccure" => println!("{:#?}", ccure::query(ip, port)?),
"bo" => println!("{:#?}", bo::query(ip, port)?),
"bb2" => println!("{:#?}", bb2::query(ip, port)?),
"codenamecure" => println!("{:#?}", codenamecure::query(ip, port)?),
"ballisticoverkill" => println!("{:#?}", ballisticoverkill::query(ip, port)?),
"brainbread2" => println!("{:#?}", brainbread2::query(ip, port)?),
"avorion" => println!("{:#?}", avorion::query(ip, port)?),
"ohd" => println!("{:#?}", ohd::query(ip, port)?),
"vr" => println!("{:#?}", vr::query(ip, port)?),
"vrising" => println!("{:#?}", vrising::query(ip, port)?),
"_gamespy1" => println!("{:#?}", gamespy::one::query(address, None)),
"_gamespy1_vars" => println!("{:#?}", gamespy::one::query_vars(address, None)),
"ut" => println!("{:#?}", ut::query(ip, port)),
@ -181,13 +181,13 @@ fn main() -> GDResult<()> {
"_gamespy3" => println!("{:#?}", gamespy::three::query(address, None)),
"_gamespy3_vars" => println!("{:#?}", gamespy::three::query_vars(address, None)),
"ffow" => println!("{:#?}", ffow::query(ip, port)),
"cw" => println!("{:#?}", cw::query(ip, port)),
"crysiswars" => println!("{:#?}", crysiswars::query(ip, port)),
"_quake1" => println!("{:#?}", quake::one::query(address, None)),
"_quake2" => println!("{:#?}", quake::two::query(address, None)),
"_quake3" => println!("{:#?}", quake::three::query(address, None)),
"quake2" => println!("{:#?}", quake2::query(ip, port)?),
"quake1" => println!("{:#?}", quake1::query(ip, port)?),
"quake3a" => println!("{:#?}", quake3a::query(ip, port)?),
"quake3" => println!("{:#?}", quake3::query(ip, port)?),
"hll" => println!("{:#?}", hll::query(ip, port)?),
"sof2" => println!("{:#?}", sof2::query(ip, port)?),
"_gamespy2" => println!("{:#?}", gamespy::two::query(address, None)),

View file

@ -0,0 +1,16 @@
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::AGEOFCHIVALRY.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -7,7 +7,7 @@ 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::BB2.as_engine(),
SteamApp::ALIENSWARM.as_engine(),
None,
None,
)?;

View file

@ -7,7 +7,7 @@ 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::BM.as_engine(),
SteamApp::ARKSE.as_engine(),
None,
None,
)?;

View file

@ -7,7 +7,7 @@ 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::VR.as_engine(),
SteamApp::BALLISTICOVERKILL.as_engine(),
None,
None,
)?;

View file

@ -7,7 +7,7 @@ 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::ALIENS.as_engine(),
SteamApp::BLACKMESA.as_engine(),
None,
None,
)?;

16
src/games/brainbread2.rs Normal file
View file

@ -0,0 +1,16 @@
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))
}

View file

@ -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::CCURE.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

16
src/games/codenamecure.rs Normal file
View file

@ -0,0 +1,16 @@
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))
}

View file

@ -7,7 +7,7 @@ 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::COSU.as_engine(),
SteamApp::COLONYSURVIVAL.as_engine(),
None,
None,
)?;

View file

@ -24,65 +24,97 @@ macro_rules! game {
/// Map of all currently supported games
pub static GAMES: Map<&'static str, Game> = phf_map! {
"mc" => game!("Minecraft", 25565, Protocol::Minecraft(None)),
"mc-java" => game!("Minecraft (java)", 25565, Protocol::Minecraft(Some(Server::Java))),
"mc-bedrock" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"mc-legacy-1.6" => game!("Minecraft (legacy v1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))),
"mc-legacy-1.4" => game!("Minecraft (legacy v1.4-1.5)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4)))),
"mc-legacy-b1.8" => game!("Minecraft (legacy vB1.8-1.3)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8)))),
"aliens" => game!("Alien Swarm", 27015, Protocol::Valve(SteamApp::ALIENS)),
"aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(SteamApp::AOC)),
// Query with all minecraft protocols node-gamedig: minecraft,minecraftping
"minecraft" => game!("Minecraft", 25565, Protocol::Minecraft(None)),
"minecraftping" => game!("Minecraft", 25565, Protocol::Minecraft(None)),
// Query with specific minecraft protocols
"minecraftbe" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"minecraftpe" => game!("Minecraft (bedrock/pocket edition)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"minecraftjava" => game!("Minecraft (java)", 25565, Protocol::Minecraft(Some(Server::Java))),
"minecraft-legacy-1.6" => game!("Minecraft (legacy v1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))),
"minecraft-legacy-1.4" => game!("Minecraft (legacy v1.4-1.5)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4)))),
"minecraft-legacy-b1.8" => game!("Minecraft (legacy vB1.8-1.3)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8)))),
"alienswarm" => game!("Alien Swarm", 27015, Protocol::Valve(SteamApp::ALIENSWARM)),
"ageofchivalry" => game!("Age of Chivalry", 27015, Protocol::Valve(SteamApp::AGEOFCHIVALRY)),
"arma2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(SteamApp::ARMA2OA)),
"ase" => game!("ARK: Survival Evolved", 27015, Protocol::Valve(SteamApp::ASE)),
"arkse" => game!("ARK: Survival Evolved", 27015, Protocol::Valve(SteamApp::ARKSE)),
"asrd" => game!("Alien Swarm: Reactive Drop", 2304, Protocol::Valve(SteamApp::ASRD)),
"avorion" => game!("Avorion", 27020, Protocol::Valve(SteamApp::AVORION)),
"bat1944" => game!("Battalion 1944", 7780, Protocol::Valve(SteamApp::BAT1944)),
"bb2" => game!("BrainBread 2", 27015, Protocol::Valve(SteamApp::BB2)),
"brainbread2" => game!("BrainBread 2", 27015, Protocol::Valve(SteamApp::BRAINBREAD2)),
"bf1942" => game!("Battlefield 1942", 23000, Protocol::Gamespy(GameSpyVersion::One)),
"bm" => game!("Black Mesa", 27015, Protocol::Valve(SteamApp::BM)),
"bo" => game!("Ballistic Overkill", 27016, Protocol::Valve(SteamApp::BO)),
"ccure" => game!("Codename CURE", 27015, Protocol::Valve(SteamApp::CCURE)),
"cosu" => game!("Colony Survival", 27004, Protocol::Valve(SteamApp::COSU)),
"blackmesa" => game!("Black Mesa", 27015, Protocol::Valve(SteamApp::BLACKMESA)),
"ballisticoverkill" => game!("Ballistic Overkill", 27016, Protocol::Valve(SteamApp::BALLISTICOVERKILL)),
"codenamecure" => game!("Codename CURE", 27015, Protocol::Valve(SteamApp::CODENAMECURE)),
"colonysurvival" => game!("Colony Survival", 27004, Protocol::Valve(SteamApp::COLONYSURVIVAL)),
"cs" => game!("Counter-Strike", 27015, Protocol::Valve(SteamApp::CS)),
"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)),
"crysiswars" => 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)),
"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::PROPRIETARY(ProprietaryProtocol::FFOW)),
"gm" => game!("Garry's Mod", 27016, Protocol::Valve(SteamApp::GM)),
"garrysmod" => game!("Garry's Mod", 27016, Protocol::Valve(SteamApp::GARRYSMOD)),
"hl2dm" => game!("Half-Life 2 Deathmatch", 27015, Protocol::Valve(SteamApp::HL2DM)),
"haloce" => game!("Halo: Combat Evolved", 2302, Protocol::Gamespy(GameSpyVersion::Two)),
"hldms" => game!("Half-Life Deathmatch: Source", 27015, Protocol::Valve(SteamApp::HLDMS)),
"hll" => game!("Hell Let Loose", 26420, Protocol::Valve(SteamApp::HLL)),
"ins" => game!("Insurgency", 27015, Protocol::Valve(SteamApp::INS)),
"insmic" => game!("Insurgency: Modern Infantry Combat", 27015, Protocol::Valve(SteamApp::INSMIC)),
"inss" => game!("Insurgency: Sandstorm", 27131, Protocol::Valve(SteamApp::INSS)),
"l4d" => game!("Left 4 Dead", 27015, Protocol::Valve(SteamApp::L4D)),
"l4d2" => game!("Left 4 Dead 2", 27015, Protocol::Valve(SteamApp::L4D2)),
"insurgency" => game!("Insurgency", 27015, Protocol::Valve(SteamApp::INSURGENCY)),
"insurgencymic" => game!("Insurgency: Modern Infantry Combat", 27015, Protocol::Valve(SteamApp::INSURGENCYMIC)),
"insurgencysandstorm" => game!("Insurgency: Sandstorm", 27131, Protocol::Valve(SteamApp::INSURGENCYSANDSTORM)),
"left4dead" => game!("Left 4 Dead", 27015, Protocol::Valve(SteamApp::LEFT4DEAD)),
"left4dead2" => game!("Left 4 Dead 2", 27015, Protocol::Valve(SteamApp::LEFT4DEAD2)),
"ohd" => game!("Operation: Harsh Doorstop", 27005, Protocol::Valve(SteamApp::OHD)),
"onset" => game!("Onset", 7776, Protocol::Valve(SteamApp::ONSET)),
"pz" => game!("Project Zomboid", 16261, Protocol::Valve(SteamApp::PZ)),
"przomboid" => game!("Project Zomboid", 16261, Protocol::Valve(SteamApp::PRZOMBOID)),
"quake1" => game!("Quake 1", 27500, Protocol::Quake(QuakeVersion::One)),
"quake2" => game!("Quake 2", 27910, Protocol::Quake(QuakeVersion::Two)),
"quake3a" => game!("Quake 3: Arena", 27960, Protocol::Quake(QuakeVersion::Three)),
"quake3" => game!("Quake 3: Arena", 27960, Protocol::Quake(QuakeVersion::Three)),
"ror2" => game!("Risk of Rain 2", 27016, Protocol::Valve(SteamApp::ROR2)),
"rust" => game!("Rust", 27015, Protocol::Valve(SteamApp::RUST)),
"sc" => game!("Sven Co-op", 27015, Protocol::Valve(SteamApp::SC)),
"sdtd" => game!("7 Days To Die", 26900, Protocol::Valve(SteamApp::SDTD)),
"svencoop" => game!("Sven Co-op", 27015, Protocol::Valve(SteamApp::SVEENCOOP)),
"7d2d" => game!("7 Days To Die", 26900, Protocol::Valve(SteamApp::SD2D)),
"sof2" => game!("Soldier of Fortune 2", 20100, Protocol::Quake(QuakeVersion::Three)),
"ss" => game!("Serious Sam", 25601, Protocol::Gamespy(GameSpyVersion::One)),
"tf" => game!("The Forest", 27016, Protocol::Valve(SteamApp::TF)),
"theforest" => game!("The Forest", 27016, Protocol::Valve(SteamApp::THEFOREST)),
"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::PROPRIETARY(ProprietaryProtocol::TheShip)),
"ship" => 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)),
"vrising" => game!("V Rising", 27016, Protocol::Valve(SteamApp::VRISING)),
"jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2MP)),
"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
"mc", // 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}");
}
}
}
}
}
}

View file

@ -7,7 +7,7 @@ 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::GM.as_engine(),
SteamApp::GARRYSMOD.as_engine(),
None,
None,
)?;

View file

@ -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::INS.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -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::INSMIC.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

16
src/games/insurgency.rs Normal file
View file

@ -0,0 +1,16 @@
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))
}

View file

@ -0,0 +1,16 @@
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::INSURGENCYMIC.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -7,7 +7,7 @@ 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::INSS.as_engine(),
SteamApp::INSURGENCYSANDSTORM.as_engine(),
None,
None,
)?;

View file

@ -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::L4D.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -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::L4D2.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -7,7 +7,7 @@ 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(),
SteamApp::LEFT4DEAD.as_engine(),
None,
None,
)?;

16
src/games/left4dead2.rs Normal file
View file

@ -0,0 +1,16 @@
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))
}

View file

@ -3,34 +3,36 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Alien Swarm
pub mod aliens;
/// Age of Chivalry
pub mod aoc;
pub mod ageofchivalry;
/// Alien Swarm
pub mod alienswarm;
/// ARK: Survival Evolved
pub mod arkse;
/// ARMA 2: Operation Arrowhead
pub mod arma2oa;
/// ARK: Survival Evolved
pub mod ase;
/// Alien Swarm: Reactive Drop
pub mod asrd;
/// Avorion
pub mod avorion;
/// Ballistic Overkill
pub mod ballisticoverkill;
/// Battalion 1944
pub mod bat1944;
/// BrainBread 2
pub mod bb2;
/// Battlefield 1942
pub mod bf1942;
/// Black Mesa
pub mod bm;
/// Ballistic Overkill
pub mod bo;
pub mod blackmesa;
/// BrainBread 2
pub mod brainbread2;
/// Codename CURE
pub mod ccure;
pub mod codenamecure;
/// Colony Survival
pub mod cosu;
pub mod colonysurvival;
/// Creativerse
pub mod creativerse;
/// Crysis Wars
pub mod crysiswars;
/// Counter-Strike
pub mod cs;
/// Counter Strike: Condition Zero
@ -39,8 +41,6 @@ pub mod cscz;
pub mod csgo;
/// Counter-Strike: Source
pub mod css;
/// Crysis Wars
pub mod cw;
/// Day of Defeat
pub mod dod;
/// Day of Defeat: Source
@ -52,7 +52,7 @@ pub mod dst;
/// Frontlines: Fuel of War
pub mod ffow;
/// Garry's Mod
pub mod gm;
pub mod garrysmod;
/// Halo: Combat Evolved
pub mod haloce;
/// Half-Life 2 Deathmatch
@ -62,17 +62,17 @@ pub mod hldms;
/// Hell Let Loose
pub mod hll;
/// Insurgency
pub mod ins;
pub mod insurgency;
/// Insurgency: Modern Infantry Combat
pub mod insmic;
pub mod insurgencymic;
/// Insurgency: Sandstorm
pub mod inss;
pub mod insurgencysandstorm;
/// Just Cause 2: Multiplayer
pub mod jc2mp;
/// Left 4 Dead
pub mod l4d;
pub mod left4dead;
/// Left 4 Dead 2
pub mod l4d2;
pub mod left4dead2;
/// Minecraft
pub mod mc;
/// Operation: Harsh Doorstop
@ -80,39 +80,39 @@ pub mod ohd;
/// Onset
pub mod onset;
/// Project Zomboid
pub mod pz;
pub mod przomboid;
/// Quake 1
pub mod quake1;
/// Quake 2
pub mod quake2;
/// Quake 3: Arena
pub mod quake3a;
pub mod quake3;
/// Risk of Rain 2
pub mod ror2;
/// Rust
pub mod rust;
/// Sven Co-op
pub mod sc;
/// 7 Days To Die
pub mod sdtd;
pub mod sd2d;
/// The Ship
pub mod ship;
/// Soldier of Fortune 2
pub mod sof2;
/// Serious Sam
pub mod ss;
/// The Forest
pub mod tf;
/// Sven Co-op
pub mod svencoop;
/// Team Fortress 2
pub mod tf2;
/// Team Fortress Classic
pub mod tfc;
/// The Ship
pub mod ts;
/// The Forest
pub mod theforest;
/// Unturned
pub mod unturned;
/// Unreal Tournament
pub mod ut;
/// V Rising
pub mod vr;
pub mod vrising;
/// Warsow
pub mod warsow;
@ -222,7 +222,7 @@ pub fn query_with_timeout_and_extra_settings(
Protocol::PROPRIETARY(protocol) => {
match protocol {
ProprietaryProtocol::TheShip => {
ts::query_with_timeout(address, port, timeout_settings).map(Box::new)?
ship::query_with_timeout(address, port, timeout_settings).map(Box::new)?
}
ProprietaryProtocol::FFOW => ffow::query_with_timeout(address, port, timeout_settings).map(Box::new)?,
ProprietaryProtocol::JC2MP => {

View file

@ -7,7 +7,7 @@ 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::PZ.as_engine(),
SteamApp::PRZOMBOID.as_engine(),
None,
None,
)?;

View file

@ -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::SC.as_engine(),
None,
None,
)?;
Ok(game::Response::new_from_valve_response(valve_response))
}

View file

@ -7,7 +7,7 @@ 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::SDTD.as_engine(),
SteamApp::SD2D.as_engine(),
None,
None,
)?;

View file

@ -136,7 +136,7 @@ pub fn query_with_timeout(
) -> GDResult<Response> {
let valve_response = valve::query(
&SocketAddr::new(*address, port.unwrap_or(27015)),
SteamApp::TS.as_engine(),
SteamApp::SHIP.as_engine(),
None,
timeout_settings,
)?;

View file

@ -7,7 +7,7 @@ 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(),
SteamApp::SVEENCOOP.as_engine(),
None,
None,
)?;

View file

@ -7,7 +7,7 @@ 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::TF.as_engine(),
SteamApp::THEFOREST.as_engine(),
None,
None,
)?;

View file

@ -7,7 +7,7 @@ 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::BO.as_engine(),
SteamApp::VRISING.as_engine(),
None,
None,
)?;

View file

@ -36,7 +36,7 @@ pub enum GenericResponse<'a> {
Quake(quake::VersionedResponse<'a>),
Valve(&'a valve::Response),
#[cfg(feature = "games")]
TheShip(&'a crate::games::ts::Response),
TheShip(&'a crate::games::ship::Response),
#[cfg(feature = "games")]
FFOW(&'a crate::games::ffow::Response),
#[cfg(feature = "games")]
@ -52,7 +52,7 @@ pub enum GenericPlayer<'a> {
Minecraft(&'a minecraft::Player),
Gamespy(gamespy::VersionedPlayer<'a>),
#[cfg(feature = "games")]
TheShip(&'a crate::games::ts::TheShipPlayer),
TheShip(&'a crate::games::ship::TheShipPlayer),
#[cfg(feature = "games")]
JCMP2(&'a crate::games::jc2mp::Player),
}

View file

@ -282,7 +282,7 @@ impl ValveProtocol {
let environment_type = Environment::from_gldsrc(buffer.read()?)?;
let has_password = buffer.read::<u8>()? == 1;
let vac_secured = buffer.read::<u8>()? == 1;
let the_ship = match *engine == SteamApp::TS.as_engine() {
let the_ship = match *engine == SteamApp::SHIP.as_engine() {
false => None,
true => {
Some(TheShip {
@ -367,11 +367,11 @@ impl ValveProtocol {
name: buffer.read_string::<Utf8Decoder>(None)?,
score: buffer.read()?,
duration: buffer.read()?,
deaths: match *engine == SteamApp::TS.as_engine() {
deaths: match *engine == SteamApp::SHIP.as_engine() {
false => None,
true => Some(buffer.read()?),
},
money: match *engine == SteamApp::TS.as_engine() {
money: match *engine == SteamApp::SHIP.as_engine() {
false => None,
true => Some(buffer.read()?),
},

View file

@ -274,59 +274,59 @@ pub enum SteamApp {
/// Team Fortress 2
TF2,
/// Left 4 Dead
L4D,
LEFT4DEAD,
/// Left 4 Dead
L4D2,
LEFT4DEAD2,
/// Alien Swarm
ALIENS,
ALIENSWARM,
/// Counter-Strike: Global Offensive
CSGO,
/// The Ship
TS,
SHIP,
/// Garry's Mod
GM,
GARRYSMOD,
/// Age of Chivalry
AOC,
AGEOFCHIVALRY,
/// Insurgency: Modern Infantry Combat
INSMIC,
INSURGENCYMIC,
/// ARMA 2: Operation Arrowhead
ARMA2OA,
/// Project Zomboid
PZ,
PRZOMBOID,
/// Insurgency
INS,
INSURGENCY,
/// Sven Co-op
SC,
SVEENCOOP,
/// 7 Days To Die
SDTD,
SD2D,
/// Rust
RUST,
/// Vallistic Overkill
BO,
BALLISTICOVERKILL,
/// Don't Starve Together
DST,
/// BrainBread 2
BB2,
BRAINBREAD2,
/// Codename CURE
CCURE,
CODENAMECURE,
/// Black Mesa
BM,
BLACKMESA,
/// Colony Survival
COSU,
COLONYSURVIVAL,
/// Avorion
AVORION,
/// Day of Infamy
DOI,
/// The Forest
TF,
THEFOREST,
/// Unturned
UNTURNED,
/// ARK: Survival Evolved
ASE,
ARKSE,
/// Battalion 1944
BAT1944,
/// Insurgency: Sandstorm
INSS,
INSURGENCYSANDSTORM,
/// Alien Swarm: Reactive Drop
ASRD,
/// Risk of Rain 2
@ -336,7 +336,7 @@ pub enum SteamApp {
/// Onset
ONSET,
/// V Rising
VR,
VRISING,
/// Hell Let Loose
HLL,
}
@ -350,38 +350,38 @@ impl SteamApp {
Self::HL2DM => Engine::new_source(320),
Self::HLDMS => Engine::new_source(360),
Self::TF2 => Engine::new_source(440),
Self::L4D => Engine::new_source(500),
Self::L4D2 => Engine::new_source(550),
Self::ALIENS => Engine::new_source(630),
Self::LEFT4DEAD => Engine::new_source(500),
Self::LEFT4DEAD2 => Engine::new_source(550),
Self::ALIENSWARM => Engine::new_source(630),
Self::CSGO => Engine::new_source(730),
Self::TS => Engine::new_source(2400),
Self::GM => Engine::new_source(4000),
Self::AOC => Engine::new_source(17510),
Self::INSMIC => Engine::new_source(17700),
Self::SHIP => Engine::new_source(2400),
Self::GARRYSMOD => Engine::new_source(4000),
Self::AGEOFCHIVALRY => Engine::new_source(17510),
Self::INSURGENCYMIC => Engine::new_source(17700),
Self::ARMA2OA => Engine::new_source(33930),
Self::PZ => Engine::new_source(108_600),
Self::INS => Engine::new_source(222_880),
Self::SDTD => Engine::new_source(251_570),
Self::PRZOMBOID => Engine::new_source(108_600),
Self::INSURGENCY => Engine::new_source(222_880),
Self::SD2D => 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::BALLISTICOVERKILL => Engine::new_source(296_300),
Self::DST => Engine::new_source(322_320),
Self::BB2 => Engine::new_source(346_330),
Self::CCURE => Engine::new_source(355_180),
Self::BM => Engine::new_source(362_890),
Self::COSU => Engine::new_source(366_090),
Self::BRAINBREAD2 => Engine::new_source(346_330),
Self::CODENAMECURE => Engine::new_source(355_180),
Self::BLACKMESA => Engine::new_source(362_890),
Self::COLONYSURVIVAL => Engine::new_source(366_090),
Self::AVORION => Engine::new_source(445_220),
Self::DOI => Engine::new_source(447_820),
Self::TF => Engine::new_source(556_450),
Self::THEFOREST => Engine::new_source(556_450),
Self::UNTURNED => Engine::new_source(304_930),
Self::ASE => Engine::new_source(346_110),
Self::ARKSE => Engine::new_source(346_110),
Self::BAT1944 => Engine::new_source(489_940),
Self::INSS => Engine::new_source(581_320),
Self::INSURGENCYSANDSTORM => Engine::new_source(581_320),
Self::ASRD => Engine::new_source(563_560),
Self::ROR2 => Engine::new_source(632_360),
Self::OHD => Engine::new_source_with_dedicated(736_590, 950_900),
Self::ONSET => Engine::new_source(1_105_810),
Self::VR => Engine::new_source(1_604_030),
Self::VRISING => Engine::new_source(1_604_030),
Self::HLL => Engine::new_source(686_810),
_ => Engine::GoldSrc(false), // CS - 10, TFC - 20, DOD - 30, CSCZ - 80, SC - 225840
}