Compare commits

...

3 Commits

7 changed files with 56 additions and 30 deletions

View File

@@ -2,25 +2,27 @@ GEM
remote: https://rubygems.org/
specs:
base64 (0.2.0)
concurrent-ruby (1.3.4)
concurrent-ruby (1.3.5)
cyberarm_engine (0.24.4)
gosu (~> 1.1)
digest-crc (0.6.5)
digest-crc (0.7.0)
rake (>= 12.0.0, < 14.0.0)
event_emitter (0.2.6)
excon (1.2.3)
ffi (1.17.1-x64-mingw-ucrt)
ffi (1.17.1-x86_64-linux-gnu)
excon (1.2.5)
logger
ffi (1.17.2-x64-mingw-ucrt)
ffi (1.17.2-x86_64-linux-gnu)
ffi-win32-extensions (1.0.4)
ffi
gosu (1.4.6)
i18n (1.14.6)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
ircparser (1.0.0)
libui (0.1.2-x64-mingw)
logger (1.7.0)
mutex_m (0.3.0)
rake (13.2.1)
rexml (3.4.0)
rexml (3.4.1)
rubyzip (2.4.1)
sdl2-bindings (0.2.3)
ffi (~> 1.15)

View File

@@ -1,6 +1,8 @@
class W3DHub
class Api
class ServerListServer
NO_OR_BAD_PING = 1_000_000
attr_reader :id, :game, :address, :port, :region, :channel, :ping, :status
def initialize(hash)
@@ -12,7 +14,7 @@ class W3DHub
@port = @data[:port]
@region = @data[:region]
@channel = @data[:channel] || "release"
@ping = -1
@ping = NO_OR_BAD_PING
@status = Status.new(@data[:status])
@@ -55,7 +57,7 @@ class W3DHub
end
end
@ping = -1 if @ping.zero?
@ping = NO_OR_BAD_PING if @ping.zero?
@ping
end,

View File

@@ -738,7 +738,7 @@ class W3DHub
end
logger.info(LOG_TAG) { " Writing updated #{path}/#{safe_file_name}..." } if patch_info[:updatedFiles].size.positive?
W3DHub::Mixer::Writer.new(file_path: "#{path}/#{safe_file_name}", package: target_mix.package, memory_buffer: true)
W3DHub::Mixer::Writer.new(file_path: "#{path}/#{safe_file_name}", package: target_mix.package, memory_buffer: true, encrypted: target_mix.encrypted?)
FileUtils.remove_dir(temp_path)

View File

@@ -6,6 +6,8 @@ class W3DHub
# https://github.com/TheUnstoppable/MixLibrary used for reference
class Mixer
DEFAULT_BUFFER_SIZE = 32_000_000
MIX1_HEADER = 0x3158494D
MIX2_HEADER = 0x3258494D
class MixParserException < RuntimeError; end
class MixFormatException < RuntimeError; end
@@ -203,8 +205,12 @@ class W3DHub
@buffer.pos = 0
@encrypted = false
# Valid header
if read_i32 == 0x3158494D
if (mime = read_i32) && (mime == MIX1_HEADER || mime == MIX2_HEADER)
@encrypted = mime == MIX2_HEADER
file_data_offset = read_i32
file_names_offset = read_i32
@@ -237,7 +243,7 @@ class W3DHub
@buffer.pos = pos
end
else
raise MixParserException, "Invalid MIX file"
raise MixParserException, "Invalid MIX file: Expected \"#{MIX1_HEADER}\" or \"#{MIX2_HEADER}\", got \"0x#{mime.to_s(16).upcase}\"\n(#{file_path})"
end
ensure
@@ -264,18 +270,24 @@ class W3DHub
buffer.strip
end
def encrypted?
@encrypted
end
end
class Writer
attr_reader :package
def initialize(file_path:, package:, memory_buffer: false, buffer_size: DEFAULT_BUFFER_SIZE)
def initialize(file_path:, package:, memory_buffer: false, buffer_size: DEFAULT_BUFFER_SIZE, encrypted: false)
@package = package
@buffer = MemoryBuffer.new(file_path: file_path, mode: :write, buffer_size: buffer_size)
@buffer.pos = 0
@buffer.write("MIX1")
@encrypted = encrypted
@buffer.write(encrypted? ? "MIX2" : "MIX1")
files = @package.files.sort { |a, b| a.file_crc <=> b.file_crc }
@@ -322,6 +334,10 @@ class W3DHub
def write_byte(byte)
@buffer.write([byte].pack("c"))
end
def encrypted?
@encrypted
end
end
# Eager loads patch file and streams target file metadata (doen't load target file data or generate CRCs)

