3 Commits

Author SHA1 Message Date
3457dcb5df Add serde serialize support for script type 2026-04-12 11:44:40 +08:00
73059190d2 Fix overflow problem 2026-04-12 10:54:34 +08:00
d21e8c04d2 correct is_this_format document 2026-04-12 07:32:02 +08:00
3 changed files with 5 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ pub trait ScriptBuilder: std::fmt::Debug {
/// Checks if the given filename and buffer match this script format.
/// * `filename` - The name of the file to check.
/// * `buf` - The buffer containing the script data.
/// * `buf_len` - The length of the buffer.
/// * `buf_len` - The length of the valid data in the buffer (it MUST <= buf.len()).
///
/// Returns a score (0-255) indicating how well the format matches.
/// A higher score means a better match.

View File

@@ -5,6 +5,7 @@ use crate::scripts::base::*;
use crate::types::*;
use crate::utils::encoding::{decode_to_string, encode_string};
use anyhow::Result;
use overf::overflowing;
#[derive(Debug)]
/// Circus MES Script Builder
@@ -51,13 +52,13 @@ fn try_parse_header(mut data: MemReaderRef<'_>) -> Result<u8> {
let head0 = data.read_i32()?;
let head1 = data.read_i32()?;
if head1 == 0x3 {
let offset = head0 as u64 * 0x6 + 0x4;
let offset = overflowing!(head0 as u64 * 0x6 + 0x4);
let version = data.peek_u16_at(offset)?;
if ScriptInfo::query_by_version(version).is_some() {
return Ok(10);
}
} else {
let offset = head0 as u64 * 0x4 + 0x4;
let offset = overflowing!(head0 as u64 * 0x4 + 0x4);
let version = data.peek_u16_at(offset)?;
if ScriptInfo::query_by_version(version).is_some() {
return Ok(10);

View File

@@ -669,7 +669,7 @@ fn default_artemis_asb_end_tags() -> std::sync::Arc<std::collections::HashSet<St
)
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
/// Script type
pub enum ScriptType {
#[cfg(feature = "artemis")]