style(simulation): cargo fmt + fix clippy warnings after economics integration

- `economy.rs`: fix empty_line_after_doc_comments (section ordering),
  use `is_multiple_of` for ECON_TICK_RATE check
- `debug.rs`, `input.rs`, `mod.rs`: rustfmt import ordering + indentation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 13:22:47 +02:00
co-authored by Claude Sonnet 4.6
parent 5f4139bc9e
commit 77232434f4
4 changed files with 19 additions and 23 deletions
+9 -6
View File
@@ -12,10 +12,10 @@ use crate::bridge::types::{
DebugCommandKind, DebugEnabled, DebugResponsePayload, EconDebugEffect, EconParamKind,
SnapshotBuffer,
};
use crate::simulation::economy::{EconSimResource, EconStateResource};
use crate::knowledge::EntityRegistry;
use crate::npc::Npc;
use crate::simulation::conversation::NpcName;
use crate::simulation::economy::{EconSimResource, EconStateResource};
use crate::simulation::movement::{PlayerCharacter, TilePosition, WalkabilityMap};
use crate::simulation::tier::ActiveSim;
use crate::simulation::time::SimulationTime;
@@ -337,7 +337,9 @@ pub fn handle_debug_commands(
magnitude,
duration_ticks,
} => {
use econ_sim::events::{EconEvent, EconEventEffect, EconEventTarget, EconEventVisibility};
use econ_sim::events::{
EconEvent, EconEventEffect, EconEventTarget, EconEventVisibility,
};
if let Some(ref mut sim) = econ_sim {
let econ_effect = match effect {
EconDebugEffect::CapacityMultiplier => {
@@ -346,9 +348,7 @@ pub fn handle_debug_commands(
EconDebugEffect::ProductivityMultiplier => {
EconEventEffect::ProductivityMultiplier(magnitude)
}
EconDebugEffect::DemandShock => {
EconEventEffect::DemandShock(magnitude)
}
EconDebugEffect::DemandShock => EconEventEffect::DemandShock(magnitude),
EconDebugEffect::ExchangeShock => {
EconEventEffect::ExchangeShock(magnitude)
}
@@ -427,7 +427,10 @@ pub fn handle_debug_commands(
}
} else {
let mut lines = vec![
format!("=== Economy state for '{}' (econ_tick={}) ===", system_id, state.econ_tick),
format!(
"=== Economy state for '{}' (econ_tick={}) ===",
system_id, state.econ_tick
),
format!(" FX rate (Tractus/Mark): {:.4}", state.tractus_mark_rate),
];
for ((_, commodity_id), sig) in &signals {
+7 -13
View File
@@ -141,7 +141,7 @@ pub fn tick_economy_simulation(
_ => return, // economy not loaded — no-op
};
if time.tick % ECON_TICK_RATE != 0 {
if !time.tick.is_multiple_of(ECON_TICK_RATE) {
return;
}
@@ -196,9 +196,7 @@ fn rebuild_signals(
let commodities: Vec<(String, f64, f64)> = node
.commodities
.iter()
.map(|(commodity_id, state)| {
(commodity_id.clone(), state.price, state.supply)
})
.map(|(commodity_id, state)| (commodity_id.clone(), state.price, state.supply))
.collect();
(system_id.clone(), commodities)
})
@@ -280,15 +278,6 @@ fn rebuild_signals(
}
}
// ---------------------------------------------------------------------------
// Startup helper
// ---------------------------------------------------------------------------
/// Attempt to load the economy simulation.
///
/// Returns `Some((EconSimResource, EconStateResource))` on success, `None` on
/// failure (with the error logged at warn level). The server inserts these as
/// resources when present; the economy features degrade gracefully when absent.
// ---------------------------------------------------------------------------
// IPC query buffer (#822)
// ---------------------------------------------------------------------------
@@ -361,6 +350,11 @@ pub fn serve_econ_state_query(
// Startup helper
// ---------------------------------------------------------------------------
/// Attempt to load the economy simulation.
///
/// Returns `Some((EconSimResource, EconStateResource))` on success, `None` on
/// failure (with the error logged at warn level). The server inserts these as
/// resources when present; the economy features degrade gracefully when absent.
pub fn try_load_economy(run_seed: u64) -> Option<(EconSimResource, EconStateResource)> {
match Simulation::load_auto(run_seed) {
Ok(sim) => {
+2 -2
View File
@@ -4,10 +4,10 @@
use crate::bridge::debug::DebugCommandBuffer;
use crate::bridge::types::{FacingDirection, ObjectType, PlayerAction, PlayerInput};
use crate::simulation::economy::EconQueryBuffer;
use crate::knowledge::{EntityRegistry, StableId};
use crate::perception::vision_cone::{facing_from_delta, Facing};
use crate::settings::{SettingsCommand, SettingsCommandBuffer};
use crate::simulation::economy::EconQueryBuffer;
use crate::simulation::interaction::{DoorInteractRequest, DoorState, TerminalInteractRequest};
use crate::simulation::inventory::{
find_next_slot, occupied_slots_for, CarriedBy, InventorySlot, ItemName, MAX_INVENTORY_SLOTS,
@@ -129,7 +129,7 @@ pub fn process_player_input(
| PlayerAction::ChangeSetting { .. }
| PlayerAction::RequestAllSettings
| PlayerAction::DeleteSetting { .. }
| PlayerAction::EconStateQuery { .. }
| PlayerAction::EconStateQuery { .. }
)
{
continue;
+1 -2
View File
@@ -170,8 +170,7 @@ impl Plugin for SimulationPlugin {
// Economy simulation (#821, D-031) — loaded once at startup, no-op when DB absent.
// Uses seed 0 for now; will be threaded through StartupMessage world seed (#TODO).
if let Some((econ_sim, econ_state)) = economy::try_load_economy(0) {
app.insert_resource(econ_sim)
.insert_resource(econ_state);
app.insert_resource(econ_sim).insert_resource(econ_state);
}
// EconQueryBuffer: always registered so EconStateQuery PlayerActions are accepted
// even when the economy DB is absent (queries just produce no response).