Skip to content

Commit

Permalink
Merge branch 'deadlock_fix' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ReCore-sys committed Jun 26, 2024
2 parents f7e404a + 17dbd9f commit 2667abf
Show file tree
Hide file tree
Showing 11 changed files with 1,429 additions and 86 deletions.
647 changes: 639 additions & 8 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ thiserror = "1.0.61"
# Logging
log = "0.4.21"
env_logger = "0.11.3"
console-subscriber = "0.3.0"

# config / ser / de
serde = { version = "1.0.203", features = ["derive"]}
Expand Down
10 changes: 5 additions & 5 deletions src/crates/ferrumc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub fn bake_packet_registry(input: TokenStream) -> TokenStream {
match_arms.push(quote! {
(#packet_id, #state) => {
let packet = crate::packets::incoming::#struct_name_lowercase::#struct_name::decode(cursor).await?;
packet.handle(conn_owned).await?;
packet.handle(&mut conn).await?;
},
});
}
Expand All @@ -273,11 +273,11 @@ pub fn bake_packet_registry(input: TokenStream) -> TokenStream {
let match_arms = match_arms.into_iter();

let output = quote! {
pub async fn handle_packet(packet_id: u8, state: String, conn_owned: &mut crate::Connection, cursor: &mut std::io::Cursor<Vec<u8>>) -> ferrumc_utils::prelude::Result<()> {
let state = state.as_str();
match (packet_id, state) {
pub async fn handle_packet(packet_id: u8, conn_owned: &mut Arc<RwLock<crate::Connection>>, cursor: &mut std::io::Cursor<Vec<u8>>) -> ferrumc_utils::prelude::Result<()> {
let mut conn = conn_owned.write().await;
match (packet_id, conn.state.as_str()) {
#(#match_arms)*
_ => println!("No packet found for ID: 0x{:02X} in state: {}", packet_id, state),
_ => println!("No packet found for ID: 0x{:02X} in state: {}", packet_id, conn_owned.read().await.state.as_str()),
}

Ok(())
Expand Down
Loading

0 comments on commit 2667abf

Please sign in to comment.