Fix critical structural issues: undo/redo, surface import, brush strength, i18n macro, level.dat export, GPU fallback, Nether/End support, dead code removal, dim serde, CPU perf, wasm-host, GPU constants, clippy warnings

- Replace OnceLock with Mutex<Option> for snapshot system in all 9 operations (undo/redo now works after redo)
- Fix import surface detection: scan actual packed block data for highest solid block instead of always using +15
- Apply brush strength threshold (< 0.3) in PaintOperation for natural edge falloff
- Remove broken t!() macro variant with variable substitution
- Complete level.dat with RandomSeed, GameType, Difficulty, Spawn, Time, DataPacks, etc.
- GPU viewport falls back to CPU renderer for multi-tile worlds
- Export supports Nether (DIM-1/region) and End (DIM1/region) dimension subdirectories
- Remove dead FloodOperation (duplicate of PaintOperation)
- Add log::warn for malformed dimension tile keys in serde
- Reduce CPU viewport base_size from 64 to 32 (4x fewer pixels)
- Simplify wasm-host host_get_seed to direct cast
- Add named constants for GPU buffer sizes
- Fix unused import warning in cli/main.rs
- cargo fmt
This commit is contained in:
loki5512344 2026-07-04 11:44:34 +02:00
parent 18613260a8
commit 2419b603c1
24 changed files with 339 additions and 271 deletions

View file

@ -33,7 +33,10 @@ pub fn cmd_export(
if validate || dry_run {
if dry_run {
log::info!("{}", i18n::translate_with("cli.dry_run", &[("action", "export")]));
log::info!(
"{}",
i18n::translate_with("cli.dry_run", &[("action", "export")])
);
}
output::print_result(
format,

View file

@ -24,7 +24,10 @@ pub fn cmd_import(
if validate || dry_run {
if dry_run {
log::info!("{}", i18n::translate_with("cli.dry_run", &[("action", "import")]));
log::info!(
"{}",
i18n::translate_with("cli.dry_run", &[("action", "import")])
);
}
terrafier_core::io::import::validate_save(input_path)?;
output::print_result(
@ -54,10 +57,13 @@ pub fn cmd_import(
let bar = progress::new_bar(region_count.max(1) as u64, &importing_msg);
let world = terrafier_core::io::import::import(input_path)?;
let tile_count: usize = world.dimensions.iter().map(|d| d.tiles.len()).sum();
let import_msg = i18n::translate_with("cli.import.complete", &[
("tiles", &tile_count.to_string()),
("dimensions", &world.dimensions.len().to_string()),
]);
let import_msg = i18n::translate_with(
"cli.import.complete",
&[
("tiles", &tile_count.to_string()),
("dimensions", &world.dimensions.len().to_string()),
],
);
progress::finish_with(&import_msg, bar);
let output_path = Path::new(&args.output);

View file

@ -33,7 +33,10 @@ pub fn cmd_render(
if validate || dry_run {
if dry_run {
log::info!("{}", i18n::translate_with("cli.dry_run", &[("action", "render")]));
log::info!(
"{}",
i18n::translate_with("cli.dry_run", &[("action", "render")])
);
}
output::print_result(
format,
@ -50,9 +53,10 @@ pub fn cmd_render(
let bar = progress::new_bar(tile_count as u64, i18n::t!("cli.render.rendering"));
terrafier_core::io::export::render_to_image(&world, &args.output, args.scale)?;
let saved_msg = i18n::translate_with("cli.render.saved", &[
("path", &args.output.display().to_string()),
]);
let saved_msg = i18n::translate_with(
"cli.render.saved",
&[("path", &args.output.display().to_string())],
);
progress::finish_with(&saved_msg, bar);
log::info!("Preview rendered to: {}", args.output.display());

View file

@ -45,11 +45,15 @@ pub fn cmd_new(
let spinner = progress::new_spinner(i18n::t!("cli.new.creating"));
let world = World::new(&args.name, args.seed);
let tile_count = world.dimensions.iter().map(|d| d.tiles.len()).sum::<usize>();
let created_msg = i18n::translate_with("cli.new.created", &[
("name", &args.name),
("tiles", &tile_count.to_string()),
]);
let tile_count = world
.dimensions
.iter()
.map(|d| d.tiles.len())
.sum::<usize>();
let created_msg = i18n::translate_with(
"cli.new.created",
&[("name", &args.name), ("tiles", &tile_count.to_string())],
);
progress::finish_with(&created_msg, spinner);
let world_dir = args.output.join(&args.name);

View file

@ -1,5 +1,4 @@
use clap::Parser;
use std::path::PathBuf;
mod cmds;
mod util;
@ -43,7 +42,7 @@ enum Commands {
#[cfg(feature = "scripting")]
Run {
/// Path to .rhai script file
script: PathBuf,
script: std::path::PathBuf,
},
}

View file

@ -37,10 +37,10 @@ fn print_human(result: &Value) {
let tiles = result["tiles"].as_u64().unwrap_or(0);
println!(
"{}",
i18n::translate_with("cli.new.created", &[
("name", name),
("tiles", &tiles.to_string()),
])
i18n::translate_with(
"cli.new.created",
&[("name", name), ("tiles", &tiles.to_string()),]
)
);
let _ = seed;
}
@ -48,10 +48,10 @@ fn print_human(result: &Value) {
let tiles = result["tiles"].as_u64().unwrap_or(0);
println!(
"{}",
i18n::translate_with("cli.export.complete", &[
("regions", "?"),
("chunks", &tiles.to_string()),
])
i18n::translate_with(
"cli.export.complete",
&[("regions", "?"), ("chunks", &tiles.to_string()),]
)
);
}
"imported" => {
@ -60,10 +60,13 @@ fn print_human(result: &Value) {
let dims = result["dimensions"].as_u64().unwrap_or(0);
println!(
"{}",
i18n::translate_with("cli.import.complete", &[
("tiles", &tiles.to_string()),
("dimensions", &dims.to_string()),
])
i18n::translate_with(
"cli.import.complete",
&[
("tiles", &tiles.to_string()),
("dimensions", &dims.to_string()),
]
)
);
let _ = name;
}
@ -71,9 +74,7 @@ fn print_human(result: &Value) {
let output = result["output"].as_str().unwrap_or("?");
println!(
"{}",
i18n::translate_with("cli.render.saved", &[
("path", output),
])
i18n::translate_with("cli.render.saved", &[("path", output),])
);
}
"validated" => {
@ -125,17 +126,15 @@ fn print_human_info(result: &Value) {
if let Some(dims) = result.get("dimensions").and_then(|v| v.as_array()) {
println!(
" {}",
i18n::translate_with("cli.info.dimensions", &[
("dimensions", &dims.len().to_string()),
])
i18n::translate_with(
"cli.info.dimensions",
&[("dimensions", &dims.len().to_string()),]
)
);
for dim in dims {
let dim_name = dim["name"].as_str().unwrap_or("?");
let dim_tiles = dim["tiles"].as_u64().unwrap_or(0);
println!(
" - {} ({} tiles)",
dim_name, dim_tiles
);
println!(" - {} ({} tiles)", dim_name, dim_tiles);
}
}
if let Some(tiles) = result.get("total_tiles").and_then(|v| v.as_u64()) {