fix(simulation): Clippy cleanup and CI enforcement (#635)
Fix all Clippy warnings across the server codebase (2411 insertions, 1341 deletions). Raise type-complexity-threshold to 750 and too-many-arguments to 12 in .clippy.toml for idiomatic Bevy ECS system signatures. The server now passes `cargo clippy -- --deny warnings` cleanly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,21 +16,21 @@ use thiserror::Error;
|
||||
|
||||
use crate::bridge::types::SaveLoadResultWire;
|
||||
use crate::bridge::types::SnapshotBuffer;
|
||||
use crate::simulation::triangle::{TemplateReferenceMap, TriangleState};
|
||||
use crate::knowledge::graph::KnowledgeGraph;
|
||||
use crate::knowledge::registry::EntityRegistry;
|
||||
use crate::npc::Npc;
|
||||
use crate::knowledge::types::StableId;
|
||||
use crate::npc::relationships::RelationshipGraph;
|
||||
use crate::npc::Npc;
|
||||
use crate::simulation::interaction::DoorState;
|
||||
use crate::simulation::movement::PlayerCharacter;
|
||||
use crate::simulation::rng::SimRng;
|
||||
use crate::simulation::save_state::{
|
||||
deserialize_npc_from_frozen, serialize_npc_to_frozen, SaveStateV1, SAVE_FORMAT_VERSION,
|
||||
};
|
||||
use crate::knowledge::types::StableId;
|
||||
use crate::simulation::interaction::DoorState;
|
||||
use crate::simulation::tier::{ActiveSim, BackgroundSim};
|
||||
use crate::simulation::time::SimulationTime;
|
||||
use crate::simulation::triangle::TriangleCrisisEventQueue;
|
||||
use crate::simulation::triangle::{TemplateReferenceMap, TriangleState};
|
||||
use crate::storyteller::{
|
||||
ActivationState, ContaminationActive, ContaminationEventQueue, MovementHistoryBuffer,
|
||||
TriangleActivatedQueue,
|
||||
@@ -93,7 +93,9 @@ pub fn save_to_file(path: &Path, world: &mut World) -> Result<(), SaveLoadError>
|
||||
let player_knowledge = {
|
||||
let mut q = world.query_filtered::<&KnowledgeGraph, With<PlayerCharacter>>();
|
||||
q.single(world).cloned().unwrap_or_else(|_| {
|
||||
tracing::warn!("save_to_file: no PlayerCharacter with KnowledgeGraph found — saving empty graph");
|
||||
tracing::warn!(
|
||||
"save_to_file: no PlayerCharacter with KnowledgeGraph found — saving empty graph"
|
||||
);
|
||||
KnowledgeGraph::new()
|
||||
})
|
||||
};
|
||||
@@ -151,7 +153,7 @@ pub fn save_to_file(path: &Path, world: &mut World) -> Result<(), SaveLoadError>
|
||||
modifications: vec![], // TODO: persist when modification system is implemented
|
||||
contamination_active: world
|
||||
.get_resource::<ContaminationActive>()
|
||||
.map_or(false, |c| c.0),
|
||||
.is_some_and(|c| c.0),
|
||||
activated_count: world
|
||||
.get_resource::<ActivationState>()
|
||||
.map_or(0, |a| a.activated_count),
|
||||
@@ -294,7 +296,11 @@ pub fn load_from_file(path: &Path, world: &mut World) -> Result<(), SaveLoadErro
|
||||
if !state.open_doors.is_empty() {
|
||||
let open_set: std::collections::BTreeSet<_> = state.open_doors.iter().copied().collect();
|
||||
let door_entities: Vec<(Entity, StableId)> = {
|
||||
let mut q = world.query::<(Entity, &crate::knowledge::registry::StableEntityId, &DoorState)>();
|
||||
let mut q = world.query::<(
|
||||
Entity,
|
||||
&crate::knowledge::registry::StableEntityId,
|
||||
&DoorState,
|
||||
)>();
|
||||
q.iter(world)
|
||||
.filter(|(_, sid, _)| open_set.contains(&sid.0))
|
||||
.map(|(e, sid, _)| (e, sid.0))
|
||||
@@ -304,7 +310,9 @@ pub fn load_from_file(path: &Path, world: &mut World) -> Result<(), SaveLoadErro
|
||||
if let Some(mut door) = world.get_mut::<DoorState>(entity) {
|
||||
door.is_open = true;
|
||||
let tile = door.blocking_tile;
|
||||
if let Some(mut wmap) = world.get_resource_mut::<crate::simulation::movement::WalkabilityMap>() {
|
||||
if let Some(mut wmap) =
|
||||
world.get_resource_mut::<crate::simulation::movement::WalkabilityMap>()
|
||||
{
|
||||
wmap.set_walkable(&tile, true);
|
||||
}
|
||||
tracing::debug!(stable_id = sid.0, "load: restored open door state");
|
||||
@@ -395,8 +403,8 @@ mod tests {
|
||||
use crate::knowledge::graph::KnowledgeGraph;
|
||||
use crate::knowledge::registry::{EntityRegistry, StableEntityId};
|
||||
use crate::knowledge::types::StableId;
|
||||
use crate::npc::Npc;
|
||||
use crate::npc::relationships::RelationshipGraph;
|
||||
use crate::npc::Npc;
|
||||
use crate::simulation::movement::TilePosition;
|
||||
use crate::simulation::rng::SimRng;
|
||||
use crate::simulation::save_state::{SaveStateV1, SAVE_FORMAT_VERSION};
|
||||
@@ -467,7 +475,11 @@ mod tests {
|
||||
let bytes = std::fs::read(&path).expect("read saved file");
|
||||
let state = SaveStateV1::from_bytes(&bytes).unwrap();
|
||||
let ids: Vec<u64> = state.npc_states.iter().map(|n| n.stable_id.0).collect();
|
||||
assert_eq!(ids, vec![10, 30, 50], "npc_states must be sorted by stable_id");
|
||||
assert_eq!(
|
||||
ids,
|
||||
vec![10, 30, 50],
|
||||
"npc_states must be sorted by stable_id"
|
||||
);
|
||||
|
||||
let _ = std::fs::remove_file(&path);
|
||||
}
|
||||
@@ -651,10 +663,7 @@ mod tests {
|
||||
let mut q = world.query_filtered::<Entity, (With<Npc>, With<BackgroundSim>)>();
|
||||
q.iter(&world).count() > 0
|
||||
};
|
||||
assert!(
|
||||
has_background,
|
||||
"loaded NPC should be in BackgroundSim tier"
|
||||
);
|
||||
assert!(has_background, "loaded NPC should be in BackgroundSim tier");
|
||||
|
||||
let _ = std::fs::remove_file(&path);
|
||||
}
|
||||
@@ -903,7 +912,10 @@ mod tests {
|
||||
// Reset activation state to defaults before load
|
||||
world.insert_resource(ActivationState::default());
|
||||
assert_eq!(world.resource::<ActivationState>().activated_count, 0);
|
||||
assert!(world.resource::<ActivationState>().last_activation_tick.is_none());
|
||||
assert!(world
|
||||
.resource::<ActivationState>()
|
||||
.last_activation_tick
|
||||
.is_none());
|
||||
|
||||
load_from_file(&path, &mut world).expect("load");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user