Skip to content

Commit

Permalink
Less verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZ1337 committed Apr 25, 2024
1 parent 0406851 commit aee208d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/command/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ fn find_input(input: &Option<PathBuf>) -> anyhow::Result<PathBuf> {
}

fn pack_dat(art_key: &String, input: &PathBuf, output: &PathBuf) -> anyhow::Result<()> {
println!("Packing assets...");
let mut assets: Vec<AssetMetadata> = Vec::new();
let mut asset_bytes: Vec<u8> = Vec::new();
let mut count = 0;

for file in WalkDir::new(input) {
let file = file.unwrap();
Expand All @@ -81,10 +83,10 @@ fn pack_dat(art_key: &String, input: &PathBuf, output: &PathBuf) -> anyhow::Resu
name = format!("assets/{}", name);
}

println!("Packing asset: {} ({} bytes)", name, size);
assets.push(AssetMetadata { name, size });

asset_bytes.extend_from_slice(&std::fs::read(path)?);
count += 1;
}

let header = haxeformat::to_string(&assets)?;
Expand All @@ -100,8 +102,8 @@ fn pack_dat(art_key: &String, input: &PathBuf, output: &PathBuf) -> anyhow::Resu
let enc_key = enc_key.as_slice();
crypto::encrypt(enc_key, out.as_mut_slice());

println!("Packing assets to: {}...", output.display());
std::fs::write(output, out)?;
println!("Packed {} assets", count);

Ok(())
}
2 changes: 1 addition & 1 deletion src/command/patch/assets_patcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@ fn pack_to_assets(temp_dir: &PathBuf, game_dir: &PathBuf, repack: RepackInfo) ->
}
}

println!("Packed objects to: {}", output.display());
println!("Packed {} objects", new_assets.content.objects.len());
Ok(())
}
2 changes: 0 additions & 2 deletions src/command/patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ pub fn patch(args: &NewArgs, patch: &PathBuf, locale_mode: &I18nCompatMode) -> a
let game_files = prepare_game_files(&args.game_dir)?;

let temp_dir = create_temp_dir();
println!("Using temp directory: {}", temp_dir.display());
let temp_unpacked = temp_dir.join("unpacked");
fs::create_dir_all(&temp_unpacked)
.context("Failed to create temp directory")?;
let repack_info = unpack::unpack_assets(args, &game_files.assets, &temp_unpacked)?;

patch_assets(patch, &temp_dir, &game_files.game_dir, repack_info)?;
let patched_dir = patch_assets(patch, &temp_dir, &game_files.game_dir, repack_info)?;

if locale_mode == &I18nCompatMode::Normal {
Expand Down
2 changes: 1 addition & 1 deletion src/command/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn revert(game_dir: &PathBuf) -> anyhow::Result<()> {
let locale_bak = game_dir.join("StreamingAssets/loc/en.zip-bak");
copy_backup(&locale, &locale_bak)?;

println!("Reverted game files in: {:?} to vanilla state", game_dir);
println!("Reverted game files to vanilla state");

Ok(())
}
Expand Down
5 changes: 3 additions & 2 deletions src/command/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ pub fn unpack_dat(args: &NewArgs, input: &PathBuf, output: &PathBuf) -> anyhow::

// Loop through assets in the data and write them to the output directory
let mut index = len + 2;
for asset in assets {
println!("Unpacking asset: {} ({} bytes)", asset.name, asset.size);
for asset in &assets {
let asset_bytes = &data[index..index + asset.size];
index += asset.size;

Expand All @@ -75,6 +74,8 @@ pub fn unpack_dat(args: &NewArgs, input: &PathBuf, output: &PathBuf) -> anyhow::
.context(format!("Failed to write asset {} to file", asset.name))?;
}

println!("Unpacked {} assets", assets.len());

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn extract_key(args: &NewArgs) -> anyhow::Result<String> {
let mut key = [0; 16];
file.read_exact(&mut key)?;
let key = String::from_utf8(key.to_vec())?;
println!("Extracted Art.dat decryption key from global metadata: {}", key);
println!("Extracted Art.dat decryption key from global metadata");

Ok(key)
}

0 comments on commit aee208d

Please sign in to comment.