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
-4
View File
@@ -66,10 +66,6 @@ impl ReplayPlayer {
Ok(Self { recording })
}
pub fn from_recording(recording: ReplayRecording) -> Self {
Self { recording }
}
pub fn play(&self) -> GameSession {
let mut session = GameSession::new_seeded(self.recording.seed);
session.init();
-13
View File
@@ -62,11 +62,6 @@ impl GameSession {
}
}
pub fn perform_action_and_step(&mut self, action: &AiAction, steps: u32) {
self.perform_action(action);
self.step(steps);
}
pub fn get_state(&self) -> GameState {
build_game_state(&self.game, self.view_width, self.view_height)
}
@@ -146,10 +141,6 @@ impl GameSession {
}
}
pub fn is_recording(&self) -> bool {
self.recorder.is_some()
}
pub fn save_replay(&self, path: &str) -> std::io::Result<()> {
if let Some(ref r) = self.recorder {
r.save(path)?;
@@ -169,10 +160,6 @@ impl GameSession {
&self.game.grid
}
pub fn grid_mut(&mut self) -> &mut Grid {
&mut self.game.grid
}
pub fn tick(&self) -> u64 {
self.game.tick
}
+1 -1
View File
@@ -76,7 +76,7 @@ impl CellInfo {
}
}
pub fn entity_info(e: &crate::entity::Entity) -> EntityInfo {
pub fn entity_info(e: &crate::entity::entity::Entity) -> EntityInfo {
let (px, py) = e.center();
let bodies: Vec<SubBodyInfo> = e.bodies.iter().enumerate().map(|(i, b)| {
let reg = MaterialRegistry::instance();