Files
settled-reach/server/src/bin/atlas/mutate.rs
T
jpmschweitzerandClaude Opus 4.6 db241b88bd refactor(schema): rename biome_summary to planet_class (D-188)
"Biome" describes per-zone vegetation classification (Whittaker table).
"Planet class" describes overall planetary character. The conflation
caused the planet generator to misclassify ~270 bodies as barren.

Scope: systems.db column, schema SQL, Rust atlas code, wiki table
headers (Biome → Class), atlas proposal JSONs, all docs/decisions,
tooling scripts. Also normalizes atmosphere vocabulary (breathable →
standard) and expands planet class mapping to all 26 wiki values.
Unknown classes default to temperate for modder safety.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 17:10:35 +02:00

111 lines
2.8 KiB
Rust

use std::process;
use rusqlite::{params, Connection};
use serde::Serialize;
#[allow(clippy::too_many_arguments)]
pub fn cmd_add_body(
conn: &Connection,
id: &str,
system: &str,
r#type: &str,
orbit: Option<i32>,
name: &Option<String>,
parent: &Option<String>,
mass_class: &Option<String>,
atmosphere: &Option<String>,
gravity: Option<f64>,
biome: &Option<String>,
inhabited: bool,
population: Option<i64>,
) {
conn.execute(
"INSERT INTO bodies (body_id, system_id, parent_body_id, body_type, orbit_index,
proper_name, mass_class, atmosphere, surface_gravity,
planet_class, inhabited, population)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)",
params![
id,
system,
parent,
r#type,
orbit,
name,
mass_class,
atmosphere,
gravity,
biome,
inhabited as i32,
population.unwrap_or(0),
],
)
.unwrap_or_else(|e| {
eprintln!("error: {}", e);
process::exit(1);
});
println!(r#"{{"ok": true, "body_id": "{}"}}"#, id);
}
pub fn cmd_add_station(
conn: &Connection,
id: &str,
system: &str,
orbits: &Option<String>,
r#type: &str,
name: &Option<String>,
population: Option<i64>,
docking: &Option<String>,
gate: bool,
) {
conn.execute(
"INSERT INTO stations (station_id, system_id, orbits_body_id, station_type,
proper_name, population, docking_class, has_gate_infrastructure)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
params![
id,
system,
orbits,
r#type,
name,
population.unwrap_or(0),
docking,
gate as i32,
],
)
.unwrap_or_else(|e| {
eprintln!("error: {}", e);
process::exit(1);
});
println!(r#"{{"ok": true, "station_id": "{}"}}"#, id);
}
pub fn cmd_wipe_system(conn: &Connection, system_id: &str) {
let stations_deleted: usize = conn
.execute(
"DELETE FROM stations WHERE system_id = ?1",
params![system_id],
)
.unwrap();
let bodies_deleted: usize = conn
.execute(
"DELETE FROM bodies WHERE system_id = ?1",
params![system_id],
)
.unwrap();
#[derive(Serialize)]
struct WipeResult {
system_id: String,
bodies_deleted: usize,
stations_deleted: usize,
}
let result = WipeResult {
system_id: system_id.to_string(),
bodies_deleted,
stations_deleted,
};
println!("{}", serde_json::to_string_pretty(&result).unwrap());
}