diff --git a/AGENTS.md b/AGENTS.md index 59ef834..12d37ef 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -105,7 +105,7 @@ Then follow this loop on every step: 1. **Verify** the user's claimed change is actually present and correct. 2. If wrong or incomplete, explain what's off and let them fix it — do not silently patch it yourself. -3. Once correct, **run the linter and formatter** (`cargo clippy --all-targets`, `cargo fmt --all`, `selene .`, and `stylua .`) to ensure no regressions or style issues were introduced. +3. Once correct, **run the linter and formatter** (`cargo clippy --all-targets --all-features -- -D warnings`, `cargo fmt --all -- --check`, `selene .`, and `stylua .`) to ensure no regressions or style issues were introduced. 4. **Ensure useful comments are added** before committing. This includes function doc comments (`///`) and inline comments above important parts of the logic. If they are missing, add them yourself and follow the documention style specified in the relevant section below. 5. After comments and lints are verified, **create a git commit** capturing that step (following the commit conventions above) before moving on. 6. **Then** tell the user what to do next. @@ -225,7 +225,7 @@ cargo run -p server # run the server cargo test # run all tests cargo test -p renderer it_works # run a single test by name cargo check -p # fast type-check one crate -cargo clippy --all-targets +cargo clippy --all-targets --all-features -- -D warnings cargo fmt selene . stylua . diff --git a/CLAUDE.md b/CLAUDE.md index 3a44fe9..654f8b6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -105,7 +105,7 @@ Then follow this loop on every step: 1. **Verify** the user's claimed change is actually present and correct. 2. If wrong or incomplete, explain what's off and let them fix it — do not silently patch it yourself. -3. Once correct, **run the linter and formatter** (`cargo clippy --all-targets`, `cargo fmt --all`, `selene .`, and `stylua .`) to ensure no regressions or style issues were introduced. +3. Once correct, **run the linter and formatter** (`cargo clippy --all-targets --all-features -- -D warnings`, `cargo fmt --all -- --check`, `selene .`, and `stylua .`) to ensure no regressions or style issues were introduced. 4. **Ensure useful comments are added** before committing. This includes function doc comments (`///`) and inline comments above important parts of the logic. If they are missing, add them yourself and follow the documention style specified in the relevant section below. 5. After comments and lints are verified, **create a git commit** capturing that step (following the commit conventions above) before moving on. 6. **Then** tell the user what to do next. @@ -225,7 +225,7 @@ cargo run -p server # run the server cargo test # run all tests cargo test -p renderer it_works # run a single test by name cargo check -p # fast type-check one crate -cargo clippy --all-targets +cargo clippy --all-targets --all-features -- -D warnings cargo fmt selene . stylua . diff --git a/Cargo.lock b/Cargo.lock index 54ab2f9..1e8dce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1281,6 +1281,10 @@ dependencies = [ [[package]] name = "server" version = "0.1.0" +dependencies = [ + "tracing", + "tracing-subscriber", +] [[package]] name = "sharded-slab" diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index ccd37f0..8826c3b 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -5,7 +5,7 @@ use anyhow::{Context, Result}; use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; -use tracing::info; +use tracing::{error, info}; use winit::application::ApplicationHandler; use winit::event::WindowEvent; use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop}; @@ -21,35 +21,59 @@ impl ApplicationHandler for App { fn resumed(&mut self, event_loop: &ActiveEventLoop) { let attributes = Window::default_attributes().with_title("Project Catalyst"); - self.window = Some(event_loop.create_window(attributes).unwrap()); + let window = match event_loop.create_window(attributes) { + Ok(w) => w, + Err(e) => { + error!("Failed to create window: {e}"); + event_loop.exit(); + return; + } + }; - let display_handle = event_loop - .display_handle() - .expect("Failed to get display handle") - .as_raw(); + let display_handle = match event_loop.display_handle() { + Ok(h) => h.as_raw(), + Err(e) => { + error!("Failed to get display handle: {e}"); + event_loop.exit(); + return; + } + }; - // Get the window handle for surface creation - let window_handle = self - .window - .as_ref() - .unwrap() - .window_handle() - .expect("Failed to get window handle") - .as_raw(); + let window_handle = match window.window_handle() { + Ok(h) => h.as_raw(), + Err(e) => { + error!("Failed to get window handle: {e}"); + event_loop.exit(); + return; + } + }; - let required_extensions = ash_window::enumerate_required_extensions(display_handle) - .expect("Failed to enumerate required extensions"); + let required_extensions = match ash_window::enumerate_required_extensions(display_handle) { + Ok(exts) => exts, + Err(e) => { + error!("Failed to enumerate required extensions: {e}"); + event_loop.exit(); + return; + } + }; - let size = self.window.as_ref().unwrap().inner_size(); - let renderer = renderer::Renderer::new( + let size = window.inner_size(); + let renderer = match renderer::Renderer::new( display_handle, window_handle, size.width, size.height, required_extensions, - ) - .expect("Failed to initialize Vulkan renderer"); + ) { + Ok(r) => r, + Err(e) => { + error!("Failed to initialize Vulkan renderer: {e}"); + event_loop.exit(); + return; + } + }; + self.window = Some(window); self.renderer = Some(renderer); } @@ -59,8 +83,9 @@ impl ApplicationHandler for App { event_loop.exit(); } WindowEvent::RedrawRequested => { - if let Some(renderer) = self.renderer.as_mut() { - renderer.draw_frame().expect("Failed to draw frame"); + if let Some(Err(e)) = self.renderer.as_mut().map(renderer::Renderer::draw_frame) { + error!("Failed to draw frame: {e}"); + event_loop.exit(); } if let Some(window) = self.window.as_ref() { diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index fdfa381..65ae803 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -7,3 +7,5 @@ edition = "2024" workspace = true [dependencies] +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 35c51a4..f4b23f9 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -3,6 +3,12 @@ //! The server handles the authoritative game simulation, including world //! management, physics, and combat. +use tracing::info; + fn main() { - println!("Hello, world!"); + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .init(); + + info!("Starting Project Catalyst server"); }