aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-07-29 15:32:04 -0500
committermat <github@matdoes.dev>2022-07-29 15:32:04 -0500
commit1b602d0be793394ac2b0d009b77c6a877a4efb7d (patch)
tree6d781edb998a362d368b6c65a86af84a91f747ba /azalea-protocol
parent4ee4687053b7442f518823b08099c156f4da4e83 (diff)
downloadazalea-drasl-1b602d0be793394ac2b0d009b77c6a877a4efb7d.tar.xz
fix errors and warnings
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/packet-macros/src/lib.rs121
-rwxr-xr-xazalea-protocol/src/packets/handshake/client_intention_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/handshake/mod.rs6
3 files changed, 73 insertions, 58 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs
index ce819733..ea4db210 100755
--- a/azalea-protocol/packet-macros/src/lib.rs
+++ b/azalea-protocol/packet-macros/src/lib.rs
@@ -235,6 +235,23 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
});
}
+ if !has_serverbound_packets {
+ serverbound_id_match_contents.extend(quote! {
+ _ => panic!("This enum is empty and can't exist.")
+ });
+ serverbound_write_match_contents.extend(quote! {
+ _ => panic!("This enum is empty and can't exist.")
+ });
+ }
+ if !has_clientbound_packets {
+ clientbound_id_match_contents.extend(quote! {
+ _ => panic!("This enum is empty and can't exist.")
+ });
+ clientbound_write_match_contents.extend(quote! {
+ _ => panic!("This enum is empty and can't exist.")
+ });
+ }
+
let mut contents = quote! {
#[derive(Clone, Debug)]
pub enum #serverbound_state_name
@@ -252,69 +269,67 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
}
};
- contents.extend(quote!{
- impl crate::packets::ProtocolPacket for #serverbound_state_name {
- fn id(&self) -> u32 {
- match self {
- #serverbound_id_match_contents
- _ => panic!("Impossible state, this packet shouldn't exist.")
- }
- }
-
- fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- match self {
- #serverbound_write_match_contents
- _ => panic!("Impossible state, this packet shouldn't exist.")
- }
+ contents.extend(quote! {
+ #[allow(unreachable_code)]
+ impl crate::packets::ProtocolPacket for #serverbound_state_name {
+ fn id(&self) -> u32 {
+ match self {
+ #serverbound_id_match_contents
}
+ }
- /// Read a packet by its id, ConnectionProtocol, and flow
- fn read(
- id: u32,
- buf: &mut impl std::io::Read,
- ) -> Result<#serverbound_state_name, String>
- where
- Self: Sized,
- {
- Ok(match id {
- #serverbound_read_match_contents
- _ => return Err(format!("Unknown Serverbound {} packet id: {}", #state_name_litstr, id)),
- })
+ fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ match self {
+ #serverbound_write_match_contents
}
}
- });
- contents.extend(quote!{
- impl crate::packets::ProtocolPacket for #clientbound_state_name {
- fn id(&self) -> u32 {
- match self {
- #clientbound_id_match_contents
- _ => panic!("Impossible state, this packet shouldn't exist.")
- }
+ /// Read a packet by its id, ConnectionProtocol, and flow
+ fn read(
+ id: u32,
+ buf: &mut impl std::io::Read,
+ ) -> Result<#serverbound_state_name, String>
+ where
+ Self: Sized,
+ {
+ Ok(match id {
+ #serverbound_read_match_contents
+ _ => return Err(format!("Unknown Serverbound {} packet id: {}", #state_name_litstr, id)),
+ })
+ }
+ }
+ });
+
+ contents.extend(quote! {
+ #[allow(unreachable_code)]
+ impl crate::packets::ProtocolPacket for #clientbound_state_name {
+ fn id(&self) -> u32 {
+ match self {
+ #clientbound_id_match_contents
}
+ }
- fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- match self {
- #clientbound_write_match_contents
- _ => panic!("Impossible state, this packet shouldn't exist.")
- }
+ fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
+ match self {
+ #clientbound_write_match_contents
}
+ }
- /// Read a packet by its id, ConnectionProtocol, and flow
- fn read(
- id: u32,
- buf: &mut impl std::io::Read,
- ) -> Result<#clientbound_state_name, String>
- where
- Self: Sized,
- {
- Ok(match id {
- #clientbound_read_match_contents
- _ => return Err(format!("Unknown Clientbound {} packet id: {}", #state_name_litstr, id)),
- })
- }
+ /// Read a packet by its id, ConnectionProtocol, and flow
+ fn read(
+ id: u32,
+ buf: &mut impl std::io::Read,
+ ) -> Result<#clientbound_state_name, String>
+ where
+ Self: Sized,
+ {
+ Ok(match id {
+ #clientbound_read_match_contents
+ _ => return Err(format!("Unknown Clientbound {} packet id: {}", #state_name_litstr, id)),
+ })
}
- });
+ }
+ });
contents.into()
}
diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs
index 804778a0..ef47bba3 100755
--- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs
+++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs
@@ -1,9 +1,9 @@
use crate::packets::ConnectionProtocol;
use azalea_buf::McBuf;
-use packet_macros::ClientboundHandshakePacket;
+use packet_macros::ServerboundHandshakePacket;
use std::hash::Hash;
-#[derive(Hash, Clone, Debug, McBuf, ClientboundHandshakePacket)]
+#[derive(Hash, Clone, Debug, McBuf, ServerboundHandshakePacket)]
pub struct ClientIntentionPacket {
#[var]
pub protocol_version: u32,
diff --git a/azalea-protocol/src/packets/handshake/mod.rs b/azalea-protocol/src/packets/handshake/mod.rs
index 88d9939b..8fd12529 100755
--- a/azalea-protocol/src/packets/handshake/mod.rs
+++ b/azalea-protocol/src/packets/handshake/mod.rs
@@ -4,8 +4,8 @@ use packet_macros::declare_state_packets;
declare_state_packets!(
HandshakePacket,
- Serverbound => {},
- Clientbound => {
+ Serverbound => {
0x00: client_intention_packet::ClientIntentionPacket,
- }
+ },
+ Clientbound => {}
);