Rehost annual stock repurchase policy branch

This commit is contained in:
Jan Petykiewicz 2026-04-18 00:28:54 -07:00
commit 0658626a57
8 changed files with 592 additions and 17 deletions

View file

@ -137,6 +137,7 @@ const RT3_SAVE_WORLD_BLOCK_STOCK_POLICY_RELATIVE_OFFSET: usize = 0x4a83;
const RT3_SAVE_WORLD_BLOCK_BOND_POLICY_RELATIVE_OFFSET: usize = 0x4a87;
const RT3_SAVE_WORLD_BLOCK_BANKRUPTCY_POLICY_RELATIVE_OFFSET: usize = 0x4a8b;
const RT3_SAVE_WORLD_BLOCK_DIVIDEND_POLICY_RELATIVE_OFFSET: usize = 0x4a8f;
const RT3_SAVE_WORLD_BLOCK_BUILDING_DENSITY_GROWTH_RELATIVE_OFFSET: usize = 0x4c78;
const RT3_SAVE_WORLD_BLOCK_ECONOMIC_TUNING_MIRROR_RELATIVE_OFFSET: usize = 0x0bda;
const RT3_SAVE_WORLD_BLOCK_ECONOMIC_TUNING_PRIMARY_RELATIVE_OFFSETS: [usize; 6] =
[0x0bde, 0x0be2, 0x0be6, 0x0bea, 0x0bee, 0x0bf2];
@ -1584,6 +1585,7 @@ pub struct SmpSaveWorldFinanceNeighborhoodProbe {
pub bankruptcy_policy_raw_hex: String,
pub dividend_policy_raw_u8: u8,
pub dividend_policy_raw_hex: String,
pub building_density_growth_setting_lane: SmpSaveDwordCandidate,
pub dword_candidates: Vec<SmpSaveDwordCandidate>,
pub evidence: Vec<String>,
}
@ -2276,6 +2278,8 @@ pub struct SmpLoadedWorldFinanceNeighborhoodState {
pub bankruptcy_policy_raw_hex: String,
pub dividend_policy_raw_u8: u8,
pub dividend_policy_raw_hex: String,
pub building_density_growth_setting_raw_u32: u32,
pub building_density_growth_setting_raw_hex: String,
pub labels: Vec<String>,
pub relative_offsets: Vec<usize>,
pub relative_offset_hex: Vec<String>,
@ -2345,6 +2349,8 @@ pub struct SmpLoadedChairmanProfileEntry {
#[serde(default)]
pub purchasing_power_total: i64,
#[serde(default)]
pub personality_byte_0x291: Option<u8>,
#[serde(default)]
pub issue_opinion_terms_raw_i32: Vec<i32>,
}
@ -2457,6 +2463,8 @@ pub struct SmpSaveChairmanRecordAnalysisEntry {
pub derived_net_worth_share_price_total: Option<i64>,
#[serde(default)]
pub derived_cached_purchasing_power_total: Option<i64>,
pub personality_byte_0x291: u8,
pub personality_byte_0x291_hex: String,
#[serde(default)]
pub cached_scalar_candidates: Vec<SmpSaveScalarCandidate>,
}
@ -3255,6 +3263,10 @@ pub fn inspect_save_company_and_chairman_analysis_bytes(
&bytes,
record_offset + SAVE_CHAIRMAN_RECORD_LINKED_COMPANY_OFFSET,
)?;
let personality_byte_0x291 = read_u8_at(
&bytes,
record_offset + SAVE_CHAIRMAN_RECORD_PERSONALITY_BYTE_0X291_OFFSET,
)?;
let mut holdings_by_company = BTreeMap::new();
for company_id in 1..=company_id_bound {
let slot_offset = record_offset
@ -3293,6 +3305,8 @@ pub fn inspect_save_company_and_chairman_analysis_bytes(
derived_holdings_share_price_total,
derived_net_worth_share_price_total,
derived_cached_purchasing_power_total,
personality_byte_0x291,
personality_byte_0x291_hex: format!("0x{personality_byte_0x291:02x}"),
cached_scalar_candidates,
});
}
@ -3528,6 +3542,11 @@ fn derive_loaded_world_finance_neighborhood_state_from_probe(
bankruptcy_policy_raw_hex: probe.bankruptcy_policy_raw_hex.clone(),
dividend_policy_raw_u8: probe.dividend_policy_raw_u8,
dividend_policy_raw_hex: probe.dividend_policy_raw_hex.clone(),
building_density_growth_setting_raw_u32: probe.building_density_growth_setting_lane.raw_u32,
building_density_growth_setting_raw_hex: probe
.building_density_growth_setting_lane
.raw_u32_hex
.clone(),
labels: probe
.dword_candidates
.iter()
@ -3688,6 +3707,7 @@ const SAVE_CHAIRMAN_RECORD_HOLDINGS_BASE_OFFSET: usize = 0x15d;
const SAVE_CHAIRMAN_RECORD_LINKED_COMPANY_OFFSET: usize = 0x1dd;
const SAVE_CHAIRMAN_RECORD_CACHE_0_OFFSET: usize = 0x1e9;
const SAVE_CHAIRMAN_RECORD_CACHE_1_OFFSET: usize = 0x1f1;
const SAVE_CHAIRMAN_RECORD_PERSONALITY_BYTE_0X291_OFFSET: usize = 0x291;
const SAVE_CHAIRMAN_RECORD_ISSUE_OPINION_TERMS_OFFSET: usize = 0x35b;
const SAVE_CHAIRMAN_RECORD_ISSUE_OPINION_TERM_COUNT: usize =
RT3_SAVE_WORLD_BLOCK_ISSUE_OPINION_TERM_COUNT;
@ -4364,6 +4384,10 @@ fn parse_save_chairman_profile_table_probe(
bytes,
record_offset + SAVE_CHAIRMAN_RECORD_LINKED_COMPANY_OFFSET,
)?;
let personality_byte_0x291 = read_u8_at(
bytes,
record_offset + SAVE_CHAIRMAN_RECORD_PERSONALITY_BYTE_0X291_OFFSET,
)?;
let cache_0 = round_f64_to_i64(read_f64_at(
bytes,
record_offset + SAVE_CHAIRMAN_RECORD_CACHE_0_OFFSET,
@ -4409,6 +4433,7 @@ fn parse_save_chairman_profile_table_probe(
holdings_value_total,
net_worth_total,
purchasing_power_total,
personality_byte_0x291: Some(personality_byte_0x291),
issue_opinion_terms_raw_i32,
});
}
@ -9144,6 +9169,12 @@ fn parse_save_world_finance_neighborhood_probe(
bytes,
payload_offset + RT3_SAVE_WORLD_BLOCK_DIVIDEND_POLICY_RELATIVE_OFFSET,
)?;
let building_density_growth_setting_lane = build_save_dword_candidate(
bytes,
payload_offset,
"building_density_growth_setting",
RT3_SAVE_WORLD_BLOCK_BUILDING_DENSITY_GROWTH_RELATIVE_OFFSET,
)?;
let dword_candidates =
build_save_world_finance_neighborhood_candidates(bytes, payload_offset)?;
@ -9171,6 +9202,7 @@ fn parse_save_world_finance_neighborhood_probe(
bankruptcy_policy_raw_hex: format!("0x{bankruptcy_policy_raw_u8:02x}"),
dividend_policy_raw_u8,
dividend_policy_raw_hex: format!("0x{dividend_policy_raw_u8:02x}"),
building_density_growth_setting_lane,
dword_candidates,
evidence: vec![
format!(
@ -9192,6 +9224,10 @@ fn parse_save_world_finance_neighborhood_probe(
RT3_SAVE_WORLD_BLOCK_BANKRUPTCY_POLICY_RELATIVE_OFFSET,
RT3_SAVE_WORLD_BLOCK_DIVIDEND_POLICY_RELATIVE_OFFSET
),
format!(
"payload +0x{:x} carries the fixed-world building-density growth setting mirrored from `[world+0x4c7c]`, which the annual repurchase and dividend policy helpers both read directly",
RT3_SAVE_WORLD_BLOCK_BUILDING_DENSITY_GROWTH_RELATIVE_OFFSET
),
"finance-neighborhood candidates cover the fixed dword strip around the grounded world calendar tuple, absolute-counter, selection-context, and issue-0x37 lanes so broader finance reader closure can build on one rehosted owner surface.".to_string(),
],
});
@ -15931,6 +15967,9 @@ mod tests {
bytes[payload_offset + RT3_SAVE_WORLD_BLOCK_BOND_POLICY_RELATIVE_OFFSET] = 2;
bytes[payload_offset + RT3_SAVE_WORLD_BLOCK_BANKRUPTCY_POLICY_RELATIVE_OFFSET] = 3;
bytes[payload_offset + RT3_SAVE_WORLD_BLOCK_DIVIDEND_POLICY_RELATIVE_OFFSET] = 4;
bytes[payload_offset + RT3_SAVE_WORLD_BLOCK_BUILDING_DENSITY_GROWTH_RELATIVE_OFFSET
..payload_offset + RT3_SAVE_WORLD_BLOCK_BUILDING_DENSITY_GROWTH_RELATIVE_OFFSET + 4]
.copy_from_slice(&2u32.to_le_bytes());
let next_chunk_offset = payload_offset + RT3_SAVE_WORLD_BLOCK_LEN;
bytes[next_chunk_offset..next_chunk_offset + 4]
.copy_from_slice(&RT3_SAVE_WORLD_BLOCK_NEXT_CHUNK_TAG.to_le_bytes());
@ -15968,6 +16007,13 @@ mod tests {
assert_eq!(probe.bankruptcy_policy_raw_hex, "0x03");
assert_eq!(probe.dividend_policy_raw_u8, 4);
assert_eq!(probe.dividend_policy_raw_hex, "0x04");
assert_eq!(probe.building_density_growth_setting_lane.raw_u32, 2);
assert_eq!(
probe
.building_density_growth_setting_lane
.relative_offset_hex,
"0x4c78"
);
assert_eq!(probe.current_calendar_tuple_word_lane.value_i32, 1);
assert_eq!(
probe.current_calendar_tuple_word_2_lane.relative_offset_hex,
@ -16773,6 +16819,8 @@ mod tests {
bytes[record_offset + SAVE_CHAIRMAN_RECORD_LINKED_COMPANY_OFFSET
..record_offset + SAVE_CHAIRMAN_RECORD_LINKED_COMPANY_OFFSET + 4]
.copy_from_slice(&linked.to_le_bytes());
bytes[record_offset + SAVE_CHAIRMAN_RECORD_PERSONALITY_BYTE_0X291_OFFSET] =
(index as u8) + 10;
bytes[record_offset + SAVE_CHAIRMAN_RECORD_CACHE_0_OFFSET
..record_offset + SAVE_CHAIRMAN_RECORD_CACHE_0_OFFSET + 8]
.copy_from_slice(&cache0.to_le_bytes());
@ -16857,10 +16905,12 @@ mod tests {
assert_eq!(table.entries[0].current_cash, -107644);
assert_eq!(table.entries[0].holdings_value_total, 252508);
assert_eq!(table.entries[0].purchasing_power_total, 144864);
assert_eq!(table.entries[0].personality_byte_0x291, Some(10));
assert_eq!(table.entries[1].profile_id, 2);
assert_eq!(table.entries[1].company_holdings.get(&2), Some(&9000));
assert_eq!(table.entries[1].holdings_value_total, 822000);
assert_eq!(table.entries[1].purchasing_power_total, 1_009_282);
assert_eq!(table.entries[1].personality_byte_0x291, Some(11));
}
#[test]