Avoid spr loading freeze when logging
This commit is contained in:
parent
49a8c750f9
commit
90312965bc
|
@ -37,6 +37,11 @@ function Client.init()
|
||||||
g_window.setIcon(resolvepath('clienticon.png'))
|
g_window.setIcon(resolvepath('clienticon.png'))
|
||||||
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
|
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 =
|
connect(g_app, { onRun =
|
||||||
function()
|
function()
|
||||||
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
-- 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-size', g_window.getUnmaximizedSize())
|
||||||
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||||
g_settings.set('window-maximized', g_window.isMaximized())
|
g_settings.set('window-maximized', g_window.isMaximized())
|
||||||
|
g_settings.set('client-version', g_game.getClientVersion())
|
||||||
Client = nil
|
Client = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,11 +67,9 @@ function EnterGame.init()
|
||||||
local host = g_settings.get('host')
|
local host = g_settings.get('host')
|
||||||
local port = g_settings.get('port')
|
local port = g_settings.get('port')
|
||||||
local autologin = g_settings.getBoolean('autologin')
|
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
|
if not clientVersion or clientVersion == 0 then clientVersion = 960 end
|
||||||
protocol = 860
|
|
||||||
end
|
|
||||||
|
|
||||||
if port == nil or port == 0 then port = 7171 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
|
for _i, proto in pairs(g_game.getSupportedProtocols()) do
|
||||||
protocolBox:addOption(proto)
|
protocolBox:addOption(proto)
|
||||||
end
|
end
|
||||||
protocolBox:setCurrentOption(protocol)
|
protocolBox:setCurrentOption(clientVersion)
|
||||||
|
|
||||||
-- only open entergame when app starts
|
-- only open entergame when app starts
|
||||||
if not g_app.isRunning() then
|
if not g_app.isRunning() then
|
||||||
|
@ -142,7 +140,7 @@ function EnterGame.doLogin()
|
||||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||||
local protocol = tonumber(protocolBox:getText())
|
local clientVersion = tonumber(protocolBox:getText())
|
||||||
EnterGame.hide()
|
EnterGame.hide()
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
|
@ -153,7 +151,6 @@ function EnterGame.doLogin()
|
||||||
|
|
||||||
g_settings.set('host', G.host)
|
g_settings.set('host', G.host)
|
||||||
g_settings.set('port', G.port)
|
g_settings.set('port', G.port)
|
||||||
g_settings.set('protocol', protocol)
|
|
||||||
|
|
||||||
local protocolLogin = ProtocolLogin.create()
|
local protocolLogin = ProtocolLogin.create()
|
||||||
protocolLogin.onError = onError
|
protocolLogin.onError = onError
|
||||||
|
@ -168,8 +165,7 @@ function EnterGame.doLogin()
|
||||||
end })
|
end })
|
||||||
|
|
||||||
g_game.chooseRsa(G.host)
|
g_game.chooseRsa(G.host)
|
||||||
g_game.setClientVersion(protocol)
|
g_game.setClientVersion(clientVersion)
|
||||||
modules.game_tibiafiles.load()
|
|
||||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,12 @@ function g_settings.getString(key, default)
|
||||||
end
|
end
|
||||||
|
|
||||||
function g_settings.getInteger(key, default)
|
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
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
function g_settings.getNumber(key, default)
|
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
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
function init()
|
function init()
|
||||||
if g_game.getClientVersion() ~= 0 then
|
connect(g_game, { onClientVersionChange = load })
|
||||||
load()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function terminate()
|
||||||
|
disconnect(g_game, { onClientVersionChange = load })
|
||||||
end
|
end
|
||||||
|
|
||||||
function load()
|
function load()
|
||||||
|
|
|
@ -5,3 +5,4 @@ Module
|
||||||
sandboxed: true
|
sandboxed: true
|
||||||
scripts: [tibiafiles.lua]
|
scripts: [tibiafiles.lua]
|
||||||
@onLoad: init()
|
@onLoad: init()
|
||||||
|
@onUnload: terminate()
|
||||||
|
|
|
@ -39,7 +39,7 @@ Game g_game;
|
||||||
Game::Game()
|
Game::Game()
|
||||||
{
|
{
|
||||||
resetGameStates();
|
resetGameStates();
|
||||||
m_protocolVersion = 0;
|
m_clientVersion = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::terminate()
|
void Game::terminate()
|
||||||
|
@ -430,7 +430,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
|
||||||
if(m_protocolGame || isOnline())
|
if(m_protocolGame || isOnline())
|
||||||
stdext::throw_exception("Unable to login into a world while already online or logging.");
|
stdext::throw_exception("Unable to login into a world while already online or logging.");
|
||||||
|
|
||||||
if(m_protocolVersion == 0)
|
if(m_clientVersion == 0)
|
||||||
stdext::throw_exception("Must set a valid game protocol version before logging.");
|
stdext::throw_exception("Must set a valid game protocol version before logging.");
|
||||||
|
|
||||||
// reset the new game state
|
// reset the new game state
|
||||||
|
@ -1123,6 +1123,9 @@ bool Game::canPerformGameAction()
|
||||||
|
|
||||||
void Game::setClientVersion(int version)
|
void Game::setClientVersion(int version)
|
||||||
{
|
{
|
||||||
|
if(m_clientVersion == version)
|
||||||
|
return;
|
||||||
|
|
||||||
if(isOnline())
|
if(isOnline())
|
||||||
stdext::throw_exception("Unable to change client version while online");
|
stdext::throw_exception("Unable to change client version while online");
|
||||||
|
|
||||||
|
@ -1175,7 +1178,7 @@ void Game::setClientVersion(int version)
|
||||||
enableFeature(Otc::GameOfflineTrainingTime);
|
enableFeature(Otc::GameOfflineTrainingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_protocolVersion = version;
|
m_clientVersion = version;
|
||||||
|
|
||||||
Proto::buildMessageModesMap(version);
|
Proto::buildMessageModesMap(version);
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ public:
|
||||||
bool getFeature(Otc::GameFeature feature) { return m_features.test(feature); }
|
bool getFeature(Otc::GameFeature feature) { return m_features.test(feature); }
|
||||||
|
|
||||||
void setClientVersion(int version);
|
void setClientVersion(int version);
|
||||||
int getClientVersion() { return m_protocolVersion; }
|
int getClientVersion() { return m_clientVersion; }
|
||||||
|
|
||||||
bool canPerformGameAction();
|
bool canPerformGameAction();
|
||||||
bool checkBotProtection();
|
bool checkBotProtection();
|
||||||
|
@ -297,7 +297,7 @@ private:
|
||||||
std::string m_characterName;
|
std::string m_characterName;
|
||||||
std::string m_worldName;
|
std::string m_worldName;
|
||||||
std::bitset<Otc::LastGameFeature> m_features;
|
std::bitset<Otc::LastGameFeature> m_features;
|
||||||
int m_protocolVersion;
|
int m_clientVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Game g_game;
|
extern Game g_game;
|
||||||
|
|
Loading…
Reference in New Issue