[Game] Apply new id naming (#114)

* 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 <action@github.com>
This commit is contained in:
CosminPerRam 2023-10-06 17:20:30 +03:00 committed by GitHub
parent b4c61781fb
commit 5280ecb3c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 231 additions and 232 deletions

View file

@ -14,12 +14,12 @@ use std::net::SocketAddr;
use byteorder::BigEndian;
pub struct LegacyBV1_8 {
pub struct LegacyV1_3 {
socket: TcpSocket,
retry_count: usize,
}
impl LegacyBV1_8 {
impl LegacyV1_3 {
fn new(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = TcpSocket::new(address)?;
socket.apply_timeout(&timeout_settings)?;
@ -72,7 +72,7 @@ impl LegacyBV1_8 {
favicon: None,
previews_chat: None,
enforces_secure_chat: None,
server_type: Server::Legacy(LegacyGroup::VB1_8),
server_type: Server::Legacy(LegacyGroup::V1_3),
})
}

View file

@ -13,12 +13,12 @@ use crate::{
};
use std::net::SocketAddr;
pub struct LegacyV1_4 {
pub struct LegacyV1_5 {
socket: TcpSocket,
retry_count: usize,
}
impl LegacyV1_4 {
impl LegacyV1_5 {
fn new(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = TcpSocket::new(address)?;
socket.apply_timeout(&timeout_settings)?;
@ -75,7 +75,7 @@ impl LegacyV1_4 {
favicon: None,
previews_chat: None,
enforces_secure_chat: None,
server_type: Server::Legacy(LegacyGroup::V1_4),
server_type: Server::Legacy(LegacyGroup::V1_5),
})
}

View file

@ -4,8 +4,8 @@ use crate::{
protocol::{
bedrock::Bedrock,
java::Java,
legacy_bv1_8::LegacyBV1_8,
legacy_v1_4::LegacyV1_4,
legacy_v1_3::LegacyV1_3,
legacy_v1_5::LegacyV1_5,
legacy_v1_6::LegacyV1_6,
},
BedrockResponse,
@ -20,8 +20,8 @@ use std::net::SocketAddr;
mod bedrock;
mod java;
mod legacy_bv1_8;
mod legacy_v1_4;
mod legacy_v1_3;
mod legacy_v1_5;
mod legacy_v1_6;
/// Queries a Minecraft server with all the protocol variants one by one (Java
@ -61,11 +61,11 @@ pub fn query_legacy(address: &SocketAddr, timeout_settings: Option<TimeoutSettin
return Ok(response);
}
if let Ok(response) = query_legacy_specific(LegacyGroup::V1_4, address, timeout_settings.clone()) {
if let Ok(response) = query_legacy_specific(LegacyGroup::V1_5, address, timeout_settings.clone()) {
return Ok(response);
}
if let Ok(response) = query_legacy_specific(LegacyGroup::VB1_8, address, timeout_settings) {
if let Ok(response) = query_legacy_specific(LegacyGroup::V1_3, address, timeout_settings) {
return Ok(response);
}
@ -80,8 +80,8 @@ pub fn query_legacy_specific(
) -> GDResult<JavaResponse> {
match group {
LegacyGroup::V1_6 => LegacyV1_6::query(address, timeout_settings),
LegacyGroup::V1_4 => LegacyV1_4::query(address, timeout_settings),
LegacyGroup::VB1_8 => LegacyBV1_8::query(address, timeout_settings),
LegacyGroup::V1_5 => LegacyV1_5::query(address, timeout_settings),
LegacyGroup::V1_3 => LegacyV1_3::query(address, timeout_settings),
}
}

View file

@ -35,9 +35,9 @@ pub enum LegacyGroup {
/// 1.6
V1_6,
/// 1.4 - 1.5
V1_4,
V1_5,
/// Beta 1.8 - 1.3
VB1_8,
V1_3,
}
/// Information about a player.

View file

@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
pub enum ProprietaryProtocol {
TheShip,
FFOW,
JC2MP,
JC2M,
}
/// Enumeration of all valid protocol types
@ -36,11 +36,11 @@ pub enum GenericResponse<'a> {
Quake(quake::VersionedResponse<'a>),
Valve(&'a valve::Response),
#[cfg(feature = "games")]
TheShip(&'a crate::games::ship::Response),
TheShip(&'a crate::games::theship::Response),
#[cfg(feature = "games")]
FFOW(&'a crate::games::ffow::Response),
#[cfg(feature = "games")]
JC2MP(&'a crate::games::jc2mp::Response),
JC2M(&'a crate::games::jc2m::Response),
}
/// All player types
@ -52,9 +52,9 @@ pub enum GenericPlayer<'a> {
Minecraft(&'a minecraft::Player),
Gamespy(gamespy::VersionedPlayer<'a>),
#[cfg(feature = "games")]
TheShip(&'a crate::games::ship::TheShipPlayer),
TheShip(&'a crate::games::theship::TheShipPlayer),
#[cfg(feature = "games")]
JCMP2(&'a crate::games::jc2mp::Player),
JCMP2(&'a crate::games::jc2m::Player),
}
pub trait CommonResponse {

View file

@ -304,7 +304,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::SHIP.as_engine() {
let the_ship = match *engine == SteamApp::THESHIP.as_engine() {
false => None,
true => {
Some(TheShip {
@ -389,11 +389,11 @@ impl ValveProtocol {
name: buffer.read_string::<Utf8Decoder>(None)?,
score: buffer.read()?,
duration: buffer.read()?,
deaths: match *engine == SteamApp::SHIP.as_engine() {
deaths: match *engine == SteamApp::THESHIP.as_engine() {
false => None,
true => Some(buffer.read()?),
},
money: match *engine == SteamApp::SHIP.as_engine() {
money: match *engine == SteamApp::THESHIP.as_engine() {
false => None,
true => Some(buffer.read()?),
},

View file

@ -254,7 +254,7 @@ impl Request {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum SteamApp {
/// Counter-Strike
CS,
COUNTERSTRIKE,
/// Creativerse
CREATIVERSE,
/// Team Fortress Classic
@ -268,11 +268,11 @@ pub enum SteamApp {
/// Day of Defeat: Source
DODS,
/// Half-Life 2 Deathmatch
HL2DM,
HL2D,
/// Half-Life Deathmatch: Source
HLDMS,
HLDS,
/// Team Fortress 2
TF2,
TEAMFORTRESS2,
/// Left 4 Dead
LEFT4DEAD,
/// Left 4 Dead
@ -282,26 +282,26 @@ pub enum SteamApp {
/// Counter-Strike: Global Offensive
CSGO,
/// The Ship
SHIP,
THESHIP,
/// Garry's Mod
GARRYSMOD,
/// Age of Chivalry
AGEOFCHIVALRY,
AOC,
/// Insurgency: Modern Infantry Combat
INSURGENCYMIC,
IMIC,
/// ARMA 2: Operation Arrowhead
ARMA2OA,
A2OA,
/// Project Zomboid
PRZOMBOID,
PROJECTZOMBOID,
/// Insurgency
INSURGENCY,
/// Sven Co-op
SVEENCOOP,
SCO,
/// 7 Days To Die
SD2D,
/// Rust
RUST,
/// Vallistic Overkill
/// Ballistic Overkill
BALLISTICOVERKILL,
/// Don't Starve Together
DST,
@ -322,9 +322,9 @@ pub enum SteamApp {
/// Unturned
UNTURNED,
/// ARK: Survival Evolved
ARKSE,
ASE,
/// Battalion 1944
BAT1944,
BATTALION1944,
/// Insurgency: Sandstorm
INSURGENCYSANDSTORM,
/// Alien Swarm: Reactive Drop
@ -347,19 +347,19 @@ impl SteamApp {
match self {
Self::CSS => Engine::new_source(240),
Self::DODS => Engine::new_source(300),
Self::HL2DM => Engine::new_source(320),
Self::HLDMS => Engine::new_source(360),
Self::TF2 => Engine::new_source(440),
Self::HL2D => Engine::new_source(320),
Self::HLDS => Engine::new_source(360),
Self::TEAMFORTRESS2 => Engine::new_source(440),
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::SHIP => Engine::new_source(2400),
Self::THESHIP => 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::PRZOMBOID => Engine::new_source(108_600),
Self::AOC => Engine::new_source(17510),
Self::IMIC => Engine::new_source(17700),
Self::A2OA => Engine::new_source(33930),
Self::PROJECTZOMBOID => 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),
@ -374,8 +374,8 @@ impl SteamApp {
Self::DOI => Engine::new_source(447_820),
Self::THEFOREST => Engine::new_source(556_450),
Self::UNTURNED => Engine::new_source(304_930),
Self::ARKSE => Engine::new_source(346_110),
Self::BAT1944 => Engine::new_source(489_940),
Self::ASE => Engine::new_source(346_110),
Self::BATTALION1944 => Engine::new_source(489_940),
Self::INSURGENCYSANDSTORM => Engine::new_source(581_320),
Self::ASRD => Engine::new_source(563_560),
Self::ROR2 => Engine::new_source(632_360),