Broaden cargo packed event condition coverage

This commit is contained in:
Jan Petykiewicz 2026-04-16 14:23:43 -07:00
commit 0c4a90c16c
11 changed files with 434 additions and 23 deletions

View file

@ -1562,6 +1562,17 @@ fn lower_condition_targets_in_condition(
comparator: *comparator,
value: *value,
},
RuntimeCondition::CargoProductionSlotThreshold {
slot,
label,
comparator,
value,
} => RuntimeCondition::CargoProductionSlotThreshold {
slot: *slot,
label: label.clone(),
comparator: *comparator,
value: *value,
},
RuntimeCondition::CargoProductionTotalThreshold { comparator, value } => {
RuntimeCondition::CargoProductionTotalThreshold {
comparator: *comparator,
@ -1671,6 +1682,7 @@ fn condition_uses_condition_true_company(condition: &RuntimeCondition) -> bool {
| RuntimeCondition::CandidateAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveCostThreshold { .. }
| RuntimeCondition::CargoProductionSlotThreshold { .. }
| RuntimeCondition::CargoProductionTotalThreshold { .. }
| RuntimeCondition::LimitedTrackBuildingAmountThreshold { .. }
| RuntimeCondition::TerritoryAccessCostThreshold { .. }
@ -2294,6 +2306,7 @@ fn runtime_condition_is_world_state(condition: &RuntimeCondition) -> bool {
| RuntimeCondition::CandidateAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveCostThreshold { .. }
| RuntimeCondition::CargoProductionSlotThreshold { .. }
| RuntimeCondition::CargoProductionTotalThreshold { .. }
| RuntimeCondition::LimitedTrackBuildingAmountThreshold { .. }
| RuntimeCondition::TerritoryAccessCostThreshold { .. }
@ -2310,6 +2323,9 @@ fn ordinary_condition_row_is_world_state_family(
|| metric.contains("Candidate Availability")
|| metric.contains("Named Locomotive")
|| metric.contains("Cargo Production")
|| metric.contains("Factory Production")
|| metric.contains("Farm/Mine Production")
|| metric.contains("Other Cargo Production")
|| metric.contains("Limited Track Building Amount")
|| metric.contains("Territory Access Cost")
|| metric.contains("Economic Status")
@ -2388,6 +2404,7 @@ fn runtime_condition_company_target_import_blocker(
| RuntimeCondition::CandidateAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveAvailabilityThreshold { .. }
| RuntimeCondition::NamedLocomotiveCostThreshold { .. }
| RuntimeCondition::CargoProductionSlotThreshold { .. }
| RuntimeCondition::CargoProductionTotalThreshold { .. }
| RuntimeCondition::LimitedTrackBuildingAmountThreshold { .. }
| RuntimeCondition::TerritoryAccessCostThreshold { .. }
@ -3001,6 +3018,8 @@ mod tests {
metric: None,
semantic_family: None,
semantic_preview: None,
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec!["negative sentinel-style condition row id".to_string()],
}]
@ -3085,6 +3104,8 @@ mod tests {
row_shape: "multivalue_scalar".to_string(),
semantic_family: Some("multivalue_scalar".to_string()),
semantic_preview: Some("Set Company Cash to 7 with aux [2, 3, 24, 36]".to_string()),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: Some("Mikado".to_string()),
notes: vec!["grouped effect row carries locomotive-name side string".to_string()],
@ -3115,6 +3136,8 @@ mod tests {
"Set Deactivate Company to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3140,6 +3163,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Company Track Pieces Buildable to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3170,6 +3195,8 @@ mod tests {
"Set Deactivate Player to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3201,6 +3228,8 @@ mod tests {
"Set Territory - Allow All to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes,
@ -3226,6 +3255,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Economic Status to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3253,6 +3284,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Limited Track Building Amount to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3280,6 +3313,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Use Wartime Cargos to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3307,6 +3342,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Turbo Diesel Availability to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3335,6 +3372,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Unknown Loco Available to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: match descriptor_id {
241..=351 => Some(descriptor_id - 240),
457..=474 => Some(descriptor_id - 345),
@ -3375,6 +3414,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set {descriptor_label} to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id,
locomotive_name: None,
notes: vec![],
@ -3431,6 +3472,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set {descriptor_label} to {value}")),
recovered_cargo_slot: Some(slot),
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3458,6 +3501,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some(format!("Set Territory Access Cost to {value}")),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3490,6 +3535,8 @@ mod tests {
"Set {label} to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3520,6 +3567,8 @@ mod tests {
"Set Confiscate All to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -3552,6 +3601,8 @@ mod tests {
"Set Retire Train to {}",
if enabled { "TRUE" } else { "FALSE" }
)),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: locomotive_name.map(ToString::to_string),
notes,
@ -3577,6 +3628,8 @@ mod tests {
row_shape: "bool_toggle".to_string(),
semantic_family: Some("bool_toggle".to_string()),
semantic_preview: Some("Set Confiscate All to FALSE".to_string()),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec![],
@ -5043,6 +5096,8 @@ mod tests {
metric: Some("Territory Track Pieces".to_string()),
semantic_family: Some("numeric_threshold".to_string()),
semantic_preview: Some("Test Territory Track Pieces >= 10".to_string()),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: Vec::new(),
},
@ -5223,6 +5278,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some("Set Unknown Loco Available to 42".to_string()),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: Some(10),
locomotive_name: None,
notes: vec![],
@ -6324,6 +6381,8 @@ mod tests {
semantic_preview: Some(
"Set Company Cash to 250 with aux [2, 3, 24, 36]".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: Some("Mikado".to_string()),
notes: vec![
@ -7855,6 +7914,8 @@ mod tests {
semantic_preview: Some(
"Test Disable Stock Buying and Selling == TRUE".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![
"checked-in whole-game condition metadata sample".to_string(),
@ -7881,6 +7942,8 @@ mod tests {
row_shape: "scalar_assignment".to_string(),
semantic_family: Some("scalar_assignment".to_string()),
semantic_preview: Some("Set Turbo Diesel Availability to 1".to_string()),
recovered_cargo_slot: None,
recovered_cargo_class: None,
recovered_locomotive_id: None,
locomotive_name: None,
notes: vec!["checked-in whole-game grouped-effect sample".to_string()],
@ -8006,7 +8069,7 @@ mod tests {
one_shot: Some(false),
compact_control: Some(real_compact_control()),
text_bands: packed_text_bands(),
standalone_condition_row_count: 5,
standalone_condition_row_count: 6,
standalone_condition_rows: vec![
crate::SmpLoadedPackedEventConditionRowSummary {
row_index: 0,
@ -8024,6 +8087,8 @@ mod tests {
semantic_preview: Some(
"Test Named Locomotive Availability: Big Boy == 42".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
@ -8044,11 +8109,37 @@ mod tests {
"Test Named Locomotive Cost: Locomotive 1 == 250000"
.to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
crate::SmpLoadedPackedEventConditionRowSummary {
row_index: 2,
raw_condition_id: 200,
subtype: 4,
flag_bytes: {
let mut bytes = vec![0; 25];
bytes[0..4].copy_from_slice(&125_i32.to_le_bytes());
bytes
},
candidate_name: Some("Cargo Production Slot 1".to_string()),
comparator: Some("eq".to_string()),
metric: Some(
"Cargo Production: Cargo Production Slot 1".to_string(),
),
semantic_family: Some("world_scalar_threshold".to_string()),
semantic_preview: Some(
"Test Cargo Production: Cargo Production Slot 1 == 125"
.to_string(),
),
recovered_cargo_slot: Some(1),
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
crate::SmpLoadedPackedEventConditionRowSummary {
row_index: 3,
raw_condition_id: 2418,
subtype: 4,
flag_bytes: {
@ -8063,11 +8154,13 @@ mod tests {
semantic_preview: Some(
"Test Cargo Production Total == 125".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
crate::SmpLoadedPackedEventConditionRowSummary {
row_index: 3,
row_index: 4,
raw_condition_id: 2547,
subtype: 4,
flag_bytes: {
@ -8082,11 +8175,13 @@ mod tests {
semantic_preview: Some(
"Test Limited Track Building Amount == 18".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
crate::SmpLoadedPackedEventConditionRowSummary {
row_index: 4,
row_index: 5,
raw_condition_id: 1516,
subtype: 4,
flag_bytes: {
@ -8101,6 +8196,8 @@ mod tests {
semantic_preview: Some(
"Test Territory Access Cost == 750000".to_string(),
),
recovered_cargo_slot: None,
recovered_cargo_class: None,
requires_candidate_name_binding: false,
notes: vec![],
},
@ -8123,6 +8220,12 @@ mod tests {
comparator: RuntimeConditionComparator::Eq,
value: 250000,
},
RuntimeCondition::CargoProductionSlotThreshold {
slot: 1,
label: "Cargo Production Slot 1".to_string(),
comparator: RuntimeConditionComparator::Eq,
value: 125,
},
RuntimeCondition::CargoProductionTotalThreshold {
comparator: RuntimeConditionComparator::Eq,
value: 125,