mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-18 17:04:50 +08:00
Add HxCrypt
This commit is contained in:
@@ -12,7 +12,9 @@ pub trait ReadSeek: Read + Seek + std::fmt::Debug {}
|
||||
pub trait WriteSeek: Write + Seek {}
|
||||
|
||||
/// A trait for types that can be displayed in debug format and are also support downcasting.
|
||||
pub trait AnyDebug: std::fmt::Debug + std::any::Any {}
|
||||
pub trait AnyDebug: std::fmt::Debug + std::any::Any {
|
||||
fn as_any(&self) -> &dyn std::any::Any;
|
||||
}
|
||||
|
||||
/// A trait for reading in a stream with debug format.
|
||||
pub trait ReadDebug: Read + std::fmt::Debug {}
|
||||
@@ -23,8 +25,6 @@ impl<T: Read + std::fmt::Debug> ReadDebug for T {}
|
||||
|
||||
impl<T: Write + Seek> WriteSeek for T {}
|
||||
|
||||
impl<T: std::fmt::Debug + std::any::Any> AnyDebug for T {}
|
||||
|
||||
/// A trait for script builders.
|
||||
pub trait ScriptBuilder: std::fmt::Debug {
|
||||
/// Returns the default encoding for the script.
|
||||
|
||||
@@ -188,6 +188,12 @@ pub struct DatExtraInfo {
|
||||
pub name_len: usize,
|
||||
}
|
||||
|
||||
impl AnyDebug for DatExtraInfo {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Circus DAT Archive
|
||||
pub struct DatArchive<'b, T: Read + Seek + std::fmt::Debug + 'b> {
|
||||
|
||||
@@ -54,7 +54,7 @@ impl ScriptBuilder for PngImageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
/// Extra information for PNG image
|
||||
pub struct ExtraInfo {
|
||||
/// x offset
|
||||
@@ -63,6 +63,12 @@ pub struct ExtraInfo {
|
||||
pub offset_y: u32,
|
||||
}
|
||||
|
||||
impl AnyDebug for ExtraInfo {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PngImage {
|
||||
reader: MemReader,
|
||||
@@ -115,6 +121,6 @@ impl Script for PngImage {
|
||||
fn extra_info<'a>(&'a self) -> Option<Box<dyn AnyDebug + 'a>> {
|
||||
self.extra
|
||||
.as_ref()
|
||||
.map(|e| Box::new(e) as Box<dyn AnyDebug>)
|
||||
.map(|e| Box::new(e.clone()) as Box<dyn AnyDebug>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::consts::*;
|
||||
use super::crypt::Crypt;
|
||||
use crate::scripts::base::ReadSeek;
|
||||
use crate::scripts::base::{AnyDebug, ReadSeek};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -29,7 +29,8 @@ pub struct ArchiveItem {
|
||||
pub segments: Vec<Segment>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(unused)]
|
||||
pub struct Xp3Entry {
|
||||
pub name: String,
|
||||
pub flags: u32,
|
||||
@@ -39,6 +40,7 @@ pub struct Xp3Entry {
|
||||
pub timestamp: Option<u64>,
|
||||
pub segments: Vec<Segment>,
|
||||
pub extras: Vec<ExtraProp>,
|
||||
pub extra: Option<Arc<Box<dyn AnyDebug + Send + Sync>>>,
|
||||
}
|
||||
|
||||
impl Xp3Entry {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -284,6 +284,20 @@ enum CryptType {
|
||||
#[serde(default)]
|
||||
random_type: i32,
|
||||
},
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
HxCrypt {
|
||||
#[serde(flatten)]
|
||||
cx: CxSchema,
|
||||
#[serde(default, flatten)]
|
||||
index_key: Option<cx::IndexKey>,
|
||||
filter_key: u64,
|
||||
#[serde(default)]
|
||||
random_type: i32,
|
||||
#[serde(default)]
|
||||
file_list_name: Option<String>,
|
||||
#[serde(default)]
|
||||
index_key_dict: HashMap<String, cx::IndexKey>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@@ -474,6 +488,24 @@ impl Schema {
|
||||
*file_crypt_flag,
|
||||
*random_type,
|
||||
)?),
|
||||
CryptType::HxCrypt {
|
||||
cx,
|
||||
index_key,
|
||||
filter_key,
|
||||
random_type,
|
||||
file_list_name,
|
||||
index_key_dict,
|
||||
} => Box::new(cx::HxCrypt::new(
|
||||
self.base.clone(),
|
||||
cx,
|
||||
index_key.as_ref(),
|
||||
*filter_key,
|
||||
*random_type,
|
||||
file_list_name.as_ref().map(|s| s.as_str()),
|
||||
config.xp3_file_list_path.as_ref().map(|s| s.as_str()),
|
||||
index_key_dict,
|
||||
filename,
|
||||
)?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ impl<'a> Xp3Archive<'a> {
|
||||
timestamp,
|
||||
segments,
|
||||
extras: entry_extras,
|
||||
extra: None,
|
||||
};
|
||||
if entry.name == "startup.tjs"
|
||||
&& entry.flags != 0
|
||||
|
||||
Reference in New Issue
Block a user