Classify machine shop Tier-2 selector outlier
This commit is contained in:
parent
2158d1e39e
commit
7894c52aea
5 changed files with 6714 additions and 278 deletions
|
|
@ -96,6 +96,7 @@ pub struct BuildingTypeRecoveredTableSummary {
|
|||
pub nonzero_bty_header_name_0x40_summaries: Vec<BuildingTypeBtyHeaderNameSummary>,
|
||||
pub nonzero_bty_header_name_0x5e_summaries: Vec<BuildingTypeBtyHeaderNameSummary>,
|
||||
pub nonzero_bty_header_name_0x7c_summaries: Vec<BuildingTypeBtyHeaderNameSummary>,
|
||||
pub nonzero_bty_header_alias_selector_summaries: Vec<BuildingTypeBtyHeaderAliasSelectorSummary>,
|
||||
pub bty_header_name_0x5e_dword_summaries: Vec<BuildingTypeBtyHeaderNameDwordSummary>,
|
||||
pub bty_name_0x5e_bca_selector_summaries: Vec<BuildingTypeBtyNameBcaSelectorSummary>,
|
||||
}
|
||||
|
|
@ -126,6 +127,21 @@ pub struct BuildingTypeBtyHeaderNameDwordSummary {
|
|||
pub sample_file_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BuildingTypeBtyHeaderAliasSelectorSummary {
|
||||
pub name_0x40: String,
|
||||
pub name_0x5e: String,
|
||||
pub name_0x7c: String,
|
||||
pub dword_0xbb: u32,
|
||||
pub dword_0xbb_hex: String,
|
||||
pub byte_0xb8_hex: String,
|
||||
pub byte_0xb9_hex: String,
|
||||
pub byte_0xba_hex: String,
|
||||
pub byte_0xbb_hex: String,
|
||||
pub file_count: usize,
|
||||
pub sample_file_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BuildingTypeBtyNameBcaSelectorSummary {
|
||||
pub header_offset_hex: String,
|
||||
|
|
@ -507,6 +523,8 @@ fn summarize_recovered_table_families(
|
|||
summarize_nonzero_bty_header_name_lane(files, 0x5e, |probe| &probe.name_0x5e);
|
||||
let nonzero_bty_header_name_0x7c_summaries =
|
||||
summarize_nonzero_bty_header_name_lane(files, 0x7c, |probe| &probe.name_0x7c);
|
||||
let nonzero_bty_header_alias_selector_summaries =
|
||||
summarize_nonzero_bty_header_alias_selector_patterns(entries, files);
|
||||
let bty_header_name_0x5e_dword_summaries =
|
||||
summarize_bty_header_name_lane_by_dword(files, 0x5e, |probe| &probe.name_0x5e);
|
||||
let bty_name_0x5e_bca_selector_summaries =
|
||||
|
|
@ -528,6 +546,7 @@ fn summarize_recovered_table_families(
|
|||
nonzero_bty_header_name_0x40_summaries,
|
||||
nonzero_bty_header_name_0x5e_summaries,
|
||||
nonzero_bty_header_name_0x7c_summaries,
|
||||
nonzero_bty_header_alias_selector_summaries,
|
||||
bty_header_name_0x5e_dword_summaries,
|
||||
bty_name_0x5e_bca_selector_summaries,
|
||||
}
|
||||
|
|
@ -700,6 +719,112 @@ fn summarize_bty_name_0x5e_bca_selector_patterns(
|
|||
summaries
|
||||
}
|
||||
|
||||
fn summarize_nonzero_bty_header_alias_selector_patterns(
|
||||
entries: &[BuildingTypeSourceEntry],
|
||||
files: &[BuildingTypeSourceFile],
|
||||
) -> Vec<BuildingTypeBtyHeaderAliasSelectorSummary> {
|
||||
let file_by_name = files
|
||||
.iter()
|
||||
.map(|file| (file.file_name.as_str(), file))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
let mut groups = BTreeMap::<
|
||||
(String, String, String, u32, String, String, String, String),
|
||||
Vec<String>,
|
||||
>::new();
|
||||
|
||||
for entry in entries {
|
||||
let bty_file = entry
|
||||
.file_names
|
||||
.iter()
|
||||
.filter_map(|name| file_by_name.get(name.as_str()))
|
||||
.find(|file| matches!(file.source_kind, BuildingTypeSourceKind::Bty));
|
||||
let bca_file = entry
|
||||
.file_names
|
||||
.iter()
|
||||
.filter_map(|name| file_by_name.get(name.as_str()))
|
||||
.find(|file| matches!(file.source_kind, BuildingTypeSourceKind::Bca));
|
||||
let (Some(bty_file), Some(bca_file)) = (bty_file, bca_file) else {
|
||||
continue;
|
||||
};
|
||||
let (Some(bty_probe), Some(bca_probe)) =
|
||||
(&bty_file.bty_header_probe, &bca_file.bca_selector_probe)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
if bty_probe.dword_0xbb == 0 {
|
||||
continue;
|
||||
}
|
||||
let name_0x40 = bty_probe.name_0x40.trim();
|
||||
let name_0x5e = bty_probe.name_0x5e.trim();
|
||||
let name_0x7c = bty_probe.name_0x7c.trim();
|
||||
if name_0x40.is_empty() || name_0x5e.is_empty() || name_0x7c.is_empty() {
|
||||
continue;
|
||||
}
|
||||
groups
|
||||
.entry((
|
||||
name_0x40.to_string(),
|
||||
name_0x5e.to_string(),
|
||||
name_0x7c.to_string(),
|
||||
bty_probe.dword_0xbb,
|
||||
bca_probe.byte_0xb8_hex.clone(),
|
||||
bca_probe.byte_0xb9_hex.clone(),
|
||||
bca_probe.byte_0xba_hex.clone(),
|
||||
bca_probe.byte_0xbb_hex.clone(),
|
||||
))
|
||||
.or_default()
|
||||
.push(bty_file.file_name.clone());
|
||||
}
|
||||
|
||||
let mut summaries = groups
|
||||
.into_iter()
|
||||
.map(
|
||||
|(
|
||||
(
|
||||
name_0x40,
|
||||
name_0x5e,
|
||||
name_0x7c,
|
||||
dword_0xbb,
|
||||
byte_0xb8_hex,
|
||||
byte_0xb9_hex,
|
||||
byte_0xba_hex,
|
||||
byte_0xbb_hex,
|
||||
),
|
||||
mut file_names,
|
||||
)| {
|
||||
file_names.sort();
|
||||
file_names.dedup();
|
||||
BuildingTypeBtyHeaderAliasSelectorSummary {
|
||||
name_0x40,
|
||||
name_0x5e,
|
||||
name_0x7c,
|
||||
dword_0xbb,
|
||||
dword_0xbb_hex: format!("0x{dword_0xbb:08x}"),
|
||||
byte_0xb8_hex,
|
||||
byte_0xb9_hex,
|
||||
byte_0xba_hex,
|
||||
byte_0xbb_hex,
|
||||
file_count: file_names.len(),
|
||||
sample_file_names: file_names.into_iter().take(24).collect(),
|
||||
}
|
||||
},
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
summaries.sort_by(|left, right| {
|
||||
right
|
||||
.file_count
|
||||
.cmp(&left.file_count)
|
||||
.then_with(|| left.dword_0xbb.cmp(&right.dword_0xbb))
|
||||
.then_with(|| left.name_0x40.cmp(&right.name_0x40))
|
||||
.then_with(|| left.name_0x5e.cmp(&right.name_0x5e))
|
||||
.then_with(|| left.name_0x7c.cmp(&right.name_0x7c))
|
||||
.then_with(|| left.byte_0xb8_hex.cmp(&right.byte_0xb8_hex))
|
||||
.then_with(|| left.byte_0xb9_hex.cmp(&right.byte_0xb9_hex))
|
||||
.then_with(|| left.byte_0xba_hex.cmp(&right.byte_0xba_hex))
|
||||
.then_with(|| left.byte_0xbb_hex.cmp(&right.byte_0xbb_hex))
|
||||
});
|
||||
summaries
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
struct BuildingBindingArtifact {
|
||||
bindings: Vec<BuildingBindingRow>,
|
||||
|
|
@ -908,6 +1033,22 @@ mod tests {
|
|||
sample_file_names: vec!["Port.bty".to_string()],
|
||||
}]
|
||||
);
|
||||
assert_eq!(
|
||||
summary.nonzero_bty_header_alias_selector_summaries,
|
||||
vec![BuildingTypeBtyHeaderAliasSelectorSummary {
|
||||
name_0x40: "Port".to_string(),
|
||||
name_0x5e: "TextileMill".to_string(),
|
||||
name_0x7c: "Port".to_string(),
|
||||
dword_0xbb: 0x01f4,
|
||||
dword_0xbb_hex: "0x000001f4".to_string(),
|
||||
byte_0xb8_hex: "0x00".to_string(),
|
||||
byte_0xb9_hex: "0x00".to_string(),
|
||||
byte_0xba_hex: "0x00".to_string(),
|
||||
byte_0xbb_hex: "0x00".to_string(),
|
||||
file_count: 1,
|
||||
sample_file_names: vec!["Port.bty".to_string()],
|
||||
}]
|
||||
);
|
||||
assert_eq!(
|
||||
summary.bty_name_0x5e_bca_selector_summaries,
|
||||
vec![BuildingTypeBtyNameBcaSelectorSummary {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue