Extend cargo selector and save-world analysis surfaces
This commit is contained in:
parent
cebcb8ad33
commit
6b8f849731
11 changed files with 639 additions and 26 deletions
|
|
@ -18,16 +18,17 @@ use rrt_model::{
|
|||
};
|
||||
use rrt_runtime::{
|
||||
CAMPAIGN_SCENARIO_COUNT, CampaignExeInspectionReport, CargoEconomySourceReport,
|
||||
CargoSkinInspectionReport, CargoTypeInspectionReport, OBSERVED_CAMPAIGN_SCENARIO_NAMES,
|
||||
OVERLAY_IMPORT_DOCUMENT_FORMAT_VERSION, Pk4ExtractionReport, Pk4InspectionReport,
|
||||
RuntimeOverlayImportDocument, RuntimeOverlayImportDocumentSource, RuntimeSaveSliceDocument,
|
||||
RuntimeSaveSliceDocumentSource, RuntimeSnapshotDocument, RuntimeSnapshotSource, RuntimeSummary,
|
||||
SAVE_SLICE_DOCUMENT_FORMAT_VERSION, SNAPSHOT_FORMAT_VERSION, SmpClassicPackedProfileBlock,
|
||||
SmpInspectionReport, SmpLoadedSaveSlice, SmpRt3105PackedProfileBlock, SmpSaveLoadSummary,
|
||||
WinInspectionReport, execute_step_command, extract_pk4_entry_file, inspect_campaign_exe_file,
|
||||
inspect_cargo_economy_sources_with_bindings, inspect_cargo_skin_pk4, inspect_cargo_types_dir,
|
||||
inspect_pk4_file, inspect_smp_file, inspect_win_file, load_runtime_snapshot_document,
|
||||
load_runtime_state_import, load_save_slice_file, project_save_slice_to_runtime_state_import,
|
||||
CargoSelectorReport, CargoSkinInspectionReport, CargoTypeInspectionReport,
|
||||
OBSERVED_CAMPAIGN_SCENARIO_NAMES, OVERLAY_IMPORT_DOCUMENT_FORMAT_VERSION, Pk4ExtractionReport,
|
||||
Pk4InspectionReport, RuntimeOverlayImportDocument, RuntimeOverlayImportDocumentSource,
|
||||
RuntimeSaveSliceDocument, RuntimeSaveSliceDocumentSource, RuntimeSnapshotDocument,
|
||||
RuntimeSnapshotSource, RuntimeSummary, SAVE_SLICE_DOCUMENT_FORMAT_VERSION,
|
||||
SNAPSHOT_FORMAT_VERSION, SmpClassicPackedProfileBlock, SmpInspectionReport, SmpLoadedSaveSlice,
|
||||
SmpRt3105PackedProfileBlock, SmpSaveLoadSummary, WinInspectionReport, execute_step_command,
|
||||
extract_pk4_entry_file, inspect_campaign_exe_file, inspect_cargo_economy_sources_with_bindings,
|
||||
inspect_cargo_skin_pk4, inspect_cargo_types_dir, inspect_pk4_file, inspect_smp_file,
|
||||
inspect_win_file, load_runtime_snapshot_document, load_runtime_state_import,
|
||||
load_save_slice_file, project_save_slice_to_runtime_state_import,
|
||||
save_runtime_overlay_import_document, save_runtime_save_slice_document,
|
||||
save_runtime_snapshot_document, validate_runtime_snapshot_document,
|
||||
};
|
||||
|
|
@ -151,6 +152,14 @@ enum Command {
|
|||
cargo_types_dir: PathBuf,
|
||||
cargo_skin_pk4_path: PathBuf,
|
||||
},
|
||||
RuntimeInspectCargoProductionSelector {
|
||||
cargo_types_dir: PathBuf,
|
||||
cargo_skin_pk4_path: PathBuf,
|
||||
},
|
||||
RuntimeInspectCargoPriceSelector {
|
||||
cargo_types_dir: PathBuf,
|
||||
cargo_skin_pk4_path: PathBuf,
|
||||
},
|
||||
RuntimeInspectWin {
|
||||
win_path: PathBuf,
|
||||
},
|
||||
|
|
@ -303,6 +312,13 @@ struct RuntimeCargoEconomyInspectionOutput {
|
|||
inspection: CargoEconomySourceReport,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct RuntimeCargoSelectorInspectionOutput {
|
||||
cargo_types_dir: String,
|
||||
cargo_skin_pk4_path: String,
|
||||
selector: CargoSelectorReport,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct RuntimeWinInspectionOutput {
|
||||
path: String,
|
||||
|
|
@ -860,6 +876,18 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
} => {
|
||||
run_runtime_inspect_cargo_economy_sources(&cargo_types_dir, &cargo_skin_pk4_path)?;
|
||||
}
|
||||
Command::RuntimeInspectCargoProductionSelector {
|
||||
cargo_types_dir,
|
||||
cargo_skin_pk4_path,
|
||||
} => {
|
||||
run_runtime_inspect_cargo_production_selector(&cargo_types_dir, &cargo_skin_pk4_path)?;
|
||||
}
|
||||
Command::RuntimeInspectCargoPriceSelector {
|
||||
cargo_types_dir,
|
||||
cargo_skin_pk4_path,
|
||||
} => {
|
||||
run_runtime_inspect_cargo_price_selector(&cargo_types_dir, &cargo_skin_pk4_path)?;
|
||||
}
|
||||
Command::RuntimeInspectWin { win_path } => {
|
||||
run_runtime_inspect_win(&win_path)?;
|
||||
}
|
||||
|
|
@ -1060,6 +1088,22 @@ fn parse_command() -> Result<Command, Box<dyn std::error::Error>> {
|
|||
cargo_skin_pk4_path: PathBuf::from(cargo_skin_pk4_path),
|
||||
})
|
||||
}
|
||||
[command, subcommand, cargo_types_dir, cargo_skin_pk4_path]
|
||||
if command == "runtime" && subcommand == "inspect-cargo-production-selector" =>
|
||||
{
|
||||
Ok(Command::RuntimeInspectCargoProductionSelector {
|
||||
cargo_types_dir: PathBuf::from(cargo_types_dir),
|
||||
cargo_skin_pk4_path: PathBuf::from(cargo_skin_pk4_path),
|
||||
})
|
||||
}
|
||||
[command, subcommand, cargo_types_dir, cargo_skin_pk4_path]
|
||||
if command == "runtime" && subcommand == "inspect-cargo-price-selector" =>
|
||||
{
|
||||
Ok(Command::RuntimeInspectCargoPriceSelector {
|
||||
cargo_types_dir: PathBuf::from(cargo_types_dir),
|
||||
cargo_skin_pk4_path: PathBuf::from(cargo_skin_pk4_path),
|
||||
})
|
||||
}
|
||||
[command, subcommand, path] if command == "runtime" && subcommand == "inspect-win" => {
|
||||
Ok(Command::RuntimeInspectWin {
|
||||
win_path: PathBuf::from(path),
|
||||
|
|
@ -1195,7 +1239,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 summarize-save-load <file.smp> | runtime load-save-slice <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-cargo-skins <Cargo106.PK4> | runtime inspect-cargo-economy-sources <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 summarize-save-load <file.smp> | runtime load-save-slice <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-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(),
|
||||
),
|
||||
}
|
||||
|
|
@ -1598,6 +1642,49 @@ fn run_runtime_inspect_cargo_economy_sources(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn run_runtime_inspect_cargo_production_selector(
|
||||
cargo_types_dir: &Path,
|
||||
cargo_skin_pk4_path: &Path,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let cargo_bindings_path =
|
||||
Path::new("artifacts/exports/rt3-1.06/event-effects-cargo-bindings.json");
|
||||
let inspection = inspect_cargo_economy_sources_with_bindings(
|
||||
cargo_types_dir,
|
||||
cargo_skin_pk4_path,
|
||||
Some(cargo_bindings_path),
|
||||
)?;
|
||||
let selector = inspection
|
||||
.production_selector
|
||||
.ok_or("named cargo production selector is not available in the checked-in bindings")?;
|
||||
let report = RuntimeCargoSelectorInspectionOutput {
|
||||
cargo_types_dir: cargo_types_dir.display().to_string(),
|
||||
cargo_skin_pk4_path: cargo_skin_pk4_path.display().to_string(),
|
||||
selector,
|
||||
};
|
||||
println!("{}", serde_json::to_string_pretty(&report)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_runtime_inspect_cargo_price_selector(
|
||||
cargo_types_dir: &Path,
|
||||
cargo_skin_pk4_path: &Path,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let cargo_bindings_path =
|
||||
Path::new("artifacts/exports/rt3-1.06/event-effects-cargo-bindings.json");
|
||||
let inspection = inspect_cargo_economy_sources_with_bindings(
|
||||
cargo_types_dir,
|
||||
cargo_skin_pk4_path,
|
||||
Some(cargo_bindings_path),
|
||||
)?;
|
||||
let report = RuntimeCargoSelectorInspectionOutput {
|
||||
cargo_types_dir: cargo_types_dir.display().to_string(),
|
||||
cargo_skin_pk4_path: cargo_skin_pk4_path.display().to_string(),
|
||||
selector: inspection.price_selector,
|
||||
};
|
||||
println!("{}", serde_json::to_string_pretty(&report)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_runtime_inspect_win(win_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let report = RuntimeWinInspectionOutput {
|
||||
path: win_path.display().to_string(),
|
||||
|
|
@ -4665,9 +4752,14 @@ mod tests {
|
|||
);
|
||||
let stock_prices_shell_save_fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../fixtures/runtime/packed-event-stock-prices-shell-save-slice-fixture.json");
|
||||
let game_won_shell_save_fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../fixtures/runtime/packed-event-game-won-shell-save-slice-fixture.json");
|
||||
let merger_premium_shell_save_fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(
|
||||
"../../fixtures/runtime/packed-event-merger-premium-shell-save-slice-fixture.json",
|
||||
);
|
||||
let set_human_control_shell_save_fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(
|
||||
"../../fixtures/runtime/packed-event-set-human-control-shell-save-slice-fixture.json",
|
||||
);
|
||||
let investor_confidence_condition_save_fixture = PathBuf::from(env!(
|
||||
"CARGO_MANIFEST_DIR"
|
||||
))
|
||||
|
|
@ -4771,8 +4863,12 @@ mod tests {
|
|||
.expect("save-slice-backed credit-rating descriptor fixture should summarize");
|
||||
run_runtime_summarize_fixture(&stock_prices_shell_save_fixture)
|
||||
.expect("save-slice-backed shell-owned stock-prices fixture should summarize");
|
||||
run_runtime_summarize_fixture(&game_won_shell_save_fixture)
|
||||
.expect("save-slice-backed shell-owned game-won fixture should summarize");
|
||||
run_runtime_summarize_fixture(&merger_premium_shell_save_fixture)
|
||||
.expect("save-slice-backed shell-owned merger-premium fixture should summarize");
|
||||
run_runtime_summarize_fixture(&set_human_control_shell_save_fixture)
|
||||
.expect("save-slice-backed shell-owned set-human-control fixture should summarize");
|
||||
run_runtime_summarize_fixture(&investor_confidence_condition_save_fixture)
|
||||
.expect("save-slice-backed investor-confidence condition fixture should summarize");
|
||||
run_runtime_summarize_fixture(&management_attitude_condition_save_fixture)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue