Expose tick interval constant and simplify handler

Move the 33 ms tick interval into `tick` as a public constant `TICK_MS`
and drop the parameter from `handle_tick_event`.
Update re‑exports and callers accordingly
This commit is contained in:
GarandPLG committed 2026-05-05 13:58:17 +02:00
1 parent b1183175be
commit 35209dd064
3 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -4,4 +4,4 @@ mod tick;
pub use audio::{AudioCmd, SoundrackParts, Soundtrack, handle_audio};
pub use events::handle_ct_events;
pub use tick::handle_tick_event;
pub use tick::{TICK_MS, handle_tick_event};
+4 -2
View File
@@ -4,8 +4,10 @@ use std::{
time::{Duration, Instant},
};
pub fn handle_tick_event(tx: Sender<()>, tick_ms: u8) {
let interval: Duration = Duration::from_millis(tick_ms as u64);
pub const TICK_MS: u8 = 33;
pub fn handle_tick_event(tx: Sender<()>) {
let interval: Duration = Duration::from_millis(TICK_MS as u64);
loop {
if tx.send(()).is_err() {
break;
+1 -3
View File
@@ -12,8 +12,6 @@ use war_in_tunnels::{
cli::{Cli, get_args},
};
const TICK_MS: u8 = 33;
/// Starts the terminal UI application.
///
/// The function follows the steps outlined in the module‑level documentation.
@@ -28,7 +26,7 @@ fn main() -> Result<()> {
let (audio_tx, audio_rx) = channel::<AudioCmd>();
thread::spawn(move || handle_ct_events(input_tx, resize_tx));
thread::spawn(move || handle_tick_event(tick_tx, TICK_MS));
thread::spawn(move || handle_tick_event(tick_tx));
thread::spawn(move || handle_audio(audio_rx, args.mute, args.soundtrack));
let mut terminal: Terminal<CrosstermBackend<Stdout>> = ratatui::init();