Fix bgi script import bug

This commit is contained in:
2025-08-02 15:52:05 +08:00
parent c0d75473f7
commit 3cfce1906e
2 changed files with 20 additions and 1 deletions

View File

@@ -214,6 +214,12 @@ pub enum BGIStringType {
Internal,
}
impl BGIStringType {
pub fn is_internal(&self) -> bool {
matches!(self, BGIStringType::Internal)
}
}
#[derive(Debug, Clone)]
pub struct BGIString {
pub offset: usize,

View File

@@ -166,7 +166,7 @@ impl Script for BGIScript {
cur_mes = mes.next();
}
}
if str_map.contains_key(&curs.address) {
if str_map.contains_key(&curs.address) && curs.typ.is_internal() {
continue;
}
let nmes = match curs.typ {
@@ -204,6 +204,19 @@ impl Script for BGIScript {
mes
}
};
match str_map.get(&curs.address) {
Some(existed) => {
if existed != &nmes {
eprintln!(
"Warning: Duplicate string at address {} with different content. Original: {}, New: {}. New string will be ignored. If you want to import it, use --bgi-import-duplicate.",
curs.address, existed, nmes
);
crate::COUNTER.inc_warning();
}
continue;
}
None => {}
}
str_map.insert(curs.address, nmes);
}
if cur_mes.is_some() || mes.next().is_some() {