mirror of
https://github.com/timvisee/lazymc.git
synced 2025-05-19 12:50:23 -07:00
Fix protocol versions being handled incorrectly
This commit is contained in:
parent
51d3ecf148
commit
b8744aaf57
@ -335,7 +335,7 @@ async fn wait_for_server_join_game_no_timeout(
|
|||||||
Ok(Some(packet)) => packet,
|
Ok(Some(packet)) => packet,
|
||||||
Ok(None) => break,
|
Ok(None) => break,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
error!(target: "lazymc::lobby", "Closing connection, error occurred");
|
error!(target: "lazymc::probe", "Closing connection, error occurred");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -344,15 +344,15 @@ async fn wait_for_server_join_game_no_timeout(
|
|||||||
if packets::play::join_game::is_packet(client_info, packet.id) {
|
if packets::play::join_game::is_packet(client_info, packet.id) {
|
||||||
// Parse join game data
|
// Parse join game data
|
||||||
let join_game_data = JoinGameData::from_packet(client_info, packet).map_err(|err| {
|
let join_game_data = JoinGameData::from_packet(client_info, packet).map_err(|err| {
|
||||||
warn!(target: "lazymc::lobby", "Failed to parse join game packet: {:?}", err);
|
warn!(target: "lazymc::probe", "Failed to parse join game packet: {:?}", err);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
return Ok(join_game_data);
|
return Ok(join_game_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::lobby", "Got unhandled packet from server in wait_for_server_join_game:");
|
debug!(target: "lazymc::probe", "Got unhandled packet from server in wait_for_server_join_game:");
|
||||||
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::probe", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gracefully close connection
|
// Gracefully close connection
|
||||||
|
@ -33,7 +33,7 @@ impl JoinGameData {
|
|||||||
/// Extract join game data from given packet.
|
/// Extract join game data from given packet.
|
||||||
pub fn from_packet(client_info: &ClientInfo, packet: RawPacket) -> Result<Self, DecodeError> {
|
pub fn from_packet(client_info: &ClientInfo, packet: RawPacket) -> Result<Self, DecodeError> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
Ok(v1_16_3::game::JoinGame::decode(&mut packet.data.as_slice())?.into())
|
Ok(v1_16_3::game::JoinGame::decode(&mut packet.data.as_slice())?.into())
|
||||||
}
|
}
|
||||||
_ => Ok(v1_17::game::JoinGame::decode(&mut packet.data.as_slice())?.into()),
|
_ => Ok(v1_17::game::JoinGame::decode(&mut packet.data.as_slice())?.into()),
|
||||||
@ -74,7 +74,7 @@ impl From<v1_17::game::JoinGame> for JoinGameData {
|
|||||||
/// Check whether the packet ID matches.
|
/// Check whether the packet ID matches.
|
||||||
pub fn is_packet(client_info: &ClientInfo, packet_id: u8) -> bool {
|
pub fn is_packet(client_info: &ClientInfo, packet_id: u8) -> bool {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => packet_id == v1_16_3::game::JoinGame::PACKET_ID,
|
Some(p) if p < v1_17::PROTOCOL => packet_id == v1_16_3::game::JoinGame::PACKET_ID,
|
||||||
_ => packet_id == v1_17::game::JoinGame::PACKET_ID,
|
_ => packet_id == v1_17::game::JoinGame::PACKET_ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ pub async fn lobby_send(
|
|||||||
let status = server.status().await;
|
let status = server.status().await;
|
||||||
|
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::JoinGame {
|
v1_16_3::game::JoinGame {
|
||||||
// Player ID must be unique, if it collides with another server entity ID the player gets
|
// Player ID must be unique, if it collides with another server entity ID the player gets
|
||||||
|
@ -21,7 +21,7 @@ pub async fn send(
|
|||||||
let id = KEEP_ALIVE_ID.fetch_add(1, Ordering::Relaxed);
|
let id = KEEP_ALIVE_ID.fetch_add(1, Ordering::Relaxed);
|
||||||
|
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(v1_16_3::game::ClientBoundKeepAlive { id }, client, writer).await
|
packet::write_packet(v1_16_3::game::ClientBoundKeepAlive { id }, client, writer).await
|
||||||
}
|
}
|
||||||
_ => packet::write_packet(v1_17::game::ClientBoundKeepAlive { id }, client, writer).await,
|
_ => packet::write_packet(v1_17::game::ClientBoundKeepAlive { id }, client, writer).await,
|
||||||
|
@ -11,7 +11,7 @@ pub async fn send(
|
|||||||
writer: &mut WriteHalf<'_>,
|
writer: &mut WriteHalf<'_>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::PlayerPositionAndLook {
|
v1_16_3::game::PlayerPositionAndLook {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
|
@ -16,7 +16,7 @@ pub async fn lobby_send(
|
|||||||
data: JoinGameData,
|
data: JoinGameData,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::Respawn {
|
v1_16_3::game::Respawn {
|
||||||
dimension: data.dimension.unwrap_or_else(|| {
|
dimension: data.dimension.unwrap_or_else(|| {
|
||||||
|
@ -19,7 +19,7 @@ pub async fn send(
|
|||||||
writer: &mut WriteHalf<'_>,
|
writer: &mut WriteHalf<'_>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::ClientBoundPluginMessage {
|
v1_16_3::game::ClientBoundPluginMessage {
|
||||||
channel: CHANNEL.into(),
|
channel: CHANNEL.into(),
|
||||||
|
@ -12,7 +12,7 @@ pub async fn send(
|
|||||||
sound_name: &str,
|
sound_name: &str,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::NamedSoundEffect {
|
v1_16_3::game::NamedSoundEffect {
|
||||||
sound_name: sound_name.into(),
|
sound_name: sound_name.into(),
|
||||||
|
@ -15,7 +15,7 @@ pub async fn send(
|
|||||||
writer: &mut WriteHalf<'_>,
|
writer: &mut WriteHalf<'_>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => {
|
Some(p) if p < v1_17::PROTOCOL => {
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
v1_16_3::game::TimeUpdate {
|
v1_16_3::game::TimeUpdate {
|
||||||
world_age: 0,
|
world_age: 0,
|
||||||
|
@ -29,7 +29,7 @@ pub async fn send(
|
|||||||
let subtitle = text.lines().skip(1).collect::<Vec<_>>().join("\n");
|
let subtitle = text.lines().skip(1).collect::<Vec<_>>().join("\n");
|
||||||
|
|
||||||
match client_info.protocol() {
|
match client_info.protocol() {
|
||||||
Some(p) if p <= v1_16_3::PROTOCOL => send_v1_16_3(client, writer, title, &subtitle).await,
|
Some(p) if p < v1_17::PROTOCOL => send_v1_16_3(client, writer, title, &subtitle).await,
|
||||||
_ => send_v1_17(client, writer, title, &subtitle).await,
|
_ => send_v1_17(client, writer, title, &subtitle).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user