Fix crash when logging without specifing a port or host

This commit is contained in:
Eduardo Bart 2012-07-09 15:06:58 -03:00
parent 2c5fdc88d1
commit 59f75d996e
1 changed files with 9 additions and 1 deletions

View File

@ -74,6 +74,8 @@ function EnterGame.init()
local port = g_settings.get('port') local port = g_settings.get('port')
local autologin = g_settings.getBoolean('autologin') local autologin = g_settings.getBoolean('autologin')
if port == nil or port == 0 then port = 7171 end
enterGame:getChildById('accountNameTextEdit'):setText(account) enterGame:getChildById('accountNameTextEdit'):setText(account)
enterGame:getChildById('accountPasswordTextEdit'):setText(password) enterGame:getChildById('accountPasswordTextEdit'):setText(password)
enterGame:getChildById('serverHostTextEdit'):setText(host) enterGame:getChildById('serverHostTextEdit'):setText(host)
@ -84,7 +86,7 @@ function EnterGame.init()
-- only open entergame when app starts -- only open entergame when app starts
if not g_app.isRunning() then if not g_app.isRunning() then
if #account > 0 and autologin then if #host > 0 and #password > 0 and #account > 0 and autologin then
addEvent(EnterGame.doLogin) addEvent(EnterGame.doLogin)
end end
else else
@ -128,6 +130,12 @@ function EnterGame.doLogin()
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText()) G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
EnterGame.hide() EnterGame.hide()
if G.host == '' or G.port == nil or G.port == 0 then
local errorBox = displayErrorBox(tr('Login Error'), tr('Enter a valid server host and port to login.'))
connect(errorBox, { onOk = EnterGame.show })
return
end
g_settings.set('host', G.host) g_settings.set('host', G.host)
g_settings.set('port', G.port) g_settings.set('port', G.port)