From af92792d4a0348eaa1811979158cfe4c09eca89d Mon Sep 17 00:00:00 2001 From: Joao Pasqualini Costa Date: Thu, 2 Feb 2017 05:59:41 -0200 Subject: [PATCH] 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 --- modules/client_entergame/characterlist.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 35e52ce6..a30f666a 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -8,6 +8,7 @@ local errorBox local waitingWindow local updateWaitEvent local resendWaitEvent +local loginEvent -- private functions local function tryLogin(charInfo, tries) @@ -21,7 +22,7 @@ local function tryLogin(charInfo, tries) if tries == 1 then g_game.safeLogout() end - scheduleEvent(function() tryLogin(charInfo, tries+1) end, 100) + loginEvent = scheduleEvent(function() tryLogin(charInfo, tries+1) end, 100) return end @@ -180,15 +181,20 @@ function CharacterList.terminate() end if updateWaitEvent then - updateWaitEvent:cancel() + removeEvent(updateWaitEvent) updateWaitEvent = nil end if resendWaitEvent then - resendWaitEvent:cancel() + removeEvent(resendWaitEvent) resendWaitEvent = nil end + if loginEvent then + removeEvent(loginEvent) + loginEvent = nil + end + CharacterList = nil end @@ -310,6 +316,10 @@ function CharacterList.doLogin() worldName = selected.worldName, characterName = selected.characterName } charactersWindow:hide() + if loginEvent then + removeEvent(loginEvent) + loginEvent = nil + end tryLogin(charInfo) else displayErrorBox(tr('Error'), tr('You must select a character to login!')) @@ -330,12 +340,12 @@ function CharacterList.cancelWait() end if updateWaitEvent then - updateWaitEvent:cancel() - updateWaitEvent = nil + removeEvent(updateWaitEvent) + updateWaitEvent = nil end if resendWaitEvent then - resendWaitEvent:cancel() + removeEvent(resendWaitEvent) resendWaitEvent = nil end