diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 43d8f063..7bd6c4a6 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -123,7 +123,7 @@ function onGameLoginError(message) end end -function onGameConnectionError(message) +function onGameConnectionError(code, message) CharacterList.destroyLoadBox() errorBox = displayErrorBox(tr("Login Error"), message) errorBox.onOk = function() diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 71af60b8..64d6773c 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -7,21 +7,14 @@ local motdButton local enterGameButton -- private functions -local function clearAccountFields() - enterGame:getChildById('accountNameTextEdit'):clearText() - enterGame:getChildById('accountPasswordTextEdit'):clearText() - enterGame:getChildById('accountNameTextEdit'):focus() - g_settings.remove('account') - g_settings.remove('password') -end - -local function onError(protocol, message, connectionError) +local function onError(protocol, message, errorCode) loadBox:destroy() loadBox = nil - if not connectionError then - clearAccountFields() + if not errorCode then + EnterGame.clearAccountFields() end + local errorBox = displayErrorBox(tr('Login Error'), message) connect(errorBox, { onOk = EnterGame.show }) end @@ -38,7 +31,7 @@ local function onCharacterList(protocol, characters, premDays) g_settings.set('password', g_crypt.encrypt(G.password)) g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked()) else - clearAccountFields() + EnterGame.clearAccountFields() end loadBox:destroy() @@ -123,6 +116,15 @@ function EnterGame.openWindow() end end + +function EnterGame.clearAccountFields() + enterGame:getChildById('accountNameTextEdit'):clearText() + enterGame:getChildById('accountPasswordTextEdit'):clearText() + enterGame:getChildById('accountNameTextEdit'):focus() + g_settings.remove('account') + g_settings.remove('password') +end + function EnterGame.doLogin() G.account = enterGame:getChildById('accountNameTextEdit'):getText() G.password = enterGame:getChildById('accountPasswordTextEdit'):getText() diff --git a/modules/game/protocollogin.lua b/modules/game/protocollogin.lua index 2511b651..9c992973 100644 --- a/modules/game/protocollogin.lua +++ b/modules/game/protocollogin.lua @@ -60,7 +60,7 @@ function ProtocolLogin:onRecv(msg) elseif opcode == LoginServerMotd then self:parseMotd(msg) elseif opcode == LoginServerUpdateNeeded then - signalcall(self.onError, self, "Client needs update.", false) + signalcall(self.onError, self, "Client needs update.") elseif opcode == LoginServerCharacterList then self:parseCharacterList(msg) else @@ -77,7 +77,7 @@ end function ProtocolLogin:login(host, port, accountName, accountPassword) if string.len(accountName) == 0 or string.len(accountPassword) == 0 then - signalcall(self.onError, self, "You must enter an account name and password.", false) + signalcall(self.onError, self, "You must enter an account name and password.") return end @@ -94,7 +94,7 @@ end function ProtocolLogin:parseError(msg) local errorMessage = msg:getString() - signalcall(self.onError, self, errorMessage, false) + signalcall(self.onError, self, errorMessage) end function ProtocolLogin:parseMotd(msg) diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 1136fb99..a4daee2d 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -34,9 +34,9 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") IF(USE_STATIC_LIBS) SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++") - MESSAGE("Link to static libraries: ON") + MESSAGE(STATUS "Link to static libraries: ON") ELSE() - MESSAGE("Link to static libraries: OFF") + MESSAGE(STATUS "Link to static libraries: OFF") ENDIF() MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 06edec2d..441c543c 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -242,6 +242,6 @@ void Protocol::onRecv(const InputMessagePtr& inputMessage) void Protocol::onError(const boost::system::error_code& err) { - callLuaField("onError", err.message(), true); + callLuaField("onError", err.message(), err.value()); disconnect(); } diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index c5ca88c8..2594d399 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -64,13 +64,13 @@ void Game::resetGameStates() m_gmActions.clear(); } -void Game::processConnectionError(const boost::system::error_code& error) +void Game::processConnectionError(const boost::system::error_code& ec) { // connection errors only have meaning if we still have a protocol if(m_protocolGame) { // eof = end of file, a clean disconnect - if(error != asio::error::eof) - g_lua.callGlobalField("g_game", "onConnectionError", error.message()); + if(ec != asio::error::eof) + g_lua.callGlobalField("g_game", "onConnectionError", ec.message(), ec.value()); processDisconnect(); } diff --git a/src/otclient/net/protocolgame.cpp b/src/otclient/net/protocolgame.cpp index de92eee0..c4d8c5e7 100644 --- a/src/otclient/net/protocolgame.cpp +++ b/src/otclient/net/protocolgame.cpp @@ -42,6 +42,8 @@ void ProtocolGame::login(const std::string& accountName, const std::string& acco void ProtocolGame::onConnect() { + Protocol::onConnect(); + // must create local player before parsing anything m_localPlayer = LocalPlayerPtr(new LocalPlayer); @@ -56,12 +58,16 @@ void ProtocolGame::onConnect() void ProtocolGame::onRecv(const InputMessagePtr& inputMessage) { + //Protocol::onConnect(inputMessage); + parseMessage(inputMessage); recv(); } void ProtocolGame::onError(const boost::system::error_code& error) { + Protocol::onError(error); + g_game.processConnectionError(error); }