refactor(sim): resolve clippy pedantic lints
- Replace signed coordinate round-trips with checked offset helpers - Use From/try_from conversions and clamp helpers in the edit parser - Isolate exact RNG, noise and day-fraction float casts in documented helpers - Split long functions (validate, world creation, apply, state_json, tick_person) - Pass run_sim shared state by reference and tidy remaining style lints Simulation behaviour and RNG sequences are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9fd93a8534
commit
63c72f5df7
20
src/main.rs
20
src/main.rs
|
|
@ -57,10 +57,10 @@ fn run_sim(
|
|||
snapshot,
|
||||
}: SimStart,
|
||||
mut rx: mpsc::UnboundedReceiver<Msg>,
|
||||
terrain: Arc<Mutex<String>>,
|
||||
script: Arc<Mutex<String>>,
|
||||
state_tx: watch::Sender<Arc<str>>,
|
||||
snapshot_tx: watch::Sender<Option<String>>,
|
||||
terrain: &Mutex<String>,
|
||||
script: &Mutex<String>,
|
||||
state_tx: &watch::Sender<Arc<str>>,
|
||||
snapshot_tx: &watch::Sender<Option<String>>,
|
||||
) {
|
||||
let mut world = match snapshot {
|
||||
Some(snapshot) => World::from_snapshot_with_script(&snapshot, seed, sim_script)
|
||||
|
|
@ -235,7 +235,7 @@ async fn client(mut socket: WebSocket, app: App) {
|
|||
Some(Ok(Message::Text(t))) if t.len() <= 256 => {
|
||||
let _ = app.tx.send(Msg::Edit(t.as_str().to_owned()));
|
||||
}
|
||||
Some(Ok(Message::Close(_))) | Some(Err(_)) | None => return,
|
||||
Some(Ok(Message::Close(_)) | Err(_)) | None => return,
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
|
|
@ -309,11 +309,11 @@ async fn main() {
|
|||
snapshot: saved_snapshot,
|
||||
},
|
||||
rx,
|
||||
terrain_buf,
|
||||
script,
|
||||
state_tx,
|
||||
snapshot_tx,
|
||||
)
|
||||
&terrain_buf,
|
||||
&script,
|
||||
&state_tx,
|
||||
&snapshot_tx,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
811
src/world.rs
811
src/world.rs
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue