From ade951f87cc1c8cad6de72aa5fca202efed77b7f Mon Sep 17 00:00:00 2001 From: cyberarm Date: Wed, 1 Dec 2021 19:49:25 -0600 Subject: [PATCH] Fixed Mixer erroring on CRC's shorter than 8 characters long, hardcoded crc string for .w3dhub.patch --- lib/application_manager/task.rb | 4 ++-- lib/mixer.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/application_manager/task.rb b/lib/application_manager/task.rb index ece19d1..0e20d7a 100644 --- a/lib/application_manager/task.rb +++ b/lib/application_manager/task.rb @@ -525,7 +525,7 @@ class W3DHub system("#{W3DHub.tar_command} -xf \"#{package_path}\" -C \"#{temp_path}\"") puts " Loading #{temp_path}/#{manifest_file.name}.patch..." - patch_mix = W3DHub::Mixer::Reader.new(file_path: "#{temp_path}/#{manifest_file.name}.patch", ignore_crc_mismatches: true) + patch_mix = W3DHub::Mixer::Reader.new(file_path: "#{temp_path}/#{manifest_file.name}.patch", ignore_crc_mismatches: false) patch_info = JSON.parse(patch_mix.package.files.find { |f| f.name == ".w3dhub.patch" || f.name == ".bhppatch" }.data, symbolize_names: true) repaired_path = "#{path}/#{manifest_file.name}" @@ -533,7 +533,7 @@ class W3DHub repaired_path = "#{path}/#{manifest_file.name.sub('data', 'Data')}" unless File.exist?(repaired_path) && path puts " Loading #{repaired_path}..." - target_mix = W3DHub::Mixer::Reader.new(file_path: repaired_path, ignore_crc_mismatches: true) + target_mix = W3DHub::Mixer::Reader.new(file_path: repaired_path, ignore_crc_mismatches: false) puts " Removing files..." if patch_info[:removedFiles].size.positive? patch_info[:removedFiles].each do |file| diff --git a/lib/mixer.rb b/lib/mixer.rb index 6f02340..5ca41f2 100644 --- a/lib/mixer.rb +++ b/lib/mixer.rb @@ -162,7 +162,7 @@ class W3DHub file_count.times do |i| file = @package.files[i] - file.mix_crc = read_u32.to_s(16) + file.mix_crc = read_u32.to_s(16).rjust(8, "0") file.content_offset = read_u32 file.content_length = read_u32 @@ -301,6 +301,8 @@ class W3DHub end def file_crc + return "e6fe46b8" if @name.downcase == ".w3dhub.patch" + Digest::CRC32.hexdigest(@name.upcase) end