mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
Add automatic client-asset installation for modern Tibia versions in OTC, with the UI and runtime support needed for a safe download-and-install flow. Main changes: - Add modules/client_assets to orchestrate descriptor and release resolution, downloads, retries, cancellation, archive extraction, optional LZMA handling, and SHA-256 integrity checks. - Add richer install logs in the console, including download phases, install phases, and final install paths. - Add support for packaged runtime files, including large DLLs distributed through archives. - Make client_entergame depend on client_assets. - Check required assets during login for modern clients version 1281 and newer. - Prompt the user to download missing modern assets instead of requiring manual setup. - Allow the client list and version selection to work with installed modern asset sets. Install layout: - Install things assets under data/things/<version>. - Install sound assets under data/sounds/<version>. - Keep extra runtime files in the existing client root/bin flow. - Preserve the existing OTC asset layout as the source of truth instead of introducing a separate permanent path. UI improvements: - Improve missing-assets and progress dialog sizing and text wrapping. - Improve progress behavior for downloads without Content-Length. - Add indeterminate progress behavior for unknown-length phases. - Add an hourglass busy indicator for indeterminate phases. - Reduce the perception that the installer is stuck during long extraction steps. Runtime and build support: - Add libarchive usage and linking for archive extraction. - Add SHA-256 helpers and Lua bindings used by client_assets. - Add safer extraction and path normalization in ResourceManager. - Adjust the Emscripten HTTP login path to follow the same HTTP/HTTPS fallback behavior used by native login. Security and integrity: - Enable strictManifestSha256 by default. - Disable raw fallback on hash mismatch by default. - Key releasesCache per source URL and repository to avoid stale cross-source cache reuse. - Add an LZMA decompression output cap to reduce memory-exhaustion risk. Compatibility: - Keep existing classic asset behavior unchanged. - Use the new auto-install flow only for modern versions when required assets are missing. - Keep the scope limited to client-side asset automation and required runtime support. - No server-side Canary behavior is changed by this PR. This makes modern client setup safer and more automatic by downloading, validating, extracting, and installing missing assets directly from OTC while preserving the existing classic asset flow.
190 lines
6.2 KiB
Lua
190 lines
6.2 KiB
Lua
-- this is the first file executed when the application starts
|
|
-- we have to load the first modules form here
|
|
|
|
-- updater
|
|
Services = {
|
|
--updater = "http://localhost/api/updater.php", --./updater
|
|
--status = "http://localhost/login.php", --./client_entergame | ./client_topmenu
|
|
--websites = "http://localhost/?subtopic=accountmanagement", --./client_entergame "Forgot password and/or email"
|
|
--createAccount = "http://localhost/clientcreateaccount.php", --./client_entergame -- createAccount.lua
|
|
--getCoinsUrl = "http://localhost/?subtopic=shop&step=terms", --./game_market
|
|
clientAssets = {
|
|
enabled = true,
|
|
repository = "dudantas/tibia-client",
|
|
installSounds = true,
|
|
strictManifestSha256 = true,
|
|
allowRawFallbackHashMismatch = false,
|
|
preferArchive = true,
|
|
installArchiveExtras = true,
|
|
archiveExtraPrefixes = { "bin" },
|
|
installPackagedFiles = true
|
|
}, -- ./client_assets
|
|
}
|
|
|
|
--- Enables or disables the entire server configuration block.
|
|
-- Set to `false` to disable all configuration below.
|
|
local ENABLE_SERVERS = true
|
|
|
|
---
|
|
-- @module Servers_init
|
|
-- Configuration table for all servers used by the system.
|
|
--
|
|
-- This entire block is conditionally enabled based on ENABLE_SERVERS.
|
|
-- When ENABLE_SERVERS == false, everything is ignored/disabled.
|
|
--
|
|
|
|
---
|
|
-- Server configuration system for multi-server or multi-world clients.
|
|
--
|
|
-- This structure allows a single client build to connect to multiple servers
|
|
-- without requiring duplicate client folders.
|
|
--
|
|
-- A server that hosts several worlds, or that provides a separate test environment,
|
|
-- can simply define additional entries inside this configuration table.
|
|
--
|
|
-- Instead of maintaining multiple client installations (one per world/server),
|
|
-- the client can switch between servers by selecting the desired configuration entry.
|
|
-- This simplifies testing, avoids redundant directories, and centralizes connection settings.
|
|
--
|
|
-- The ENABLE_SERVERS flag allows the entire configuration block to be enabled or disabled
|
|
-- without deleting or commenting out individual entries.
|
|
--
|
|
|
|
Servers_init = {}
|
|
|
|
if ENABLE_SERVERS then
|
|
|
|
---
|
|
-- List of servers and their configuration parameters.
|
|
-- Each entry defines port, protocol, and authentication options.
|
|
-- @table Servers_init
|
|
--
|
|
Servers_init = {
|
|
|
|
-- Local login server
|
|
---
|
|
-- Configuration for local login server.
|
|
-- @class table
|
|
-- @name local_login
|
|
-- @field port Port used for HTTP connection
|
|
-- @field protocol Protocol identifier used by the application
|
|
-- @field httpLogin Enables HTTP-based login on the server
|
|
-- @field useAuthenticator Enables additional authentication layer
|
|
--
|
|
["http://127.0.0.1/login.php"] = {
|
|
port = 80,
|
|
protocol = 1511,
|
|
httpLogin = true,
|
|
useAuthenticator = false
|
|
},
|
|
|
|
-- External server
|
|
---
|
|
-- Configuration for external server ip.net.
|
|
-- @class table
|
|
-- @name ip_net
|
|
-- @field port TCP port used for connection
|
|
-- @field protocol Protocol identifier used by the server
|
|
-- @field httpLogin Indicates if the server allows HTTP login
|
|
--
|
|
["ip.net"] = {
|
|
port = 7171,
|
|
protocol = 860,
|
|
httpLogin = false
|
|
}
|
|
}
|
|
end
|
|
|
|
g_app.setName("OTClient - Redemption");
|
|
g_app.setCompactName("otclient");
|
|
g_app.setOrganizationName("otcr");
|
|
|
|
g_app.hasUpdater = function()
|
|
return (Services.updater and Services.updater ~= "" and g_modules.getModule("updater"))
|
|
end
|
|
|
|
-- setup logger
|
|
g_logger.setLogFile(g_resources.getWorkDir() .. g_app.getCompactName() .. '.log')
|
|
g_logger.info(os.date('== application started at %b %d %Y %X'))
|
|
g_logger.info("== operating system: " .. g_platform.getOSName())
|
|
|
|
-- print first terminal message
|
|
g_logger.info(g_app.getName() .. ' ' .. g_app.getVersion() .. ' rev ' .. g_app.getBuildRevision() .. ' (' ..
|
|
g_app.getBuildCommit() .. ') built on ' .. g_app.getBuildDate() .. ' for arch ' ..
|
|
g_app.getBuildArch())
|
|
|
|
-- setup lua debugger
|
|
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
|
|
require("lldebugger").start()
|
|
g_logger.debug("Started LUA debugger.")
|
|
else
|
|
g_logger.debug("LUA debugger not started (not launched with VSCode local-lua).")
|
|
end
|
|
|
|
-- add data directory to the search path
|
|
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'data', true) then
|
|
g_logger.fatal('Unable to add data directory to the search path.')
|
|
end
|
|
|
|
-- add modules directory to the search path
|
|
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'modules', true) then
|
|
g_logger.fatal('Unable to add modules directory to the search path.')
|
|
end
|
|
|
|
g_html.addGlobalStyle('/data/styles/html.css')
|
|
g_html.addGlobalStyle('/data/styles/custom.css')
|
|
|
|
-- try to add mods path too
|
|
g_resources.addSearchPath(g_resources.getWorkDir() .. 'mods', true)
|
|
|
|
-- setup directory for saving configurations
|
|
g_resources.setupUserWriteDir(('%s/'):format(g_app.getCompactName()))
|
|
|
|
-- search all packages
|
|
g_resources.searchAndAddPackages('/', '.otpkg', true)
|
|
|
|
-- load settings
|
|
g_configs.loadSettings('/config.otml')
|
|
|
|
g_modules.discoverModules()
|
|
|
|
-- libraries modules 0-99
|
|
g_modules.autoLoadModules(99)
|
|
g_modules.ensureModuleLoaded('corelib')
|
|
g_modules.ensureModuleLoaded('gamelib')
|
|
g_modules.ensureModuleLoaded('modulelib')
|
|
g_modules.ensureModuleLoaded("startup")
|
|
|
|
g_modules.autoLoadModules(999)
|
|
g_modules.ensureModuleLoaded('game_shaders') -- pre load
|
|
|
|
local function loadModules()
|
|
-- client modules 100-499
|
|
g_modules.autoLoadModules(499)
|
|
g_modules.ensureModuleLoaded('client')
|
|
|
|
-- game modules 500-999
|
|
g_modules.autoLoadModules(999)
|
|
g_modules.ensureModuleLoaded('game_interface')
|
|
|
|
-- mods 1000-9999
|
|
g_modules.autoLoadModules(9999)
|
|
g_modules.ensureModuleLoaded('client_mods')
|
|
|
|
local script = '/' .. g_app.getCompactName() .. 'rc.lua'
|
|
|
|
if g_resources.fileExists(script) then
|
|
dofile(script)
|
|
end
|
|
|
|
-- uncomment the line below so that modules are reloaded when modified. (Note: Use only mod dev)
|
|
-- g_modules.enableAutoReload()
|
|
end
|
|
|
|
-- run updater, must use data.zip
|
|
if g_app.hasUpdater() then
|
|
g_modules.ensureModuleLoaded("updater")
|
|
return Updater.init(loadModules)
|
|
end
|
|
|
|
loadModules()
|