Skip to content

Commit

Permalink
feat: add allow(dead_code) attributes to game cache module
Browse files Browse the repository at this point in the history
  • Loading branch information
hsnks100 committed Dec 7, 2024
1 parent 085424f commit c293376
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/game_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait ClientTrait: Debug {
}

/// Represents the result of processing a frame.
#[derive(Debug)]
#[allow(dead_code)]
pub struct FrameResult {
pub frame_index: usize,
pub use_cache: bool,
Expand All @@ -109,6 +109,7 @@ pub struct GameDataProcessor {
}

impl GameDataProcessor {
#[allow(dead_code)]
/// Creates a new GameDataProcessor with no clients.
pub fn new() -> Self {
Self {
Expand All @@ -119,18 +120,21 @@ impl GameDataProcessor {
}
}

#[allow(dead_code)]
/// Adds a new client to the processor.
fn add_client(&mut self, client_id: u32, client: Box<dyn ClientTrait>) {
self.clients.insert(client_id, client);
}

#[allow(dead_code)]
/// Processes incoming game data from a client.
/// Stores the data in the client's pending inputs.
fn process_incoming(&mut self, client_id: u32, data: Vec<u8>) {
let client = self.clients.get_mut(&client_id).expect("Client not found");
client.handle_incoming(data);
}

#[allow(dead_code)]
/// Processes a frame if inputs from all clients are available.
/// Returns Some(FrameResult) if the frame was processed.
pub fn process_frame(&mut self) -> Option<FrameResult> {
Expand Down Expand Up @@ -168,6 +172,7 @@ impl GameDataProcessor {
Some(frame_result)
}

#[allow(dead_code)]
/// Prepares outgoing game data to send to clients.
pub fn prepare_outgoing(&mut self, data: Vec<u8>) -> (bool, u8, Vec<u8>) {
if let Some(pos) = self.aggregated_cache.find(&data) {
Expand Down

0 comments on commit c293376

Please sign in to comment.