mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-22 20:04:20 +08:00
Fix bgi script import bug
This commit is contained in:
@@ -214,6 +214,12 @@ pub enum BGIStringType {
|
|||||||
Internal,
|
Internal,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BGIStringType {
|
||||||
|
pub fn is_internal(&self) -> bool {
|
||||||
|
matches!(self, BGIStringType::Internal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BGIString {
|
pub struct BGIString {
|
||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ impl Script for BGIScript {
|
|||||||
cur_mes = mes.next();
|
cur_mes = mes.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if str_map.contains_key(&curs.address) {
|
if str_map.contains_key(&curs.address) && curs.typ.is_internal() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let nmes = match curs.typ {
|
let nmes = match curs.typ {
|
||||||
@@ -204,6 +204,19 @@ impl Script for BGIScript {
|
|||||||
mes
|
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);
|
str_map.insert(curs.address, nmes);
|
||||||
}
|
}
|
||||||
if cur_mes.is_some() || mes.next().is_some() {
|
if cur_mes.is_some() || mes.next().is_some() {
|
||||||
|
|||||||
Reference in New Issue
Block a user