From bcbcfebca9ef144a097a283dca8df1da1fe9d839 Mon Sep 17 00:00:00 2001 From: ReCore Date: Wed, 27 Nov 2024 14:25:34 +1030 Subject: [PATCH] Merge + clippy fixes --- Cargo.toml | 2 +- src/bin/src/main.rs | 2 +- src/bin/src/packet_handlers/login_process.rs | 1 - src/bin/src/systems/chunk_sender.rs | 2 +- src/bin/src/systems/keep_alive_system.rs | 2 -- src/lib/events/Cargo.toml | 4 ---- src/lib/net/src/utils/state.rs | 4 ++-- src/lib/utils/logging/src/lib.rs | 3 --- 8 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2c8ce800..cd80f9ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,7 +139,7 @@ maplit = "1.0.2" macro_rules_attribute = "0.2.0" # Magic ("life-before-main" initialization, __attribute__((constructor))) -ctor = "0.2.8" +ctor = "0.2.9" # Compression/Decompression libflate = "2.1.0" diff --git a/src/bin/src/main.rs b/src/bin/src/main.rs index 50a591d0..38a3bc7f 100644 --- a/src/bin/src/main.rs +++ b/src/bin/src/main.rs @@ -34,7 +34,7 @@ async fn main() { let cli_args = CLIArgs::parse(); ferrumc_logging::init_logging(cli_args.log.clone()); - println!("good day to ya. enjoy your time with ferrumc!"); + info!("Starting server..."); if let Err(e) = entry(cli_args).await { error!("Server exited with the following error: {}", e.to_string()); diff --git a/src/bin/src/packet_handlers/login_process.rs b/src/bin/src/packet_handlers/login_process.rs index cf5a5b50..b3f8f10c 100644 --- a/src/bin/src/packet_handlers/login_process.rs +++ b/src/bin/src/packet_handlers/login_process.rs @@ -23,7 +23,6 @@ use tracing::{debug, trace}; use ferrumc_core::transform::grounded::OnGround; use ferrumc_core::transform::position::Position; use ferrumc_core::transform::rotation::Rotation; -use ferrumc_net::packets::outgoing::finish_configuration::FinishConfigurationPacket; #[event_handler] async fn handle_login_start( diff --git a/src/bin/src/systems/chunk_sender.rs b/src/bin/src/systems/chunk_sender.rs index 469f0c2e..ad87b208 100644 --- a/src/bin/src/systems/chunk_sender.rs +++ b/src/bin/src/systems/chunk_sender.rs @@ -31,7 +31,7 @@ impl System for ChunkSenderSystem { while !self.stop.load(Ordering::Relaxed) { let players = state.universe.query::<(&PlayerIdentity, &Position, &mut StreamWriter)>(); // TODO: This is so ass. Please fix this. - for (player, position, mut conn) in players { + for (_entity, (player, position, mut conn)) in players { debug!("Sending chunks to player: {player:?} @ {position:?}"); for z in ((position.z.floor() as i32) / 16) - 5..(position.z.ceil() as i32 / 16) + 5 { for x in (position.x.floor() as i32 / 16) - 5..(position.x.ceil() as i32 / 16) + 5 { diff --git a/src/bin/src/systems/keep_alive_system.rs b/src/bin/src/systems/keep_alive_system.rs index 25a01285..fc57ad5b 100644 --- a/src/bin/src/systems/keep_alive_system.rs +++ b/src/bin/src/systems/keep_alive_system.rs @@ -9,7 +9,6 @@ use ferrumc_net::utils::state::terminate_connection; use ferrumc_net::GlobalState; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use std::time::Duration; use tracing::{error, info, trace, warn}; pub struct KeepAliveSystem { @@ -34,7 +33,6 @@ impl System for KeepAliveSystem { } // Get the times before the queries, since it's possible a query takes more than a millisecond with a lot of entities. - let packet = KeepAlivePacket::default(); let current_time = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) diff --git a/src/lib/events/Cargo.toml b/src/lib/events/Cargo.toml index fd287b52..2c1c7109 100644 --- a/src/lib/events/Cargo.toml +++ b/src/lib/events/Cargo.toml @@ -6,11 +6,7 @@ edition = "2021" [dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros"]} -crossbeam = { workspace = true } ctor = { workspace = true} -parking_lot = { workspace = true } -hashbrown = { workspace = true } -tinyvec = { workspace = true } thiserror = { workspace = true } futures = { workspace = true } dashmap = { workspace = true } diff --git a/src/lib/net/src/utils/state.rs b/src/lib/net/src/utils/state.rs index bdab35f0..3a114927 100644 --- a/src/lib/net/src/utils/state.rs +++ b/src/lib/net/src/utils/state.rs @@ -26,7 +26,7 @@ pub async fn terminate_connection( conn_id: usize, reason: String, ) -> NetResult<()> { - let mut writer = match conn_id.get_mut::(state.clone()) { + let mut writer = match conn_id.get_mut::(&state.clone()) { Ok(writer) => writer, Err(e) => { warn!("Failed to get stream writer for entity {}: {}", conn_id, e); @@ -45,7 +45,7 @@ pub async fn terminate_connection( return Err(e); } - match conn_id.get_mut::(state.clone()) { + match conn_id.get_mut::(&state.clone()) { Ok(mut control) => { control.should_disconnect = true; diff --git a/src/lib/utils/logging/src/lib.rs b/src/lib/utils/logging/src/lib.rs index ca752116..7050c2d6 100644 --- a/src/lib/utils/logging/src/lib.rs +++ b/src/lib/utils/logging/src/lib.rs @@ -14,9 +14,6 @@ pub fn init_logging(log_level: Option) { /*let trace_level = std::env::args() .find(|arg| arg.starts_with("--log=")) .map(|arg| arg.replace("--log=", ""));*/ - let trace_level = std::env::var("FERRUMC_LOG").ok(); - - // let trace_level = trace_level.unwrap_or_else(|| LOG_LEVEL.to_string()); let trace_level = log_level.unwrap_or_else(|| { println!("No log level provided, using default log level: {}", LOG_LEVEL); LOG_LEVEL.to_string()