mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-07 05:18:44 +08:00
Changed some scripts dumped JSON to pretty print JSON
Formated code Add protect when read vector of data
This commit is contained in:
@@ -133,7 +133,7 @@ impl Script for BGIBsiScript {
|
||||
serde_yaml_ng::to_string(&self.data)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to YAML: {}", e))?
|
||||
} else {
|
||||
serde_json::to_string(&self.data)
|
||||
serde_json::to_string_pretty(&self.data)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to JSON: {}", e))?
|
||||
};
|
||||
let mut writer = crate::utils::files::write_file(filename)?;
|
||||
|
||||
@@ -367,7 +367,7 @@ impl Script for CstlScript {
|
||||
serde_yaml_ng::to_string(&d)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to YAML: {}", e))?
|
||||
} else {
|
||||
serde_json::to_string(&d)
|
||||
serde_json::to_string_pretty(&d)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to JSON: {}", e))?
|
||||
};
|
||||
let s = encode_string(encoding, &s, false)?;
|
||||
|
||||
@@ -490,7 +490,7 @@ impl Script for RldScript {
|
||||
serde_yaml_ng::to_string(&names)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to YAML: {}", e))?
|
||||
} else {
|
||||
serde_json::to_string(&names)
|
||||
serde_json::to_string_pretty(&names)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to JSON: {}", e))?
|
||||
}
|
||||
} else {
|
||||
@@ -498,7 +498,7 @@ impl Script for RldScript {
|
||||
serde_yaml_ng::to_string(&self.ops)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to YAML: {}", e))?
|
||||
} else {
|
||||
serde_json::to_string(&self.ops)
|
||||
serde_json::to_string_pretty(&self.ops)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to serialize to JSON: {}", e))?
|
||||
}
|
||||
};
|
||||
|
||||
@@ -190,7 +190,10 @@ impl Data {
|
||||
|
||||
let start_pos = func_starts.iter().position(|&s| s == speak_idx);
|
||||
if let Some(pos) = start_pos {
|
||||
let end = func_starts.get(pos + 1).copied().unwrap_or(self.functions.len());
|
||||
let end = func_starts
|
||||
.get(pos + 1)
|
||||
.copied()
|
||||
.unwrap_or(self.functions.len());
|
||||
let names: Vec<String> = (speak_idx..end)
|
||||
.filter(|&i| self.functions[i].opcode == 0x0e)
|
||||
.filter_map(|i| match self.functions[i].operands.first() {
|
||||
|
||||
Reference in New Issue
Block a user