View File

@@ -196,11 +196,11 @@ class W3DHub
def ping_icon(server)
case server.ping
when 0..160
when 0..150
@ping_icons[:good]
when 161..250
when 151..200
@ping_icons[:fair]
when 251..1_000
when 201..1_000
@ping_icons[:poor]
when 1_001..5_000
@ping_icons[:bad]
@@ -210,7 +210,7 @@ class W3DHub
end
def ping_tip(server)
server.ping.negative? ? "Ping failed" : "Ping #{server.ping}ms"
server.ping == W3DHub::Api::ServerListServer::NO_OR_BAD_PING ? "Ping failed" : "Ping #{server.ping}ms"
end
def find_element_by_tag(container, tag, list = [])
@@ -292,7 +292,7 @@ class W3DHub
@server_list_container.children.sort_by! do |child|
s = Store.server_list.find { |s| s.id == child.style.tag }
[s.status.player_count, s.id]
[s.status.player_count, -s.ping]
end.reverse!.each_with_index do |child, i|
next if @selected_server_container && child == @selected_server_container

View File

@@ -6,8 +6,8 @@ class W3DHub
stack(width: 1.0, height: 1.0, padding: 16, scroll: true) do
background 0xaa_252525
para "<b>Language</b>"
flow(width: 1.0, height: 0.12) do
stack(width: 1.0, fill: true) do
para "<b>Language</b>"
para "<b>Launcher Language</b>", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@language_menu = list_box items: I18n.available_locales.map { |l| expand_language_code(l.to_s) }, choose: expand_language_code(Store.settings[:language]), width: 1.0
@@ -15,8 +15,8 @@ class W3DHub
end
end
para "<b>Folder Paths</b>", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
stack(width: 1.0, height: 0.3) do
stack(width: 1.0, height: 144) do
para "<b>Folder Paths</b>", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
flow(width: 1.0, height: 0.5) do
para "<b>App Install Folder</b>", width: 0.249, margin_left: 32, margin_top: 12
@@ -26,19 +26,25 @@ class W3DHub
end
end
flow(width: 1.0, margin_top: 16) do
flow(width: 1.0, height: 256, margin_top: 16) do
para "<b>Package Cache Folder</b>", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], width: 1.0
stack(width: 0.75, height: 200) do
flow(width: 1.0, height: 1.0) do
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], fill: true
button "Browse...", width: 128, height: 1.0, tip: "Browse for game executable" do
path = W3DHub.ask_file
end
end
para "A folder which will be used to cache downloaded packages used to install games and apps"
end
end
end
if true # W3DHub.unix?
para "<b>Wine</b>", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
flow(width: 1.0, height: 0.12) do
stack(width: 1.0, fill: true) do
para "<b>Wine</b>", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
para "<b>Wine Command</b>", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@wine_command_input = edit_line Store.settings[:wine_command], width: 1.0
@@ -46,7 +52,7 @@ class W3DHub
end
end
flow(width: 1.0, height: 0.13, margin_top: 16) do
stack(width: 1.0, fill: true, margin_top: 16) do
para "<b>Wine Prefix</b>", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@wine_prefix_toggle = toggle_button checked: Store.settings[:wine_prefix]

View File

@@ -1,4 +1,4 @@
class W3DHub
DIR_NAME = "W3DHubAlt"
VERSION = "0.6.1"
VERSION = "0.6.2"
end