Version 1.6 - important fix for high memory usage

This commit is contained in:
OTCv8
2020-01-01 23:22:56 +01:00
parent d15cc347dc
commit 1d2bdf855d
21 changed files with 83 additions and 322 deletions

View File

@@ -15,7 +15,7 @@ local serverSelector
local clientVersionSelector
local serverHostTextEdit
local rememberPasswordBox
local protos = {"740", "760", "772", "800", "810", "854", "860", "1077", "1090", "1096", "1098", "1099", "1100"}
local protos = {"740", "760", "772", "792", "800", "810", "854", "860", "1077", "1090", "1096", "1098", "1099", "1100"}
local webSocket
local webSocketLoginPacket
@@ -53,10 +53,14 @@ local function onCharacterList(protocol, characters, account, otui)
loadBox:destroy()
loadBox = nil
end
CharacterList.create(characters, account, otui)
CharacterList.create(characters, account, otui, webSocket)
CharacterList.show()
if webSocket then
webSocket = nil
end
g_settings.save()
end
@@ -76,18 +80,22 @@ end
local function validateThings(things)
local incorrectThings = ""
local missingFiles = false
local versionForMissingFiles = 0
if things ~= nil then
local thingsNode = {}
for thingtype, thingdata in pairs(things) do
thingsNode[thingtype] = thingdata[1]
if not g_resources.fileExists("/data/things/" .. thingdata[1]) then
correctThings = false
incorrectThings = incorrectThings .. "Missing file: " .. thingdata[1] .. "\n"
end
local localChecksum = g_resources.fileChecksum("/data/things/" .. thingdata[1]):lower()
if localChecksum ~= thingdata[2]:lower() and #thingdata[2] > 1 then
if g_resources.isLoadedFromArchive() then -- ignore checksum if it's test/debug version
incorrectThings = incorrectThings .. "Invalid checksum of file: " .. thingdata[1] .. " (is " .. localChecksum .. ", should be " .. thingdata[2]:lower() .. ")\n"
missingFiles = true
versionForMissingFiles = thingdata[1]:split("/")[1]
else
local localChecksum = g_resources.fileChecksum("/data/things/" .. thingdata[1]):lower()
if localChecksum ~= thingdata[2]:lower() and #thingdata[2] > 1 then
if g_resources.isLoadedFromArchive() then -- ignore checksum if it's test/debug version
incorrectThings = incorrectThings .. "Invalid checksum of file: " .. thingdata[1] .. " (is " .. localChecksum .. ", should be " .. thingdata[2]:lower() .. ")\n"
end
end
end
end
@@ -95,6 +103,12 @@ local function validateThings(things)
else
g_settings.setNode("things", {})
end
if missingFiles then
incorrectThings = incorrectThings .. "\nYou should open data/things and create directory " .. versionForMissingFiles ..
".\nIn this directory (data/things/" .. versionForMissingFiles .. ") you should put missing\nfiles (Tibia.dat and Tibia.spr) " ..
"from correct Tibia version."
end
return incorrectThings
end
@@ -177,10 +191,6 @@ local function onHTTPResult(data, err)
end
end
if webSocket then
webSocket:close()
webSocket = nil
end
onCharacterList(nil, characters, account, nil)
end
@@ -310,22 +320,16 @@ function EnterGame.checkWebsocket()
if webSocket then
webSocket:close()
webSocket = nil
newLogin.code:setText("")
end
return
end
if webSocket then
if webSocket.url == url then
if newLogin:isHidden() and newLogin.code:getText():len() > 1 then
newLogin:show()
newLogin:raise()
end
return
end
webSocket:close()
webSocket = nil
end
newLogin.code:setText("")
webSocket = HTTP.WebSocketJSON(url, {
onOpen = function(message, webSocketId)
if webSocket and webSocket.id == webSocketId then
@@ -338,8 +342,8 @@ function EnterGame.checkWebsocket()
webSocketLoginPacket = nil
EnterGame.hide()
onHTTPResult(message, nil)
elseif message.type == "quick_login" and message.code and message.qrcode then
EnterGame.showNewLogin(message.code, message.qrcode)
elseif message.type == "quick_login" and message.qrcode then
EnterGame.showNewLogin(message.qrcode)
end
end
end,
@@ -365,10 +369,15 @@ function EnterGame.hideNewLogin()
newLogin:hide()
end
function EnterGame.showNewLogin(code, qrcode)
function EnterGame.showNewLogin(qrcode)
if enterGame:isHidden() then return end
newLogin.code:setText(code)
newLogin.qrcode:setQRCode(qrcode, 1)
newLogin.qrcode:setQRCode("https://quath.co/0/" .. qrcode, 1)
newLogin.qrcode:setEnabled(true)
local clickFunction = function()
g_platform.openUrl("qauth://" .. qrcode)
end
newLogin.qrcode.onClick = clickFunction
newLogin.quathlogo.onClick = clickFunction
if newLogin:isHidden() then
newLogin:show()
newLogin:raise()
@@ -449,7 +458,7 @@ function EnterGame.doLogin()
local incorrectThings = validateThings(things)
if #incorrectThings > 0 then
g_logger.info(incorrectThings)
g_logger.error(incorrectThings)
if Updater then
return Updater.updateThings(things, incorrectThings)
else