Skip to content

Commit

Permalink
DLC compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
clayamore committed Jun 21, 2024
1 parent e8e0590 commit c60887a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/save/common/user_data_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
}
Expand All @@ -23,8 +23,8 @@ impl Read for UserData11 {
fn read(br: &mut BinaryReader) -> Result<UserData11, Error> {
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)
}
Expand Down
16 changes: 16 additions & 0 deletions src/util/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub mod params {
CharMakeMenuListItemParam,
CharMakeMenuTopParam,
ChrActivateConditionParam,
ChrEquipModelParam,
ChrModelParam,
ClearCountCorrectParam,
CoolTimeParam,
Expand Down Expand Up @@ -102,10 +103,13 @@ pub mod params {
MapDefaultInfoParam,
MapGdRegionDrawParam,
MapGdRegionInfoParam,
MapGridCreateHeightDetailLimitInfo,
MapGridCreateHeightLimitInfoParam,
MapMimicryEstablishmentParam,
MapNameTexParam,
MapNameTexParam_m61,
MapPieceTexParam,
MapPieceTexParam_m61,
MaterialExParam,
MenuColorTableParam,
MenuCommonParam,
Expand All @@ -114,6 +118,7 @@ pub mod params {
MenuPropertySpecParam,
MenuValueTableParam,
MimicryEstablishmentTexParam,
MimicryEstablishmentTexParam_m61,
MoveParam,
MPEstusFlaskRecoveryParam,
MultiHPEstusFlaskBonusParam,
Expand Down Expand Up @@ -150,6 +155,8 @@ pub mod params {
ShopLineupParam,
ShopLineupParam_Recipe,
SignPuddleParam,
SignPuddleSubCategoryParam,
SignPuddleTabParam,
SoundAssetSoundObjEnableDistParam,
SoundAutoEnvSoundGroupParam,
SoundAutoReverbEvaluationDistParam,
Expand All @@ -172,6 +179,7 @@ pub mod params {
WeatherAssetReplaceParam,
WeatherLotParam,
WeatherLotTexParam,
WeatherLotTexParam_m61,
WeatherParam,
WepAbsorpPosParam,
WetAspectParam,
Expand Down Expand Up @@ -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) ,
Expand Down Expand Up @@ -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) ,
Expand All @@ -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) ,
Expand Down Expand Up @@ -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) ,
Expand All @@ -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) ,
Expand Down
27 changes: 15 additions & 12 deletions src/util/regulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}};
Expand All @@ -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<u32, Row<EQUIP_PARAM_ACCESSORY_ST>> {
Expand Down Expand Up @@ -123,29 +130,25 @@ 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);
assert_eq!(br.read_i32()?, 0);
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),
Expand Down

0 comments on commit c60887a

Please sign in to comment.