mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Avoid spr loading freeze when logging
This commit is contained in:
@@ -37,6 +37,11 @@ function Client.init()
|
||||
g_window.setIcon(resolvepath('clienticon.png'))
|
||||
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
|
||||
|
||||
-- load default client version
|
||||
local clientVersion = g_settings.getInteger('client-version')
|
||||
if not clientVersion or clientVersion == 0 then clientVersion = 960 end
|
||||
g_game.setClientVersion(clientVersion)
|
||||
|
||||
connect(g_app, { onRun =
|
||||
function()
|
||||
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
||||
@@ -53,5 +58,6 @@ function Client.terminate()
|
||||
g_settings.set('window-size', g_window.getUnmaximizedSize())
|
||||
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||
g_settings.set('window-maximized', g_window.isMaximized())
|
||||
g_settings.set('client-version', g_game.getClientVersion())
|
||||
Client = nil
|
||||
end
|
||||
|
||||
@@ -67,11 +67,9 @@ function EnterGame.init()
|
||||
local host = g_settings.get('host')
|
||||
local port = g_settings.get('port')
|
||||
local autologin = g_settings.getBoolean('autologin')
|
||||
local protocol = g_settings.getInteger('protocol', 860)
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
|
||||
if not protocol or protocol == 0 then
|
||||
protocol = 860
|
||||
end
|
||||
if not clientVersion or clientVersion == 0 then clientVersion = 960 end
|
||||
|
||||
if port == nil or port == 0 then port = 7171 end
|
||||
|
||||
@@ -87,7 +85,7 @@ function EnterGame.init()
|
||||
for _i, proto in pairs(g_game.getSupportedProtocols()) do
|
||||
protocolBox:addOption(proto)
|
||||
end
|
||||
protocolBox:setCurrentOption(protocol)
|
||||
protocolBox:setCurrentOption(clientVersion)
|
||||
|
||||
-- only open entergame when app starts
|
||||
if not g_app.isRunning() then
|
||||
@@ -142,7 +140,7 @@ function EnterGame.doLogin()
|
||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
local protocol = tonumber(protocolBox:getText())
|
||||
local clientVersion = tonumber(protocolBox:getText())
|
||||
EnterGame.hide()
|
||||
|
||||
if g_game.isOnline() then
|
||||
@@ -153,7 +151,6 @@ function EnterGame.doLogin()
|
||||
|
||||
g_settings.set('host', G.host)
|
||||
g_settings.set('port', G.port)
|
||||
g_settings.set('protocol', protocol)
|
||||
|
||||
local protocolLogin = ProtocolLogin.create()
|
||||
protocolLogin.onError = onError
|
||||
@@ -168,8 +165,7 @@ function EnterGame.doLogin()
|
||||
end })
|
||||
|
||||
g_game.chooseRsa(G.host)
|
||||
g_game.setClientVersion(protocol)
|
||||
modules.game_tibiafiles.load()
|
||||
g_game.setClientVersion(clientVersion)
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||
end
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ function g_settings.getString(key, default)
|
||||
end
|
||||
|
||||
function g_settings.getInteger(key, default)
|
||||
local v = tonumber(g_settings.get(key, default)) or 1
|
||||
local v = tonumber(g_settings.get(key, default)) or 0
|
||||
return v
|
||||
end
|
||||
|
||||
function g_settings.getNumber(key, default)
|
||||
local v = tonumber(g_settings.get(key, default)) or 1
|
||||
local v = tonumber(g_settings.get(key, default)) or 0
|
||||
return v
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
function init()
|
||||
if g_game.getClientVersion() ~= 0 then
|
||||
load()
|
||||
end
|
||||
connect(g_game, { onClientVersionChange = load })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onClientVersionChange = load })
|
||||
end
|
||||
|
||||
function load()
|
||||
|
||||
@@ -5,3 +5,4 @@ Module
|
||||
sandboxed: true
|
||||
scripts: [tibiafiles.lua]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
||||
Reference in New Issue
Block a user