mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-22 04:06:18 +00:00
Compare commits
3 Commits
v0.9.1
...
027ba27b37
| Author | SHA1 | Date | |
|---|---|---|---|
| 027ba27b37 | |||
| adff1f9159 | |||
| 355a4503ea |
@@ -60,15 +60,15 @@ class W3DHub
|
||||
end
|
||||
|
||||
# Handle arbitrary urls that may come through
|
||||
url = nil
|
||||
if path.start_with?("http")
|
||||
uri = URI(path)
|
||||
|
||||
endpoint = uri.origin
|
||||
path = uri.request_uri
|
||||
else
|
||||
url = "#{endpoint}#{path}"
|
||||
end
|
||||
|
||||
url = "#{endpoint}#{path}"
|
||||
|
||||
logger.debug(LOG_TAG) { "Fetching #{method.to_s.upcase} \"#{url}\"..." }
|
||||
|
||||
# Inject Authorization header if account data is populated
|
||||
|
||||
@@ -255,13 +255,14 @@ class W3DHub
|
||||
!server.status.password &&
|
||||
server.status.player_count < server.status.max_players
|
||||
end
|
||||
server_options.sort_by! { |s| [s.status.player_count, s.ping] }.reverse!
|
||||
|
||||
# try to find server with lowest ping and matching version
|
||||
found_server = server_options.find { |server| server.version == app_data[:installed_version] }
|
||||
# try to find server with lowest ping and undefined version
|
||||
found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION }
|
||||
|
||||
found_server ? found_server : nil
|
||||
found_server || nil
|
||||
end
|
||||
|
||||
def play_now(app_id, channel)
|
||||
|
||||
@@ -746,8 +746,6 @@ class W3DHub
|
||||
end
|
||||
patch_entry = patch_mix.entries.find { |e| e.name.casecmp?(".w3dhub.patch") || e.name.casecmp?(".bhppatch") }
|
||||
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)
|
||||
|
||||
@@ -767,15 +765,20 @@ class W3DHub
|
||||
patch_info[:updatedFiles].each do |file|
|
||||
logger.debug(LOG_TAG) { " #{file}" }
|
||||
|
||||
patch_mix.entries.each do |entry|
|
||||
target_mix.add_entry(entry: entry, replace: true)
|
||||
patch = patch_mix.entries.find { |e| e.name.casecmp?(file) }
|
||||
target = target_mix.entries.find { |e| e.name.casecmp?(file) }
|
||||
|
||||
if target
|
||||
target_mix.entries[target_mix.entries.index(target)] = patch
|
||||
else
|
||||
target_mix.entries << patch
|
||||
end
|
||||
end
|
||||
|
||||
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 = W3DHub::WWMix.new(path: temp_mix_path, encrypted: target_mix.encrypted?)
|
||||
target_mix.entries.each { |e| temp_mix.add_entry(entry: e, replace: true) }
|
||||
temp_mix = W3DHub::WWMix.new(path: temp_mix_path)
|
||||
target_mix.entries.each { |e| temp_mix.add_entry(entry: e) }
|
||||
unless temp_mix.save
|
||||
raise temp_mix.error_reason
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class W3DHub
|
||||
DIR_NAME = "W3DHubAlt".freeze
|
||||
VERSION = "0.9.1".freeze
|
||||
VERSION = "0.9.0".freeze
|
||||
end
|
||||
|
||||
@@ -228,34 +228,27 @@ class W3DHub
|
||||
@encrypted
|
||||
end
|
||||
|
||||
def add_file(path:, replace: false)
|
||||
def add_file(path:)
|
||||
return false unless File.exist?(path)
|
||||
return false if File.directory?(path)
|
||||
|
||||
entry = Entry.new(name: File.basename(path), path: path, info: EntryInfoHeader.new(0, 0, File.size(path)))
|
||||
add_entry(entry: entry, replace: replace)
|
||||
info = EntryInfoHeader.new(0, 0, File.size(path))
|
||||
@entries << Entry.new(name: File.basename(path), path: path, info: info)
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def add_blob(path:, blob:, replace: false)
|
||||
def add_blob(path:, blob:)
|
||||
info = EntryInfoHeader.new(0, 0, blob.size)
|
||||
entry = Entry.new(name: File.basename(path), path: path, info: info, blob: blob)
|
||||
@entries << Entry.new(name: File.basename(path), path: path, info: info, blob: blob)
|
||||
into.crc32 = @entries.last.calculate_crc32
|
||||
|
||||
add_entry(entry: entry, replace: replace)
|
||||
true
|
||||
end
|
||||
|
||||
def add_entry(entry:, replace: false)
|
||||
duplicate = @entries.find { |e| e.name.upcase == entry.name.upcase }
|
||||
|
||||
if duplicate
|
||||
if replace
|
||||
@entries.delete(duplicate)
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def add_entry(entry:)
|
||||
@entries << entry
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user