Probe map title hints for kind-8 carriers

This commit is contained in:
Jan Petykiewicz 2026-04-19 10:53:49 -07:00
commit b9054b1780
6 changed files with 655 additions and 18 deletions

View file

@ -24,12 +24,13 @@ use rrt_runtime::{
RuntimeOverlayImportDocument, RuntimeOverlayImportDocumentSource, RuntimeSaveSliceDocument,
RuntimeSaveSliceDocumentSource, RuntimeSnapshotDocument, RuntimeSnapshotSource, RuntimeSummary,
SAVE_SLICE_DOCUMENT_FORMAT_VERSION, SNAPSHOT_FORMAT_VERSION, SmpClassicPackedProfileBlock,
SmpInspectionReport, SmpLoadedSaveSlice, SmpRt3105PackedProfileBlock, SmpSaveLoadSummary,
WinInspectionReport, compare_save_region_fixed_row_run_candidates, execute_step_command,
extract_pk4_entry_file, inspect_building_types_dir_with_bindings, inspect_campaign_exe_file,
inspect_cargo_economy_sources_with_bindings, inspect_cargo_skin_pk4, inspect_cargo_types_dir,
inspect_pk4_file, inspect_save_company_and_chairman_analysis_file,
inspect_save_infrastructure_asset_trace_file, inspect_save_periodic_company_service_trace_file,
SmpInspectionReport, SmpLoadedSaveSlice, SmpMapTitleHintProbe, SmpRt3105PackedProfileBlock,
SmpSaveLoadSummary, WinInspectionReport, compare_save_region_fixed_row_run_candidates,
execute_step_command, extract_pk4_entry_file, inspect_building_types_dir_with_bindings,
inspect_campaign_exe_file, inspect_cargo_economy_sources_with_bindings, inspect_cargo_skin_pk4,
inspect_cargo_types_dir, inspect_map_title_hint_file, inspect_pk4_file,
inspect_save_company_and_chairman_analysis_file, inspect_save_infrastructure_asset_trace_file,
inspect_save_periodic_company_service_trace_file,
inspect_save_placed_structure_dynamic_side_buffer_file,
inspect_save_region_queued_notice_records_file, inspect_save_region_service_trace_file,
inspect_smp_file, inspect_unclassified_save_collection_headers_file, inspect_win_file,
@ -135,6 +136,9 @@ enum Command {
RuntimeInspectCompactEventDispatchClusterCounts {
root_path: PathBuf,
},
RuntimeInspectMapTitleHints {
root_path: PathBuf,
},
RuntimeSummarizeSaveLoad {
smp_path: PathBuf,
},
@ -319,6 +323,28 @@ struct RuntimeCompactEventDispatchClusterCountsOutput {
report: RuntimeCompactEventDispatchClusterCountsReport,
}
#[derive(Debug, Serialize)]
struct RuntimeMapTitleHintDirectoryOutput {
root_path: String,
report: RuntimeMapTitleHintDirectoryReport,
}
#[derive(Debug, Serialize)]
struct RuntimeMapTitleHintDirectoryReport {
maps_scanned: usize,
maps_with_probe: usize,
maps_with_grounded_title_hits: usize,
maps_with_adjacent_title_pairs: usize,
maps_with_same_stem_adjacent_pairs: usize,
maps: Vec<RuntimeMapTitleHintMapEntry>,
}
#[derive(Debug, Serialize)]
struct RuntimeMapTitleHintMapEntry {
path: String,
probe: SmpMapTitleHintProbe,
}
#[derive(Debug, Serialize)]
struct RuntimeCompactEventDispatchClusterReport {
maps_scanned: usize,
@ -1061,6 +1087,9 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
Command::RuntimeInspectCompactEventDispatchClusterCounts { root_path } => {
run_runtime_inspect_compact_event_dispatch_cluster_counts(&root_path)?;
}
Command::RuntimeInspectMapTitleHints { root_path } => {
run_runtime_inspect_map_title_hints(&root_path)?;
}
Command::RuntimeSummarizeSaveLoad { smp_path } => {
run_runtime_summarize_save_load(&smp_path)?;
}
@ -1311,6 +1340,13 @@ fn parse_command() -> Result<Command, Box<dyn std::error::Error>> {
root_path: PathBuf::from(root_path),
})
}
[command, subcommand, root_path]
if command == "runtime" && subcommand == "inspect-map-title-hints" =>
{
Ok(Command::RuntimeInspectMapTitleHints {
root_path: PathBuf::from(root_path),
})
}
[command, subcommand, path]
if command == "runtime" && subcommand == "summarize-save-load" =>
{
@ -1611,7 +1647,7 @@ fn parse_command() -> Result<Command, Box<dyn std::error::Error>> {
})
}
_ => Err(
"usage: rrt-cli [validate [repo-root] | finance eval <snapshot.json> | finance diff <left.json> <right.json> | runtime validate-fixture <fixture.json> | runtime summarize-fixture <fixture.json> | runtime export-fixture-state <fixture.json> <snapshot.json> | runtime diff-state <left.json> <right.json> | runtime summarize-state <snapshot.json> | runtime import-state <input.json> <snapshot.json> | runtime inspect-smp <file.smp> | runtime inspect-candidate-table <file.smp> | runtime inspect-compact-event-dispatch-cluster <maps-dir> | runtime inspect-compact-event-dispatch-cluster-counts <maps-dir> | runtime summarize-save-load <file.smp> | runtime load-save-slice <file.smp> | runtime inspect-save-company-chairman <file.smp> | runtime inspect-save-placed-structure-triplets <file.smp> | runtime compare-region-fixed-row-runs <left.gms> <right.gms> | runtime inspect-periodic-company-service-trace <file.smp> | runtime inspect-region-service-trace <file.smp> | runtime inspect-infrastructure-asset-trace <file.smp> | runtime inspect-save-region-queued-notice-records <file.smp> | runtime inspect-placed-structure-dynamic-side-buffer <file.smp> | runtime inspect-unclassified-save-collections <file.smp> | runtime import-save-state <file.smp> <snapshot.json> | runtime export-save-slice <file.smp> <save-slice.json> | runtime export-overlay-import <snapshot.json> <save-slice.json> <overlay-import.json> | runtime inspect-pk4 <file.pk4> | runtime inspect-cargo-types <CargoTypes-dir> | runtime inspect-building-type-sources <BuildingTypes-dir> [building-bindings.json] | runtime inspect-cargo-skins <Cargo106.PK4> | runtime inspect-cargo-economy-sources <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-cargo-production-selector <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-cargo-price-selector <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-win <file.win> | runtime extract-pk4-entry <file.pk4> <entry-name> <output-path> | runtime inspect-campaign-exe <RT3.exe> | runtime compare-classic-profile <save1.gms> <save2.gms> [saveN.gms...] | runtime compare-105-profile <save1.gms> <save2.gms> [saveN.gms...] | runtime compare-candidate-table <file1> <file2> [fileN...] | runtime compare-recipe-book-lines <file1> <file2> [fileN...] | runtime compare-setup-payload-core <file1> <file2> [fileN...] | runtime compare-setup-launch-payload <file1> <file2> [fileN...] | runtime compare-post-special-conditions-scalars <file1> <file2> [fileN...] | runtime scan-candidate-table-headers <root-dir> | runtime scan-special-conditions <root-dir> | runtime scan-aligned-runtime-rule-band <root-dir> | runtime scan-post-special-conditions-scalars <root-dir> | runtime scan-post-special-conditions-tail <root-dir> | runtime scan-recipe-book-lines <root-dir> | runtime export-profile-block <save.gms> <profile.json>]"
"usage: rrt-cli [validate [repo-root] | finance eval <snapshot.json> | finance diff <left.json> <right.json> | runtime validate-fixture <fixture.json> | runtime summarize-fixture <fixture.json> | runtime export-fixture-state <fixture.json> <snapshot.json> | runtime diff-state <left.json> <right.json> | runtime summarize-state <snapshot.json> | runtime import-state <input.json> <snapshot.json> | runtime inspect-smp <file.smp> | runtime inspect-candidate-table <file.smp> | runtime inspect-compact-event-dispatch-cluster <maps-dir> | runtime inspect-compact-event-dispatch-cluster-counts <maps-dir> | runtime inspect-map-title-hints <maps-dir> | runtime summarize-save-load <file.smp> | runtime load-save-slice <file.smp> | runtime inspect-save-company-chairman <file.smp> | runtime inspect-save-placed-structure-triplets <file.smp> | runtime compare-region-fixed-row-runs <left.gms> <right.gms> | runtime inspect-periodic-company-service-trace <file.smp> | runtime inspect-region-service-trace <file.smp> | runtime inspect-infrastructure-asset-trace <file.smp> | runtime inspect-save-region-queued-notice-records <file.smp> | runtime inspect-placed-structure-dynamic-side-buffer <file.smp> | runtime inspect-unclassified-save-collections <file.smp> | runtime import-save-state <file.smp> <snapshot.json> | runtime export-save-slice <file.smp> <save-slice.json> | runtime export-overlay-import <snapshot.json> <save-slice.json> <overlay-import.json> | runtime inspect-pk4 <file.pk4> | runtime inspect-cargo-types <CargoTypes-dir> | runtime inspect-building-type-sources <BuildingTypes-dir> [building-bindings.json] | runtime inspect-cargo-skins <Cargo106.PK4> | runtime inspect-cargo-economy-sources <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-cargo-production-selector <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-cargo-price-selector <CargoTypes-dir> <Cargo106.PK4> | runtime inspect-win <file.win> | runtime extract-pk4-entry <file.pk4> <entry-name> <output-path> | runtime inspect-campaign-exe <RT3.exe> | runtime compare-classic-profile <save1.gms> <save2.gms> [saveN.gms...] | runtime compare-105-profile <save1.gms> <save2.gms> [saveN.gms...] | runtime compare-candidate-table <file1> <file2> [fileN...] | runtime compare-recipe-book-lines <file1> <file2> [fileN...] | runtime compare-setup-payload-core <file1> <file2> [fileN...] | runtime compare-setup-launch-payload <file1> <file2> [fileN...] | runtime compare-post-special-conditions-scalars <file1> <file2> [fileN...] | runtime scan-candidate-table-headers <root-dir> | runtime scan-special-conditions <root-dir> | runtime scan-aligned-runtime-rule-band <root-dir> | runtime scan-post-special-conditions-scalars <root-dir> | runtime scan-post-special-conditions-tail <root-dir> | runtime scan-recipe-book-lines <root-dir> | runtime export-profile-block <save.gms> <profile.json>]"
.into(),
),
}
@ -1816,6 +1852,59 @@ fn run_runtime_inspect_smp(smp_path: &Path) -> Result<(), Box<dyn std::error::Er
Ok(())
}
fn run_runtime_inspect_map_title_hints(root_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
let mut maps = Vec::new();
let mut maps_scanned = 0usize;
let mut maps_with_probe = 0usize;
let mut maps_with_grounded_title_hits = 0usize;
let mut maps_with_adjacent_title_pairs = 0usize;
let mut maps_with_same_stem_adjacent_pairs = 0usize;
let mut paths = fs::read_dir(root_path)?
.filter_map(|entry| entry.ok().map(|entry| entry.path()))
.filter(|path| {
path.extension()
.and_then(|extension| extension.to_str())
.is_some_and(|extension| extension.eq_ignore_ascii_case("gmp"))
})
.collect::<Vec<_>>();
paths.sort();
for path in paths {
maps_scanned += 1;
if let Some(probe) = inspect_map_title_hint_file(&path)? {
maps_with_probe += 1;
if !probe.grounded_title_hits.is_empty() {
maps_with_grounded_title_hits += 1;
}
if !probe.adjacent_reference_title_pairs.is_empty() {
maps_with_adjacent_title_pairs += 1;
}
if probe.strongest_same_stem_pair.is_some() {
maps_with_same_stem_adjacent_pairs += 1;
}
maps.push(RuntimeMapTitleHintMapEntry {
path: path.display().to_string(),
probe,
});
}
}
let output = RuntimeMapTitleHintDirectoryOutput {
root_path: root_path.display().to_string(),
report: RuntimeMapTitleHintDirectoryReport {
maps_scanned,
maps_with_probe,
maps_with_grounded_title_hits,
maps_with_adjacent_title_pairs,
maps_with_same_stem_adjacent_pairs,
maps,
},
};
println!("{}", serde_json::to_string_pretty(&output)?);
Ok(())
}
fn run_runtime_inspect_compact_event_dispatch_cluster(
root_path: &Path,
) -> Result<(), Box<dyn std::error::Error>> {