Fix Login problem and use removeEvent (#816)
When trying to logout in battle the player would not logout and tryLogin would be called, so the next time you tryed to login it will still be trying to login
This commit is contained in:
parent
2292df922d
commit
af92792d4a
|
@ -8,6 +8,7 @@ local errorBox
|
||||||
local waitingWindow
|
local waitingWindow
|
||||||
local updateWaitEvent
|
local updateWaitEvent
|
||||||
local resendWaitEvent
|
local resendWaitEvent
|
||||||
|
local loginEvent
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function tryLogin(charInfo, tries)
|
local function tryLogin(charInfo, tries)
|
||||||
|
@ -21,7 +22,7 @@ local function tryLogin(charInfo, tries)
|
||||||
if tries == 1 then
|
if tries == 1 then
|
||||||
g_game.safeLogout()
|
g_game.safeLogout()
|
||||||
end
|
end
|
||||||
scheduleEvent(function() tryLogin(charInfo, tries+1) end, 100)
|
loginEvent = scheduleEvent(function() tryLogin(charInfo, tries+1) end, 100)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -180,15 +181,20 @@ function CharacterList.terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
if updateWaitEvent then
|
if updateWaitEvent then
|
||||||
updateWaitEvent:cancel()
|
removeEvent(updateWaitEvent)
|
||||||
updateWaitEvent = nil
|
updateWaitEvent = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if resendWaitEvent then
|
if resendWaitEvent then
|
||||||
resendWaitEvent:cancel()
|
removeEvent(resendWaitEvent)
|
||||||
resendWaitEvent = nil
|
resendWaitEvent = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if loginEvent then
|
||||||
|
removeEvent(loginEvent)
|
||||||
|
loginEvent = nil
|
||||||
|
end
|
||||||
|
|
||||||
CharacterList = nil
|
CharacterList = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -310,6 +316,10 @@ function CharacterList.doLogin()
|
||||||
worldName = selected.worldName,
|
worldName = selected.worldName,
|
||||||
characterName = selected.characterName }
|
characterName = selected.characterName }
|
||||||
charactersWindow:hide()
|
charactersWindow:hide()
|
||||||
|
if loginEvent then
|
||||||
|
removeEvent(loginEvent)
|
||||||
|
loginEvent = nil
|
||||||
|
end
|
||||||
tryLogin(charInfo)
|
tryLogin(charInfo)
|
||||||
else
|
else
|
||||||
displayErrorBox(tr('Error'), tr('You must select a character to login!'))
|
displayErrorBox(tr('Error'), tr('You must select a character to login!'))
|
||||||
|
@ -330,12 +340,12 @@ function CharacterList.cancelWait()
|
||||||
end
|
end
|
||||||
|
|
||||||
if updateWaitEvent then
|
if updateWaitEvent then
|
||||||
updateWaitEvent:cancel()
|
removeEvent(updateWaitEvent)
|
||||||
updateWaitEvent = nil
|
updateWaitEvent = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if resendWaitEvent then
|
if resendWaitEvent then
|
||||||
resendWaitEvent:cancel()
|
removeEvent(resendWaitEvent)
|
||||||
resendWaitEvent = nil
|
resendWaitEvent = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue