Add error code to onError protocol event

This commit is contained in:
Eduardo Bart
2012-07-09 19:45:34 -03:00
parent 59f75d996e
commit e7691b873b
7 changed files with 30 additions and 22 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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)