Skip to content

Commit

Permalink
clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ReCore-sys committed Dec 10, 2024
1 parent 7d7a66d commit 5f25545
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 18 deletions.
15 changes: 8 additions & 7 deletions src/bin/src/packet_handlers/login_process.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ferrumc_core::chunks::chunk_receiver::ChunkReceiver;
use ferrumc_core::identity::player_identity::PlayerIdentity;
use ferrumc_core::transform::grounded::OnGround;
use ferrumc_core::transform::position::Position;
Expand Down Expand Up @@ -25,7 +26,6 @@ use ferrumc_net::packets::outgoing::synchronize_player_position::SynchronizePlay
use ferrumc_net_codec::encode::NetEncodeOpts;
use ferrumc_state::GlobalState;
use tracing::{debug, trace};
use ferrumc_core::chunks::chunk_receiver::ChunkReceiver;

#[event_handler]
async fn handle_login_start(
Expand All @@ -39,10 +39,12 @@ async fn handle_login_start(
debug!("Received login start from user with username {}", username);

// Add the player identity component to the ECS for the entity.
state.universe.add_component::<PlayerIdentity>(
login_start_event.conn_id,
PlayerIdentity::new(username.to_string(), uuid),
)?
state
.universe
.add_component::<PlayerIdentity>(
login_start_event.conn_id,
PlayerIdentity::new(username.to_string(), uuid),
)?
.add_component::<ChunkReceiver>(login_start_event.conn_id, ChunkReceiver::default())?;

//Send a Login Success Response to further the login sequence
Expand Down Expand Up @@ -175,9 +177,8 @@ async fn handle_ack_finish_configuration(
let mut chunk_recv = state.universe.get_mut::<ChunkReceiver>(conn_id)?;
chunk_recv.last_chunk = Some((pos.x as i32, pos.z as i32, String::from("overworld")));
chunk_recv.calculate_chunks().await;

send_keep_alive(conn_id, state, &mut writer).await?;


Ok(ack_finish_configuration_event)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use tracing::trace;
use ferrumc_core::chunks::chunk_receiver::ChunkReceiver;
use ferrumc_core::identity::player_identity::PlayerIdentity;
use ferrumc_core::transform::grounded::OnGround;
Expand All @@ -9,6 +8,7 @@ use ferrumc_net::errors::NetError;
use ferrumc_net::packets::packet_events::TransformEvent;
use ferrumc_net::utils::ecs_helpers::EntityExt;
use ferrumc_state::GlobalState;
use tracing::trace;

#[event_handler]
async fn handle_player_move(
Expand Down
6 changes: 1 addition & 5 deletions src/bin/src/systems/chunk_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ impl System for ChunkFetcher {
let players = state
.universe
.query::<(&PlayerIdentity, &mut ChunkReceiver)>();
for (eid, (_, chunk_recv)) in players {
for (_eid, (_, chunk_recv)) in players {
let state = state.clone();
//taskset.spawn(async move {
let player = state
.universe
.get::<PlayerIdentity>(eid)
.expect("PlayerIdentity not found");
for mut chunks in chunk_recv.needed_chunks.iter_mut() {
let (key, chunk) = chunks.pair_mut();
if chunk.is_none() {
Expand Down
1 change: 0 additions & 1 deletion src/bin/src/systems/chunk_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use ferrumc_net::connection::StreamWriter;
use ferrumc_net::packets::outgoing::chunk_and_light_data::ChunkAndLightData;
use ferrumc_net::packets::outgoing::set_center_chunk::SetCenterChunk;
use ferrumc_net_codec::encode::NetEncodeOpts;
use ferrumc_net_codec::net_types::var_int::VarInt;
use ferrumc_state::GlobalState;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/src/systems/definition.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::systems::chunk_fetcher::ChunkFetcher;
use crate::systems::chunk_sender::ChunkSenderSystem;
use crate::systems::keep_alive_system::KeepAliveSystem;
use crate::systems::tcp_listener_system::TcpListenerSystem;
Expand All @@ -8,7 +9,6 @@ use ferrumc_state::GlobalState;
use futures::stream::FuturesUnordered;
use std::sync::{Arc, LazyLock};
use tracing::{debug, debug_span, info, Instrument};
use crate::systems::chunk_fetcher::ChunkFetcher;

#[async_trait]
pub trait System: Send + Sync {
Expand Down
1 change: 0 additions & 1 deletion src/lib/core/src/chunks/chunk_receiver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use dashmap::{DashMap, DashSet};
use ferrumc_world::chunk_format::Chunk;
use tokio::time::Instant;
use tracing::trace;

const VIEW_DISTANCE: i32 = 12;
pub struct ChunkReceiver {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/src/chunks/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod chunk_receiver;
pub mod chunk_receiver;
2 changes: 1 addition & 1 deletion src/lib/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod errors;

// Core structs/types. Usually used in ECS Components.
pub mod chunks;
pub mod identity;
pub mod state;
pub mod transform;
pub mod chunks;

0 comments on commit 5f25545

Please sign in to comment.