Add error code to onError protocol event
This commit is contained in:
parent
59f75d996e
commit
e7691b873b
|
@ -123,7 +123,7 @@ function onGameLoginError(message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onGameConnectionError(message)
|
function onGameConnectionError(code, message)
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
errorBox = displayErrorBox(tr("Login Error"), message)
|
errorBox = displayErrorBox(tr("Login Error"), message)
|
||||||
errorBox.onOk = function()
|
errorBox.onOk = function()
|
||||||
|
|
|
@ -7,21 +7,14 @@ local motdButton
|
||||||
local enterGameButton
|
local enterGameButton
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function clearAccountFields()
|
local function onError(protocol, message, errorCode)
|
||||||
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)
|
|
||||||
loadBox:destroy()
|
loadBox:destroy()
|
||||||
loadBox = nil
|
loadBox = nil
|
||||||
|
|
||||||
if not connectionError then
|
if not errorCode then
|
||||||
clearAccountFields()
|
EnterGame.clearAccountFields()
|
||||||
end
|
end
|
||||||
|
|
||||||
local errorBox = displayErrorBox(tr('Login Error'), message)
|
local errorBox = displayErrorBox(tr('Login Error'), message)
|
||||||
connect(errorBox, { onOk = EnterGame.show })
|
connect(errorBox, { onOk = EnterGame.show })
|
||||||
end
|
end
|
||||||
|
@ -38,7 +31,7 @@ local function onCharacterList(protocol, characters, premDays)
|
||||||
g_settings.set('password', g_crypt.encrypt(G.password))
|
g_settings.set('password', g_crypt.encrypt(G.password))
|
||||||
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
|
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
|
||||||
else
|
else
|
||||||
clearAccountFields()
|
EnterGame.clearAccountFields()
|
||||||
end
|
end
|
||||||
|
|
||||||
loadBox:destroy()
|
loadBox:destroy()
|
||||||
|
@ -123,6 +116,15 @@ function EnterGame.openWindow()
|
||||||
end
|
end
|
||||||
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()
|
function EnterGame.doLogin()
|
||||||
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||||
|
|
|
@ -60,7 +60,7 @@ function ProtocolLogin:onRecv(msg)
|
||||||
elseif opcode == LoginServerMotd then
|
elseif opcode == LoginServerMotd then
|
||||||
self:parseMotd(msg)
|
self:parseMotd(msg)
|
||||||
elseif opcode == LoginServerUpdateNeeded then
|
elseif opcode == LoginServerUpdateNeeded then
|
||||||
signalcall(self.onError, self, "Client needs update.", false)
|
signalcall(self.onError, self, "Client needs update.")
|
||||||
elseif opcode == LoginServerCharacterList then
|
elseif opcode == LoginServerCharacterList then
|
||||||
self:parseCharacterList(msg)
|
self:parseCharacterList(msg)
|
||||||
else
|
else
|
||||||
|
@ -77,7 +77,7 @@ end
|
||||||
|
|
||||||
function ProtocolLogin:login(host, port, accountName, accountPassword)
|
function ProtocolLogin:login(host, port, accountName, accountPassword)
|
||||||
if string.len(accountName) == 0 or string.len(accountPassword) == 0 then
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ end
|
||||||
|
|
||||||
function ProtocolLogin:parseError(msg)
|
function ProtocolLogin:parseError(msg)
|
||||||
local errorMessage = msg:getString()
|
local errorMessage = msg:getString()
|
||||||
signalcall(self.onError, self, errorMessage, false)
|
signalcall(self.onError, self, errorMessage)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ProtocolLogin:parseMotd(msg)
|
function ProtocolLogin:parseMotd(msg)
|
||||||
|
|
|
@ -34,9 +34,9 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
|
||||||
|
|
||||||
IF(USE_STATIC_LIBS)
|
IF(USE_STATIC_LIBS)
|
||||||
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
|
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||||
MESSAGE("Link to static libraries: ON")
|
MESSAGE(STATUS "Link to static libraries: ON")
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE("Link to static libraries: OFF")
|
MESSAGE(STATUS "Link to static libraries: OFF")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
||||||
|
|
|
@ -242,6 +242,6 @@ void Protocol::onRecv(const InputMessagePtr& inputMessage)
|
||||||
|
|
||||||
void Protocol::onError(const boost::system::error_code& err)
|
void Protocol::onError(const boost::system::error_code& err)
|
||||||
{
|
{
|
||||||
callLuaField("onError", err.message(), true);
|
callLuaField("onError", err.message(), err.value());
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,13 @@ void Game::resetGameStates()
|
||||||
m_gmActions.clear();
|
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
|
// connection errors only have meaning if we still have a protocol
|
||||||
if(m_protocolGame) {
|
if(m_protocolGame) {
|
||||||
// eof = end of file, a clean disconnect
|
// eof = end of file, a clean disconnect
|
||||||
if(error != asio::error::eof)
|
if(ec != asio::error::eof)
|
||||||
g_lua.callGlobalField("g_game", "onConnectionError", error.message());
|
g_lua.callGlobalField("g_game", "onConnectionError", ec.message(), ec.value());
|
||||||
|
|
||||||
processDisconnect();
|
processDisconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ void ProtocolGame::login(const std::string& accountName, const std::string& acco
|
||||||
|
|
||||||
void ProtocolGame::onConnect()
|
void ProtocolGame::onConnect()
|
||||||
{
|
{
|
||||||
|
Protocol::onConnect();
|
||||||
|
|
||||||
// must create local player before parsing anything
|
// must create local player before parsing anything
|
||||||
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
|
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
|
||||||
|
|
||||||
|
@ -56,12 +58,16 @@ void ProtocolGame::onConnect()
|
||||||
|
|
||||||
void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
|
void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
|
||||||
{
|
{
|
||||||
|
//Protocol::onConnect(inputMessage);
|
||||||
|
|
||||||
parseMessage(inputMessage);
|
parseMessage(inputMessage);
|
||||||
recv();
|
recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::onError(const boost::system::error_code& error)
|
void ProtocolGame::onError(const boost::system::error_code& error)
|
||||||
{
|
{
|
||||||
|
Protocol::onError(error);
|
||||||
|
|
||||||
g_game.processConnectionError(error);
|
g_game.processConnectionError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue