Skip to content

Commit

Permalink
[Game] Apply new id naming (#114)
Browse files Browse the repository at this point in the history
* Apply new id naming

* Fix failing CI on all features

* Update changelog

* Rename tf2 example to teamfortress2

* Fix typo in steamapp game names

* Rename minecraft legacy versions

* Apply CI node badge fix by Douile

* Add/Update badge

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
CosminPerRam and actions-user authored Oct 6, 2023
1 parent b4c6178 commit 5280ecb
Show file tree
Hide file tree
Showing 38 changed files with 231 additions and 232 deletions.
8 changes: 4 additions & 4 deletions .github/badges/node.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ Generics:
- Changed `score` type (and the function) of player from `u32` to `i32`.

Games:
- Renamed game definitions to better match node-gamedig (subject to change again in the next release). (by @Douile)
- Renamed game implementations to match new definition names. (by @Douile)
- Rename some game definitions and implementations to follow a stable ID naming system.

Protocols:
- Valve:
Expand Down Expand Up @@ -64,6 +63,8 @@ reported by the server are the same, errors if not, enabled by default. (by @Dou
3. Renamed `players_sample` to `players`.
4. Added an optional parameter, `RequestSettings`, which contains fields that are used when creating the handshake
packet (this solves some servers not responding to the query). (by @Douile)
5. Legacy versions naming has been changed to represent up to what version they can query, `LegacyBV1_8` (Beta 1.8 to
1.3) -> `LegacyV1_3` and `LegacyV1_4` (1.4 to 1.5) -> `LegacyV1_5` (and their enums accordingly).

- Minecraft Bedrock
1. Renamed `version_protocol` to `protocol_version`.
Expand Down
112 changes: 56 additions & 56 deletions GAMES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Pick a game/service/protocol (check the [GAMES](GAMES.md), [SERVICES](SERVICES.m

[Team Fortress 2](https://store.steampowered.com/app/440/Team_Fortress_2/) query example:
```rust
use gamedig::games::tf2;
use gamedig::games::teamfortress2;

fn main() {
let response = tf2::query(&"127.0.0.1".parse().unwrap(), None);
let response = teamfortress2::query(&"127.0.0.1".parse().unwrap(), None);
// None is the default port (which is 27015), could also be Some(27015)

match response { // Result type, must check what it is...
Expand Down
4 changes: 2 additions & 2 deletions examples/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ mod test {
}

#[test]
fn battlefield() { test_game("bf1942"); }
fn battlefield1942() { test_game("battlefield1942"); }

#[test]
fn minecraft() { test_game("minecraft"); }

#[test]
fn tf2() { test_game("tf2"); }
fn teamfortress2() { test_game("teamfortress2"); }

#[test]
fn quake() { test_game("quake3"); }
Expand Down
6 changes: 3 additions & 3 deletions examples/minecraft.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use gamedig::games::mc;
use gamedig::games::minecraft;
use gamedig::protocols::minecraft::RequestSettings;

fn main() {
// or Some(<port>), None is the default protocol port (which is 25565 for java
// and 19132 for bedrock)
let response = mc::query(&"127.0.0.1".parse().unwrap(), None);
let response = minecraft::query(&"127.0.0.1".parse().unwrap(), None);
// This will fail if no server is available locally!

match response {
Expand All @@ -15,7 +15,7 @@ fn main() {
// This is an example to query a server with a hostname to be specified in the
// packet. Passing -1 on the protocol_version means anything, note that
// an invalid value here might result in server not responding.
let response = mc::query_java(
let response = minecraft::query_java(
&"209.222.114.62".parse().unwrap(),
Some(25565),
Some(RequestSettings {
Expand Down
4 changes: 2 additions & 2 deletions examples/tf2.rs → examples/teamfortress2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use gamedig::games::tf2;
use gamedig::games::teamfortress2;

fn main() {
let response = tf2::query(&"127.0.0.1".parse().unwrap(), None);
let response = teamfortress2::query(&"127.0.0.1".parse().unwrap(), None);
// or Some(27015), None is the default protocol port (which is 27015)

match response {
Expand Down
2 changes: 1 addition & 1 deletion src/games/arma2oa.rs → src/games/a2oa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(2304)),
SteamApp::ARMA2OA.as_engine(),
SteamApp::A2OA.as_engine(),
None,
None,
)?;
Expand Down
2 changes: 1 addition & 1 deletion src/games/cs.rs → src/games/aoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::CS.as_engine(),
SteamApp::AOC.as_engine(),
None,
None,
)?;
Expand Down
2 changes: 1 addition & 1 deletion src/games/tf2.rs → src/games/ase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::TF2.as_engine(),
SteamApp::ASE.as_engine(),
None,
None,
)?;
Expand Down
2 changes: 1 addition & 1 deletion src/games/bat1944.rs → src/games/battalion1944.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::net::{IpAddr, SocketAddr};
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<game::Response> {
let mut valve_response = valve::query(
&SocketAddr::new(*address, port.unwrap_or(7780)),
SteamApp::BAT1944.as_engine(),
SteamApp::BATTALION1944.as_engine(),
None,
None,
)?;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/games/ageofchivalry.rs → src/games/counterstrike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::AGEOFCHIVALRY.as_engine(),
SteamApp::COUNTERSTRIKE.as_engine(),
None,
None,
)?;
Expand Down
46 changes: 23 additions & 23 deletions src/games/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
"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))),
"minecraftbedrock" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"minecraftpocket" => 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)))),
"minecraftlegacy16" => game!("Minecraft (legacy v1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))),
"minecraftlegacy15" => game!("Minecraft (legacy v1.4-1.5)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_5)))),
"minecraftlegacy13" => game!("Minecraft (legacy vB1.8-1.3)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_3)))),
"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)),
"arkse" => game!("ARK: Survival Evolved", 27015, Protocol::Valve(SteamApp::ARKSE)),
"aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(SteamApp::AOC)),
"a2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(SteamApp::A2OA)),
"ase" => game!("ARK: Survival Evolved", 27015, Protocol::Valve(SteamApp::ASE)),
"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)),
"battalion1944" => game!("Battalion 1944", 7780, Protocol::Valve(SteamApp::BATTALION1944)),
"brainbread2" => game!("BrainBread 2", 27015, Protocol::Valve(SteamApp::BRAINBREAD2)),
"bf1942" => game!("Battlefield 1942", 23000, Protocol::Gamespy(GameSpyVersion::One)),
"battlefield1942" => game!("Battlefield 1942", 23000, Protocol::Gamespy(GameSpyVersion::One)),
"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)),
"counterstrike" => game!("Counter-Strike", 27015, Protocol::Valve(SteamApp::COUNTERSTRIKE)),
"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)),
Expand All @@ -59,35 +59,35 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
"dst" => game!("Don't Starve Together", 27016, Protocol::Valve(SteamApp::DST)),
"ffow" => game!("Frontlines: Fuel of War", 5478, Protocol::PROPRIETARY(ProprietaryProtocol::FFOW)),
"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)),
"hl2d" => game!("Half-Life 2 Deathmatch", 27015, Protocol::Valve(SteamApp::HL2D)),
"hce" => game!("Halo: Combat Evolved", 2302, Protocol::Gamespy(GameSpyVersion::Two)),
"hlds" => game!("Half-Life Deathmatch: Source", 27015, Protocol::Valve(SteamApp::HLDS)),
"hll" => game!("Hell Let Loose", 26420, Protocol::Valve(SteamApp::HLL)),
"insurgency" => game!("Insurgency", 27015, Protocol::Valve(SteamApp::INSURGENCY)),
"insurgencymic" => game!("Insurgency: Modern Infantry Combat", 27015, Protocol::Valve(SteamApp::INSURGENCYMIC)),
"imic" => game!("Insurgency: Modern Infantry Combat", 27015, Protocol::Valve(SteamApp::IMIC)),
"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)),
"przomboid" => game!("Project Zomboid", 16261, Protocol::Valve(SteamApp::PRZOMBOID)),
"projectzomboid" => game!("Project Zomboid", 16261, Protocol::Valve(SteamApp::PROJECTZOMBOID)),
"quake1" => game!("Quake 1", 27500, Protocol::Quake(QuakeVersion::One)),
"quake2" => game!("Quake 2", 27910, Protocol::Quake(QuakeVersion::Two)),
"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)),
"svencoop" => game!("Sven Co-op", 27015, Protocol::Valve(SteamApp::SVEENCOOP)),
"sco" => game!("Sven Co-op", 27015, Protocol::Valve(SteamApp::SCO)),
"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)),
"serioussam" => game!("Serious Sam", 25601, Protocol::Gamespy(GameSpyVersion::One)),
"theforest" => game!("The Forest", 27016, Protocol::Valve(SteamApp::THEFOREST)),
"tf2" => game!("Team Fortress 2", 27015, Protocol::Valve(SteamApp::TF2)),
"teamfortress2" => game!("Team Fortress 2", 27015, Protocol::Valve(SteamApp::TEAMFORTRESS2)),
"tfc" => game!("Team Fortress Classic", 27015, Protocol::Valve(SteamApp::TFC)),
"ship" => game!("The Ship", 27015, Protocol::PROPRIETARY(ProprietaryProtocol::TheShip)),
"theship" => 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)),
"unrealtournament" => game!("Unreal Tournament", 7778, Protocol::Gamespy(GameSpyVersion::One)),
"vrising" => game!("V Rising", 27016, Protocol::Valve(SteamApp::VRISING)),
"jc2mp" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2MP)),
"jc2m" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2M)),
"warsow" => game!("Warsow", 44400, Protocol::Quake(QuakeVersion::Three)),
};

Expand All @@ -101,7 +101,7 @@ mod test {
let ignore = [
"mod", // Module file
"definitions", // This file
"mc", // Has various defs
"minecraft", // Has various defs
"sd2d", // Module names cannot start with numbers
];

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/games/arkse.rs → src/games/hl2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::ARKSE.as_engine(),
SteamApp::HL2D.as_engine(),
None,
None,
)?;
Expand Down
16 changes: 0 additions & 16 deletions src/games/hldms.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/games/hl2dm.rs → src/games/hlds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::HL2DM.as_engine(),
SteamApp::HLDS.as_engine(),
None,
None,
)?;
Expand Down
16 changes: 16 additions & 0 deletions src/games/imic.rs
Original file line number Diff line number Diff line change
@@ -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::IMIC.as_engine(),
None,
None,
)?;

Ok(game::Response::new_from_valve_response(valve_response))
}
16 changes: 0 additions & 16 deletions src/games/insurgencymic.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/games/jc2mp.rs → src/games/jc2m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct Response {
}

impl CommonResponse for Response {
fn as_original(&self) -> GenericResponse { GenericResponse::JC2MP(self) }
fn as_original(&self) -> GenericResponse { GenericResponse::JC2M(self) }

fn game_version(&self) -> Option<&str> { Some(&self.game_version) }
fn description(&self) -> Option<&str> { Some(&self.description) }
Expand Down
File renamed without changes.
Loading

0 comments on commit 5280ecb

Please sign in to comment.