Enhance -p/--protocol-version to accept game version string
Now you can pass `-p 1.7.10` as an alternative to `-p 5`, etc
This commit is contained in:
parent
10e5d6f441
commit
1274a75f81
|
@ -178,7 +178,7 @@ struct Opt {
|
||||||
|
|
||||||
/// Protocol version to use in the autodetection ping
|
/// Protocol version to use in the autodetection ping
|
||||||
#[structopt(short = "p", long = "default-protocol-version")]
|
#[structopt(short = "p", long = "default-protocol-version")]
|
||||||
default_protocol_version: Option<i32>,
|
default_protocol_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
|
@ -260,6 +260,8 @@ pub fn main() {
|
||||||
|
|
||||||
let textures = renderer.get_textures();
|
let textures = renderer.get_textures();
|
||||||
let dpi_factor = window.get_current_monitor().get_hidpi_factor();
|
let dpi_factor = window.get_current_monitor().get_hidpi_factor();
|
||||||
|
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
|
||||||
|
opt.default_protocol_version.unwrap_or("".to_string()));
|
||||||
let mut game = Game {
|
let mut game = Game {
|
||||||
server: server::Server::dummy_server(resource_manager.clone()),
|
server: server::Server::dummy_server(resource_manager.clone()),
|
||||||
focused: false,
|
focused: false,
|
||||||
|
@ -277,7 +279,7 @@ pub fn main() {
|
||||||
last_mouse_xrel: 0.0,
|
last_mouse_xrel: 0.0,
|
||||||
last_mouse_yrel: 0.0,
|
last_mouse_yrel: 0.0,
|
||||||
is_fullscreen: false,
|
is_fullscreen: false,
|
||||||
default_protocol_version: opt.default_protocol_version.unwrap_or(protocol::SUPPORTED_PROTOCOLS[0]),
|
default_protocol_version,
|
||||||
};
|
};
|
||||||
game.renderer.camera.pos = cgmath::Point3::new(0.5, 13.2, 0.5);
|
game.renderer.camera.pos = cgmath::Point3::new(0.5, 13.2, 0.5);
|
||||||
|
|
||||||
|
|
|
@ -13,49 +13,50 @@ mod v15w39c;
|
||||||
mod v1_8_9;
|
mod v1_8_9;
|
||||||
mod v1_7_10;
|
mod v1_7_10;
|
||||||
|
|
||||||
pub fn translate_internal_packet_id_for_version(version: i32, state: State, dir: Direction, id: i32, to_internal: bool) -> i32 {
|
// https://wiki.vg/Protocol_History
|
||||||
match version {
|
// https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
|
||||||
// https://wiki.vg/Protocol_History
|
|
||||||
// https://wiki.vg/Protocol_version_numbers#Versions_after_the_Netty_rewrite
|
|
||||||
|
|
||||||
477 => v1_14::translate_internal_packet_id(state, dir, id, to_internal),
|
pub fn protocol_name_to_protocol_version(s: String) -> i32 {
|
||||||
|
match s.as_ref() {
|
||||||
// 19w02a
|
"" => SUPPORTED_PROTOCOLS[0],
|
||||||
452 => v19w02a::translate_internal_packet_id(state, dir, id, to_internal),
|
"1.14" => 477,
|
||||||
|
"19w02a" => 452,
|
||||||
// 18w50a
|
"18w50a" => 451,
|
||||||
451 => v18w50a::translate_internal_packet_id(state, dir, id, to_internal),
|
"1.13.2" => 404,
|
||||||
|
"1.12.2" => 340,
|
||||||
// 1.13.2
|
"1.11.2" => 316,
|
||||||
404 => v1_13_2::translate_internal_packet_id(state, dir, id, to_internal),
|
"1.11" => 315,
|
||||||
|
"1.10.2" => 210,
|
||||||
// 1.12.2
|
"1.9.2" => 109,
|
||||||
340 => v1_12_2::translate_internal_packet_id(state, dir, id, to_internal),
|
"1.9" => 107,
|
||||||
|
"15w39c" => 74,
|
||||||
// 1.11.2
|
"1.8.9" => 47,
|
||||||
316 => v1_11_2::translate_internal_packet_id(state, dir, id, to_internal),
|
"1.7.10" => 5,
|
||||||
|
_ => {
|
||||||
// 1.11
|
if let Ok(n) = s.parse::<i32>() {
|
||||||
315 => v1_11_2::translate_internal_packet_id(state, dir, id, to_internal),
|
n
|
||||||
|
} else {
|
||||||
// 1.10.2
|
panic!("Unrecognized protocol name: {}", s)
|
||||||
210 => v1_10_2::translate_internal_packet_id(state, dir, id, to_internal),
|
}
|
||||||
|
}
|
||||||
// 1.9.2
|
}
|
||||||
109 => v1_9_2::translate_internal_packet_id(state, dir, id, to_internal),
|
}
|
||||||
|
|
||||||
// 1.9
|
pub fn translate_internal_packet_id_for_version(version: i32, state: State, dir: Direction, id: i32, to_internal: bool) -> i32 {
|
||||||
107 => v1_9::translate_internal_packet_id(state, dir, id, to_internal),
|
match version {
|
||||||
|
477 => v1_14::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
// 15w39a/b/c
|
452 => v19w02a::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
74 => v15w39c::translate_internal_packet_id(state, dir, id, to_internal),
|
451 => v18w50a::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
404 => v1_13_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
// 1.8.9 - 1.8
|
340 => v1_12_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
47 => v1_8_9::translate_internal_packet_id(state, dir, id, to_internal),
|
316 => v1_11_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
315 => v1_11_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
// 1.7.10 - 1.7.6
|
210 => v1_10_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
5 => v1_7_10::translate_internal_packet_id(state, dir, id, to_internal),
|
109 => v1_9_2::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
107 => v1_9::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
_ => panic!("unsupported protocol version"),
|
74 => v15w39c::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
47 => v1_8_9::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
5 => v1_7_10::translate_internal_packet_id(state, dir, id, to_internal),
|
||||||
|
_ => panic!("unsupported protocol version: {}", version),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue