Skip to content

Commit

Permalink
fix: minecraft id naming inconsistencies (#152)
Browse files Browse the repository at this point in the history
* fix: minecraft id naming inconsistencies

* fix: minecraft legacy beta 1.8 being wrongly id named in definitions

* docs: Update CHANGELOG to document minecraft legacy renames

* docs: Update CHANGELOG to note removal of legacy versions game names being prefixed with 'v'
  • Loading branch information
CosminPerRam authored Nov 16, 2023
1 parent 13f1c2b commit bd73b65
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Game:
- - Left 4 Dead: `left4dead` -> `l4d`.
- - 7 Days to Die: `7d2d` in definitions and `sd2d` in game declaration -> `sdtd`.
- - Quake 3 Arena: `quake3arena` -> `q3a`.
- Minecraft Legacy 1.5 and 1.3 were renamed to 1.4 and beta 1.8 respectively to show the lowest version they support, this change includes Structs, Enum and game id renames, also removed the "v" from the game definition name.

Protocols:
- Valve: Removed `SteamApp` due to it not being really useful at all, replaced all instances with `Engine`.
Expand Down
6 changes: 3 additions & 3 deletions crates/lib/src/games/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
"minecraftbedrock" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"minecraftpocket" => game!("Minecraft (pocket)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
"minecraftjava" => game!("Minecraft (java)", 25565, Protocol::Minecraft(Some(Server::Java))),
"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)))),
"minecraftlegacy16" => game!("Minecraft (legacy 1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))),
"minecraftlegacy14" => game!("Minecraft (legacy 1.4)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4)))),
"minecraftlegacyb18" => game!("Minecraft (legacy b1.8)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8)))),
"alienswarm" => game!("Alien Swarm", 27015, Protocol::Valve(Engine::new(630))),
"aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(Engine::new(17510))),
"a2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(Engine::new(33930))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use crate::{
};
use std::net::SocketAddr;

pub struct LegacyV1_5 {
pub struct LegacyV1_4 {
socket: TcpSocket,
retry_count: usize,
}

impl LegacyV1_5 {
impl LegacyV1_4 {
fn new(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = TcpSocket::new(address)?;
socket.apply_timeout(&timeout_settings)?;
Expand Down Expand Up @@ -75,7 +75,7 @@ impl LegacyV1_5 {
favicon: None,
previews_chat: None,
enforces_secure_chat: None,
server_type: Server::Legacy(LegacyGroup::V1_5),
server_type: Server::Legacy(LegacyGroup::V1_4),
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use std::net::SocketAddr;

use byteorder::BigEndian;

pub struct LegacyV1_3 {
pub struct LegacyVB1_8 {
socket: TcpSocket,
retry_count: usize,
}

impl LegacyV1_3 {
impl LegacyVB1_8 {
fn new(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = TcpSocket::new(address)?;
socket.apply_timeout(&timeout_settings)?;
Expand Down Expand Up @@ -72,7 +72,7 @@ impl LegacyV1_3 {
favicon: None,
previews_chat: None,
enforces_secure_chat: None,
server_type: Server::Legacy(LegacyGroup::V1_3),
server_type: Server::Legacy(LegacyGroup::VB1_8),
})
}

Expand Down
16 changes: 8 additions & 8 deletions crates/lib/src/protocols/minecraft/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::{
protocol::{
bedrock::Bedrock,
java::Java,
legacy_v1_3::LegacyV1_3,
legacy_v1_5::LegacyV1_5,
legacy_v1_4::LegacyV1_4,
legacy_v1_6::LegacyV1_6,
legacy_vb1_8::LegacyVB1_8,
},
BedrockResponse,
JavaResponse,
Expand All @@ -20,9 +20,9 @@ use std::net::SocketAddr;

mod bedrock;
mod java;
mod legacy_v1_3;
mod legacy_v1_5;
mod legacy_v1_4;
mod legacy_v1_6;
mod legacy_vb1_8;

/// Queries a Minecraft server with all the protocol variants one by one (Java
/// -> Bedrock -> Legacy (1.6 -> 1.4 -> Beta 1.8)).
Expand Down Expand Up @@ -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_5, address, timeout_settings) {
if let Ok(response) = query_legacy_specific(LegacyGroup::V1_4, address, timeout_settings) {
return Ok(response);
}

if let Ok(response) = query_legacy_specific(LegacyGroup::V1_3, address, timeout_settings) {
if let Ok(response) = query_legacy_specific(LegacyGroup::VB1_8, address, timeout_settings) {
return Ok(response);
}

Expand All @@ -80,8 +80,8 @@ pub fn query_legacy_specific(
) -> GDResult<JavaResponse> {
match group {
LegacyGroup::V1_6 => LegacyV1_6::query(address, timeout_settings),
LegacyGroup::V1_5 => LegacyV1_5::query(address, timeout_settings),
LegacyGroup::V1_3 => LegacyV1_3::query(address, timeout_settings),
LegacyGroup::V1_4 => LegacyV1_4::query(address, timeout_settings),
LegacyGroup::VB1_8 => LegacyVB1_8::query(address, timeout_settings),
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/protocols/minecraft/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub enum LegacyGroup {
/// 1.6
V1_6,
/// 1.4 - 1.5
V1_5,
V1_4,
/// Beta 1.8 - 1.3
V1_3,
VB1_8,
}

/// Information about a player.
Expand Down

0 comments on commit bd73b65

Please sign in to comment.