refactor: code cleanup — dead code, warnings, duplication

Dead code removed (21 methods, 4 fields, 3 constants):
- Cell: MaterialId::ALL, MaterialId::from_u8 (unsafe transmute)
- Grid: get_mut, clear, fill_rect, swap, dump_region, next buffer field
- Entity: move_center, EntityManager::iter_mut
- Player: move_dir field, entity_mut
- VerletSolver: step, SubBody::add_vel, SubBody::apply_force
- CellularAutomaton: tick_count
- InputHandler: release_all, poll, Action::None
- WindowInput: clear
- GameSession: perform_action_and_step, is_recording, grid_mut
- ReplayPlayer: from_recording
- Material: empty()
- VulkanRenderer: tick_count field
- MaterialBrush: name()

Warnings fixed:
- Remove unused MaterialRegistry imports from renderers
- Remove unused reg variables in terminal/vulkan/graphics
- Remove unused water_surface in game.rs
- Remove unused p/y_death in tests
- Remove unused qf_slice in graphics.rs

Duplication eliminated:
- main.rs: run_ascii_mode + run_graphics_mode → generic run_gpu_mode<R: GpuRenderer>
  ~140 lines of duplicated event loop code removed
- GpuRenderer trait unifies VulkanRenderer and GraphicsRenderer API

Unsafe code fixed:
- rand_u8: static mut + unsafe → AtomicU8 + fetch_add (thread-safe)

Module cleanup:
- world/mod.rs: removed all unused re-exports
- physics/mod.rs: removed all unused re-exports
- entity/mod.rs: removed unused Entity/EntityId re-exports

Result: ~6500 → ~5964 lines, 0 non-deprecation warnings, 109 tests pass
This commit is contained in:
Emil
2026-06-21 01:36:25 +03:00
parent d889e24cf6
commit 68fe0b87dd
22 changed files with 182 additions and 511 deletions
+1 -4
View File
@@ -11,7 +11,6 @@ use crate::entity::EntityManager;
use crate::render::Renderer;
use crate::world::cell::MaterialId;
use crate::world::grid::Grid;
use crate::world::material::MaterialRegistry;
pub struct TerminalRenderer {
width: usize,
@@ -70,7 +69,6 @@ impl Renderer for TerminalRenderer {
return Ok(());
}
let reg = MaterialRegistry::instance();
let mut out = stdout();
let mut frame: Vec<(char, (u8, u8, u8), (u8, u8, u8))>;
let total = self.width * self.height;
@@ -80,13 +78,12 @@ impl Renderer for TerminalRenderer {
for dx in 0..self.width {
let wx = cam_x + dx as i32;
let wy = cam_y + dy as i32;
let idx = dy * self.width + dx;
if !grid.in_bounds(wx, wy) {
let idx = dy * self.width + dx;
frame[idx] = ('?', (80, 80, 80), (10, 10, 15));
continue;
}
let cell = grid.get(wx, wy);
let idx = dy * self.width + dx;
if cell.is_empty() {
frame[idx] = (' ', (cell.fg[0], cell.fg[1], cell.fg[2]), (cell.bg[0], cell.bg[1], cell.bg[2]));
} else {