mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-22 04:06:18 +00:00
Compare commits
3 Commits
355a4503ea
...
v0.9.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 68df923bea | |||
| ddbec8d72c | |||
| 70d4e0c40f |
@@ -746,6 +746,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
patch_entry = patch_mix.entries.find { |e| e.name.casecmp?(".w3dhub.patch") || e.name.casecmp?(".bhppatch") }
|
patch_entry = patch_mix.entries.find { |e| e.name.casecmp?(".w3dhub.patch") || e.name.casecmp?(".bhppatch") }
|
||||||
patch_entry.read
|
patch_entry.read
|
||||||
|
# "remove" patch meta file from patch before copying patch data
|
||||||
|
patch_mix.entries.delete(patch_entry)
|
||||||
|
|
||||||
patch_info = JSON.parse(patch_entry.blob, symbolize_names: true)
|
patch_info = JSON.parse(patch_entry.blob, symbolize_names: true)
|
||||||
|
|
||||||
@@ -765,20 +767,15 @@ class W3DHub
|
|||||||
patch_info[:updatedFiles].each do |file|
|
patch_info[:updatedFiles].each do |file|
|
||||||
logger.debug(LOG_TAG) { " #{file}" }
|
logger.debug(LOG_TAG) { " #{file}" }
|
||||||
|
|
||||||
patch = patch_mix.entries.find { |e| e.name.casecmp?(file) }
|
patch_mix.entries.each do |entry|
|
||||||
target = target_mix.entries.find { |e| e.name.casecmp?(file) }
|
target_mix.add_entry(entry: entry, replace: true)
|
||||||
|
|
||||||
if target
|
|
||||||
target_mix.entries[target_mix.entries.index(target)] = patch
|
|
||||||
else
|
|
||||||
target_mix.entries << patch
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
logger.info(LOG_TAG) { " Writing updated #{file_path}..." } if patch_info[:updatedFiles].size.positive?
|
logger.info(LOG_TAG) { " Writing updated #{file_path}..." } if patch_info[:updatedFiles].size.positive?
|
||||||
temp_mix_path = "#{temp_path}/#{File.basename(file_path)}"
|
temp_mix_path = "#{temp_path}/#{File.basename(file_path)}"
|
||||||
temp_mix = W3DHub::WWMix.new(path: temp_mix_path)
|
temp_mix = W3DHub::WWMix.new(path: temp_mix_path, encrypted: target_mix.encrypted?)
|
||||||
target_mix.entries.each { |e| temp_mix.add_entry(entry: e) }
|
target_mix.entries.each { |e| temp_mix.add_entry(entry: e, replace: true) }
|
||||||
unless temp_mix.save
|
unless temp_mix.save
|
||||||
raise temp_mix.error_reason
|
raise temp_mix.error_reason
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class W3DHub
|
class W3DHub
|
||||||
DIR_NAME = "W3DHubAlt".freeze
|
DIR_NAME = "W3DHubAlt".freeze
|
||||||
VERSION = "0.9.0".freeze
|
VERSION = "0.9.1".freeze
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -228,27 +228,34 @@ class W3DHub
|
|||||||
@encrypted
|
@encrypted
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_file(path:)
|
def add_file(path:, replace: false)
|
||||||
return false unless File.exist?(path)
|
return false unless File.exist?(path)
|
||||||
return false if File.directory?(path)
|
return false if File.directory?(path)
|
||||||
|
|
||||||
info = EntryInfoHeader.new(0, 0, File.size(path))
|
entry = Entry.new(name: File.basename(path), path: path, info: EntryInfoHeader.new(0, 0, File.size(path)))
|
||||||
@entries << Entry.new(name: File.basename(path), path: path, info: info)
|
add_entry(entry: entry, replace: replace)
|
||||||
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_blob(path:, blob:)
|
def add_blob(path:, blob:, replace: false)
|
||||||
info = EntryInfoHeader.new(0, 0, blob.size)
|
info = EntryInfoHeader.new(0, 0, blob.size)
|
||||||
@entries << Entry.new(name: File.basename(path), path: path, info: info, blob: blob)
|
entry = Entry.new(name: File.basename(path), path: path, info: info, blob: blob)
|
||||||
into.crc32 = @entries.last.calculate_crc32
|
into.crc32 = @entries.last.calculate_crc32
|
||||||
|
|
||||||
true
|
add_entry(entry: entry, replace: replace)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_entry(entry:)
|
def add_entry(entry:, replace: false)
|
||||||
@entries << entry
|
duplicate = @entries.find { |e| e.name.upcase == entry.name.upcase }
|
||||||
|
|
||||||
|
if duplicate
|
||||||
|
if replace
|
||||||
|
@entries.delete(duplicate)
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@entries << entry
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user