From c60887a0d1542e54c8d851f2e24994811cf3ad1c Mon Sep 17 00:00:00 2001 From: clayamore Date: Fri, 21 Jun 2024 16:43:23 +0200 Subject: [PATCH] DLC compatibility --- src/save/common/user_data_11.rs | 8 ++++---- src/util/params.rs | 16 ++++++++++++++++ src/util/regulation.rs | 27 +++++++++++++++------------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/save/common/user_data_11.rs b/src/save/common/user_data_11.rs index 351fb26..352e647 100644 --- a/src/save/common/user_data_11.rs +++ b/src/save/common/user_data_11.rs @@ -13,8 +13,8 @@ impl Default for UserData11 { fn default() -> Self { Self { unk: Default::default(), - regulation: vec![0; 0x1c5f70], - rest: vec![0;0x7A090] + regulation: vec![0; 0x1e9fb0], + rest: vec![0;0x56050] } } } @@ -23,8 +23,8 @@ impl Read for UserData11 { fn read(br: &mut BinaryReader) -> Result { let mut user_data_11 = UserData11::default(); user_data_11.unk.copy_from_slice(br.read_bytes(0x10)?); - user_data_11.regulation.copy_from_slice(br.read_bytes(0x1c5f70)?); - user_data_11.rest.copy_from_slice(br.read_bytes(0x7A090)?); + user_data_11.regulation.copy_from_slice(br.read_bytes(0x1e9fb0)?); + user_data_11.rest.copy_from_slice(br.read_bytes(0x56050)?); assert_eq!(user_data_11.rest[0], 0); Ok(user_data_11) } diff --git a/src/util/params.rs b/src/util/params.rs index 449c79d..f8d5295 100644 --- a/src/util/params.rs +++ b/src/util/params.rs @@ -33,6 +33,7 @@ pub mod params { CharMakeMenuListItemParam, CharMakeMenuTopParam, ChrActivateConditionParam, + ChrEquipModelParam, ChrModelParam, ClearCountCorrectParam, CoolTimeParam, @@ -102,10 +103,13 @@ pub mod params { MapDefaultInfoParam, MapGdRegionDrawParam, MapGdRegionInfoParam, + MapGridCreateHeightDetailLimitInfo, MapGridCreateHeightLimitInfoParam, MapMimicryEstablishmentParam, MapNameTexParam, + MapNameTexParam_m61, MapPieceTexParam, + MapPieceTexParam_m61, MaterialExParam, MenuColorTableParam, MenuCommonParam, @@ -114,6 +118,7 @@ pub mod params { MenuPropertySpecParam, MenuValueTableParam, MimicryEstablishmentTexParam, + MimicryEstablishmentTexParam_m61, MoveParam, MPEstusFlaskRecoveryParam, MultiHPEstusFlaskBonusParam, @@ -150,6 +155,8 @@ pub mod params { ShopLineupParam, ShopLineupParam_Recipe, SignPuddleParam, + SignPuddleSubCategoryParam, + SignPuddleTabParam, SoundAssetSoundObjEnableDistParam, SoundAutoEnvSoundGroupParam, SoundAutoReverbEvaluationDistParam, @@ -172,6 +179,7 @@ pub mod params { WeatherAssetReplaceParam, WeatherLotParam, WeatherLotTexParam, + WeatherLotTexParam_m61, WeatherParam, WepAbsorpPosParam, WetAspectParam, @@ -224,6 +232,7 @@ pub mod params { "CharMakeMenuListItemParam"=>Ok(Self::CharMakeMenuListItemParam) , "CharMakeMenuTopParam"=>Ok(Self::CharMakeMenuTopParam) , "ChrActivateConditionParam"=>Ok(Self::ChrActivateConditionParam) , + "ChrEquipModelParam"=>Ok(Self::ChrEquipModelParam) , "ChrModelParam"=>Ok(Self::ChrModelParam) , "ClearCountCorrectParam"=>Ok(Self::ClearCountCorrectParam) , "CoolTimeParam"=>Ok(Self::CoolTimeParam) , @@ -293,10 +302,13 @@ pub mod params { "MapDefaultInfoParam"=>Ok(Self::MapDefaultInfoParam) , "MapGdRegionDrawParam"=>Ok(Self::MapGdRegionDrawParam) , "MapGdRegionInfoParam"=>Ok(Self::MapGdRegionInfoParam) , + "MapGridCreateHeightDetailLimitInfo"=>Ok(Self::MapGridCreateHeightDetailLimitInfo) , "MapGridCreateHeightLimitInfoParam"=>Ok(Self::MapGridCreateHeightLimitInfoParam) , "MapMimicryEstablishmentParam"=>Ok(Self::MapMimicryEstablishmentParam) , "MapNameTexParam"=>Ok(Self::MapNameTexParam) , + "MapNameTexParam_m61"=>Ok(Self::MapNameTexParam_m61) , "MapPieceTexParam"=>Ok(Self::MapPieceTexParam) , + "MapPieceTexParam_m61"=>Ok(Self::MapPieceTexParam_m61) , "MaterialExParam"=>Ok(Self::MaterialExParam) , "MenuColorTableParam"=>Ok(Self::MenuColorTableParam) , "MenuCommonParam"=>Ok(Self::MenuCommonParam) , @@ -305,6 +317,7 @@ pub mod params { "MenuPropertySpecParam"=>Ok(Self::MenuPropertySpecParam) , "MenuValueTableParam"=>Ok(Self::MenuValueTableParam) , "MimicryEstablishmentTexParam"=>Ok(Self::MimicryEstablishmentTexParam) , + "MimicryEstablishmentTexParam_m61"=>Ok(Self::MimicryEstablishmentTexParam_m61) , "MoveParam"=>Ok(Self::MoveParam) , "MPEstusFlaskRecoveryParam"=>Ok(Self::MPEstusFlaskRecoveryParam) , "MultiHPEstusFlaskBonusParam"=>Ok(Self::MultiHPEstusFlaskBonusParam) , @@ -341,6 +354,8 @@ pub mod params { "ShopLineupParam"=>Ok(Self::ShopLineupParam) , "ShopLineupParam_Recipe"=>Ok(Self::ShopLineupParam_Recipe) , "SignPuddleParam"=>Ok(Self::SignPuddleParam) , + "SignPuddleSubCategoryParam"=>Ok(Self::SignPuddleSubCategoryParam) , + "SignPuddleTabParam"=>Ok(Self::SignPuddleTabParam) , "SoundAssetSoundObjEnableDistParam"=>Ok(Self::SoundAssetSoundObjEnableDistParam) , "SoundAutoEnvSoundGroupParam"=>Ok(Self::SoundAutoEnvSoundGroupParam) , "SoundAutoReverbEvaluationDistParam"=>Ok(Self::SoundAutoReverbEvaluationDistParam) , @@ -363,6 +378,7 @@ pub mod params { "WeatherAssetReplaceParam"=>Ok(Self::WeatherAssetReplaceParam) , "WeatherLotParam"=>Ok(Self::WeatherLotParam) , "WeatherLotTexParam"=>Ok(Self::WeatherLotTexParam) , + "WeatherLotTexParam_m61"=>Ok(Self::WeatherLotTexParam_m61) , "WeatherParam"=>Ok(Self::WeatherParam) , "WepAbsorpPosParam"=>Ok(Self::WepAbsorpPosParam) , "WetAspectParam"=>Ok(Self::WetAspectParam) , diff --git a/src/util/regulation.rs b/src/util/regulation.rs index 748eaec..4375c72 100644 --- a/src/util/regulation.rs +++ b/src/util/regulation.rs @@ -2,7 +2,6 @@ use std::{collections::HashMap, io::Error, str::FromStr, sync::{Mutex, RwLock}}; use aes::cipher::{block_padding::NoPadding, BlockDecryptMut, KeyIvInit}; use binary_reader::{BinaryReader, Endian}; -use miniz_oxide::inflate::decompress_to_vec; use once_cell::sync::{Lazy, OnceCell}; use crate::{db::{accessory_name::accessory_name::ACCESSORY_NAME, aow_name::aow_name::AOW_NAME, armor_name::armor_name::ARMOR_NAME, item_name::item_name::ITEM_NAME, weapon_name::weapon_name::WEAPON_NAME}, save::save::save::Save, util::{param_structs::{EQUIP_PARAM_ACCESSORY_ST, EQUIP_PARAM_GEM_ST, EQUIP_PARAM_GOODS_ST, EQUIP_PARAM_PROTECTOR_ST, EQUIP_PARAM_WEAPON_ST}, params::params::{Row, PARAM}}}; @@ -15,7 +14,15 @@ pub struct Regulation; impl Regulation { pub fn init_params(save: &Save) { - *PARAMS.write().unwrap() = Regulation::params_from_regulation(save.save_type.get_regulation()).unwrap(); + let res = Regulation::params_from_regulation(save.save_type.get_regulation()); + + + match res { + Ok(res) => *PARAMS.write().unwrap() = res, + Err(err) => println!("{err}"), + } + + } pub fn equip_accessory_param_map() -> &'static HashMap> { @@ -123,14 +130,14 @@ impl Regulation { let compressed_size = br.read_i32()?; assert_eq!(br.read_bytes(4)?, b"DCP\0"); - assert_eq!(br.read_bytes(4)?, b"DFLT"); + assert_eq!(br.read_bytes(4)?, b"ZSTD"); assert_eq!(br.read_i32()?, 0x20); - assert_eq!(br.read_u8()?, 9); + assert_eq!(br.read_u8()?, 0x15); assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_i32()?, 0); - assert_eq!(br.read_u8()?, 15); + assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_u8()?, 0); assert_eq!(br.read_u8()?, 0); @@ -138,14 +145,10 @@ impl Regulation { assert_eq!(br.read_i32()?, 0x00010100); assert_eq!(br.read_bytes(4)?, b"DCA\0"); - let _compressed_header_length = br.read_i32()?; + assert_eq!(br.read_i32()?, 8); - assert_eq!(br.read_u8()?, 0x78); - let assert_value = br.read_u8()?; - assert!(assert_value == 0x01 || assert_value == 0x5E || assert_value == 0x9C || assert_value == 0xDA); - - let compressed = br.read_bytes(compressed_size as usize - 2)?; - let res = decompress_to_vec(compressed); + let compressed = br.read_bytes(compressed_size as usize)?; + let res = zstd::decode_all(compressed); match res { Ok(decompressed) => Ok(decompressed),