Expose save-world issue state in summaries
This commit is contained in:
parent
40078707c8
commit
77c847afba
2 changed files with 203 additions and 0 deletions
|
|
@ -60,6 +60,20 @@ pub struct ExpectedRuntimeSummary {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub world_restore_territory_access_cost: Option<u32>,
|
pub world_restore_territory_access_cost: Option<u32>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub world_restore_issue_37_value: Option<u32>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_issue_37_multiplier_raw_u32: Option<u32>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_issue_37_multiplier_value_f32_text: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_economic_tuning_mirror_raw_u32: Option<u32>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_economic_tuning_mirror_value_f32_text: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_economic_tuning_lane_count: Option<usize>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub world_restore_economic_tuning_lane_value_f32_text: Option<Vec<String>>,
|
||||||
|
#[serde(default)]
|
||||||
pub world_restore_absolute_counter_restore_kind: Option<String>,
|
pub world_restore_absolute_counter_restore_kind: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub world_restore_absolute_counter_adjustment_context: Option<String>,
|
pub world_restore_absolute_counter_adjustment_context: Option<String>,
|
||||||
|
|
@ -419,6 +433,70 @@ impl ExpectedRuntimeSummary {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(value) = self.world_restore_issue_37_value {
|
||||||
|
if actual.world_restore_issue_37_value != Some(value) {
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_issue_37_value mismatch: expected {value}, got {:?}",
|
||||||
|
actual.world_restore_issue_37_value
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(value) = self.world_restore_issue_37_multiplier_raw_u32 {
|
||||||
|
if actual.world_restore_issue_37_multiplier_raw_u32 != Some(value) {
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_issue_37_multiplier_raw_u32 mismatch: expected {value}, got {:?}",
|
||||||
|
actual.world_restore_issue_37_multiplier_raw_u32
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(value) = &self.world_restore_issue_37_multiplier_value_f32_text {
|
||||||
|
if actual
|
||||||
|
.world_restore_issue_37_multiplier_value_f32_text
|
||||||
|
.as_ref()
|
||||||
|
!= Some(value)
|
||||||
|
{
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_issue_37_multiplier_value_f32_text mismatch: expected {value:?}, got {:?}",
|
||||||
|
actual.world_restore_issue_37_multiplier_value_f32_text
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(value) = self.world_restore_economic_tuning_mirror_raw_u32 {
|
||||||
|
if actual.world_restore_economic_tuning_mirror_raw_u32 != Some(value) {
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_economic_tuning_mirror_raw_u32 mismatch: expected {value}, got {:?}",
|
||||||
|
actual.world_restore_economic_tuning_mirror_raw_u32
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(value) = &self.world_restore_economic_tuning_mirror_value_f32_text {
|
||||||
|
if actual
|
||||||
|
.world_restore_economic_tuning_mirror_value_f32_text
|
||||||
|
.as_ref()
|
||||||
|
!= Some(value)
|
||||||
|
{
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_economic_tuning_mirror_value_f32_text mismatch: expected {value:?}, got {:?}",
|
||||||
|
actual.world_restore_economic_tuning_mirror_value_f32_text
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(count) = self.world_restore_economic_tuning_lane_count {
|
||||||
|
if actual.world_restore_economic_tuning_lane_count != count {
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_economic_tuning_lane_count mismatch: expected {count}, got {}",
|
||||||
|
actual.world_restore_economic_tuning_lane_count
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(values) = &self.world_restore_economic_tuning_lane_value_f32_text {
|
||||||
|
if &actual.world_restore_economic_tuning_lane_value_f32_text != values {
|
||||||
|
mismatches.push(format!(
|
||||||
|
"world_restore_economic_tuning_lane_value_f32_text mismatch: expected {values:?}, got {:?}",
|
||||||
|
actual.world_restore_economic_tuning_lane_value_f32_text
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(kind) = &self.world_restore_absolute_counter_restore_kind {
|
if let Some(kind) = &self.world_restore_absolute_counter_restore_kind {
|
||||||
if actual.world_restore_absolute_counter_restore_kind.as_ref() != Some(kind) {
|
if actual.world_restore_absolute_counter_restore_kind.as_ref() != Some(kind) {
|
||||||
mismatches.push(format!(
|
mismatches.push(format!(
|
||||||
|
|
@ -1297,6 +1375,7 @@ mod tests {
|
||||||
"world_flag_count": 1,
|
"world_flag_count": 1,
|
||||||
"company_count": 1,
|
"company_count": 1,
|
||||||
"event_runtime_record_count": 0,
|
"event_runtime_record_count": 0,
|
||||||
|
"world_restore_economic_tuning_lane_count": 0,
|
||||||
"total_company_cash": 250000
|
"total_company_cash": 250000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,13 @@ pub struct RuntimeSummary {
|
||||||
pub world_restore_limited_track_building_amount: Option<i32>,
|
pub world_restore_limited_track_building_amount: Option<i32>,
|
||||||
pub world_restore_economic_status_code: Option<i32>,
|
pub world_restore_economic_status_code: Option<i32>,
|
||||||
pub world_restore_territory_access_cost: Option<u32>,
|
pub world_restore_territory_access_cost: Option<u32>,
|
||||||
|
pub world_restore_issue_37_value: Option<u32>,
|
||||||
|
pub world_restore_issue_37_multiplier_raw_u32: Option<u32>,
|
||||||
|
pub world_restore_issue_37_multiplier_value_f32_text: Option<String>,
|
||||||
|
pub world_restore_economic_tuning_mirror_raw_u32: Option<u32>,
|
||||||
|
pub world_restore_economic_tuning_mirror_value_f32_text: Option<String>,
|
||||||
|
pub world_restore_economic_tuning_lane_count: usize,
|
||||||
|
pub world_restore_economic_tuning_lane_value_f32_text: Vec<String>,
|
||||||
pub world_restore_absolute_counter_restore_kind: Option<String>,
|
pub world_restore_absolute_counter_restore_kind: Option<String>,
|
||||||
pub world_restore_absolute_counter_adjustment_context: Option<String>,
|
pub world_restore_absolute_counter_adjustment_context: Option<String>,
|
||||||
pub metadata_count: usize,
|
pub metadata_count: usize,
|
||||||
|
|
@ -169,6 +176,29 @@ impl RuntimeSummary {
|
||||||
.limited_track_building_amount,
|
.limited_track_building_amount,
|
||||||
world_restore_economic_status_code: state.world_restore.economic_status_code,
|
world_restore_economic_status_code: state.world_restore.economic_status_code,
|
||||||
world_restore_territory_access_cost: state.world_restore.territory_access_cost,
|
world_restore_territory_access_cost: state.world_restore.territory_access_cost,
|
||||||
|
world_restore_issue_37_value: state.world_restore.issue_37_value,
|
||||||
|
world_restore_issue_37_multiplier_raw_u32: state
|
||||||
|
.world_restore
|
||||||
|
.issue_37_multiplier_raw_u32,
|
||||||
|
world_restore_issue_37_multiplier_value_f32_text: state
|
||||||
|
.world_restore
|
||||||
|
.issue_37_multiplier_value_f32_text
|
||||||
|
.clone(),
|
||||||
|
world_restore_economic_tuning_mirror_raw_u32: state
|
||||||
|
.world_restore
|
||||||
|
.economic_tuning_mirror_raw_u32,
|
||||||
|
world_restore_economic_tuning_mirror_value_f32_text: state
|
||||||
|
.world_restore
|
||||||
|
.economic_tuning_mirror_value_f32_text
|
||||||
|
.clone(),
|
||||||
|
world_restore_economic_tuning_lane_count: state
|
||||||
|
.world_restore
|
||||||
|
.economic_tuning_lane_raw_u32
|
||||||
|
.len(),
|
||||||
|
world_restore_economic_tuning_lane_value_f32_text: state
|
||||||
|
.world_restore
|
||||||
|
.economic_tuning_lane_value_f32_text
|
||||||
|
.clone(),
|
||||||
world_restore_absolute_counter_restore_kind: state
|
world_restore_absolute_counter_restore_kind: state
|
||||||
.world_restore
|
.world_restore
|
||||||
.absolute_counter_restore_kind
|
.absolute_counter_restore_kind
|
||||||
|
|
@ -995,6 +1025,100 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn summarizes_save_world_issue_and_economic_tuning_restore_state() {
|
||||||
|
let state = RuntimeState {
|
||||||
|
calendar: CalendarPoint {
|
||||||
|
year: 1830,
|
||||||
|
month_slot: 0,
|
||||||
|
phase_slot: 0,
|
||||||
|
tick_slot: 0,
|
||||||
|
},
|
||||||
|
world_flags: BTreeMap::new(),
|
||||||
|
save_profile: RuntimeSaveProfileState::default(),
|
||||||
|
world_restore: RuntimeWorldRestoreState {
|
||||||
|
issue_37_value: Some(3),
|
||||||
|
issue_37_multiplier_raw_u32: Some(0x3d75c28f),
|
||||||
|
issue_37_multiplier_value_f32_text: Some("0.06".to_string()),
|
||||||
|
economic_tuning_mirror_raw_u32: Some(0x3f46dff5),
|
||||||
|
economic_tuning_mirror_value_f32_text: Some("0.7766201".to_string()),
|
||||||
|
economic_tuning_lane_raw_u32: vec![
|
||||||
|
0x3f400000, 0x3be56042, 0x3c03126f, 0x3c1374bc, 0x3c23d70a, 0x3c23d70a,
|
||||||
|
],
|
||||||
|
economic_tuning_lane_value_f32_text: vec![
|
||||||
|
"0.75".to_string(),
|
||||||
|
"0.007".to_string(),
|
||||||
|
"0.008".to_string(),
|
||||||
|
"0.009".to_string(),
|
||||||
|
"0.01".to_string(),
|
||||||
|
"0.01".to_string(),
|
||||||
|
],
|
||||||
|
..RuntimeWorldRestoreState::default()
|
||||||
|
},
|
||||||
|
metadata: BTreeMap::new(),
|
||||||
|
companies: Vec::new(),
|
||||||
|
selected_company_id: None,
|
||||||
|
players: Vec::new(),
|
||||||
|
selected_player_id: None,
|
||||||
|
chairman_profiles: Vec::new(),
|
||||||
|
selected_chairman_profile_id: None,
|
||||||
|
trains: Vec::new(),
|
||||||
|
locomotive_catalog: Vec::new(),
|
||||||
|
cargo_catalog: Vec::new(),
|
||||||
|
territories: Vec::new(),
|
||||||
|
company_territory_track_piece_counts: Vec::new(),
|
||||||
|
company_territory_access: Vec::new(),
|
||||||
|
packed_event_collection: None,
|
||||||
|
event_runtime_records: Vec::new(),
|
||||||
|
candidate_availability: BTreeMap::new(),
|
||||||
|
named_locomotive_availability: BTreeMap::new(),
|
||||||
|
named_locomotive_cost: BTreeMap::new(),
|
||||||
|
cargo_production_overrides: BTreeMap::new(),
|
||||||
|
named_cargo_price_overrides: BTreeMap::new(),
|
||||||
|
all_cargo_price_override: None,
|
||||||
|
named_cargo_production_overrides: BTreeMap::new(),
|
||||||
|
all_cargo_production_override: None,
|
||||||
|
factory_cargo_production_override: None,
|
||||||
|
farm_mine_cargo_production_override: None,
|
||||||
|
world_runtime_variables: BTreeMap::new(),
|
||||||
|
company_runtime_variables: BTreeMap::new(),
|
||||||
|
player_runtime_variables: BTreeMap::new(),
|
||||||
|
territory_runtime_variables: BTreeMap::new(),
|
||||||
|
world_scalar_overrides: BTreeMap::new(),
|
||||||
|
special_conditions: BTreeMap::new(),
|
||||||
|
service_state: RuntimeServiceState::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let summary = RuntimeSummary::from_state(&state);
|
||||||
|
|
||||||
|
assert_eq!(summary.world_restore_issue_37_value, Some(3));
|
||||||
|
assert_eq!(
|
||||||
|
summary.world_restore_issue_37_multiplier_raw_u32,
|
||||||
|
Some(0x3d75c28f)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
summary
|
||||||
|
.world_restore_issue_37_multiplier_value_f32_text
|
||||||
|
.as_deref(),
|
||||||
|
Some("0.06")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
summary.world_restore_economic_tuning_mirror_raw_u32,
|
||||||
|
Some(0x3f46dff5)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
summary
|
||||||
|
.world_restore_economic_tuning_mirror_value_f32_text
|
||||||
|
.as_deref(),
|
||||||
|
Some("0.7766201")
|
||||||
|
);
|
||||||
|
assert_eq!(summary.world_restore_economic_tuning_lane_count, 6);
|
||||||
|
assert_eq!(
|
||||||
|
summary.world_restore_economic_tuning_lane_value_f32_text,
|
||||||
|
vec!["0.75", "0.007", "0.008", "0.009", "0.01", "0.01"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn counts_active_companies_separately_from_total_companies() {
|
fn counts_active_companies_separately_from_total_companies() {
|
||||||
let state = RuntimeState {
|
let state = RuntimeState {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue