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

@@ -31,14 +31,6 @@ local function tryLogin(charInfo, tries)
CharacterList.hide()
-- proxies for not http login users
if charInfo.worldHost == "0.0.0.0" and g_proxy then
g_proxy.clear()
-- g_proxy.addProxy(proxyHost, proxyPort, proxyPriority)
g_proxy.addProxy("163.172.147.135", 7162, 0)
g_proxy.addProxy("158.69.68.42", 7162, 0)
end
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName, G.authenticatorToken, G.sessionKey)
g_logger.info("Login to " .. charInfo.worldHost .. ":" .. charInfo.worldPort)
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
@@ -243,9 +235,11 @@ function CharacterList.terminate()
CharacterList = nil
end
function CharacterList.create(characters, account, otui)
function CharacterList.create(characters, account, otui, websocket)
if not otui then otui = 'characterlist' end
if websocket then
websocket:close()
end
if charactersWindow then
charactersWindow:destroy()
end

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

View File

@@ -3,11 +3,11 @@ StaticWindow
anchors.verticalCenter: parent.verticalCenter
margin-right: 20
id: newLoginPanel
width: 230
height: 350
width: 240
height: 320
!text: tr('Quick Login & Registration')
Label
UIButton
id: qrcode
width: 200
height: 200
@@ -17,7 +17,7 @@ StaticWindow
image-smooth: false
margin-top: 5
Label
UIButton
id: quathlogo
width: 66
height: 40
@@ -33,28 +33,18 @@ StaticWindow
anchors.right: qrcode.right
text-align: center
text-auto-resize: true
!text: tr("Scan QR code or process\nbellow code to register or login")
!text: tr("Scan or click QR code\nto register or login")
height: 40
margin-top: 10
margin-bottom: 5
Label
id: code
height: 20
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: prev.right
text-align: center
font: sans-bold-16px
margin-top: 10
text: XXXXXX
Label
Button
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: prev.right
anchors.left: parent.left
anchors.right: parent.right
text-align: center
!text: tr("Click to get Android/iOS app")
!text: tr("Click to get PC/Android/iOS app")
height: 20
margin-top: 10
color: #FFFFFF
color: #FFFFFF
@onClick: g_platform.openUrl("http://qauth.co")

View File

@@ -116,6 +116,7 @@ function sendStats()
classic = tostring(g_settings.getBoolean("classicView")),
fullscreen = tostring(g_window.isFullscreen()),
vsync = tostring(g_settings.getBoolean("vsync")),
autoReconnect = tostring(g_settings.getBoolean("autoReconnect")),
window_width = g_window.getWidth(),
window_height = g_window.getHeight(),
player_name = g_game.getCharacterName(),
@@ -132,7 +133,8 @@ function sendStats()
cpu = g_platform.getCPUName(),
mem = g_platform.getTotalSystemMemory(),
mem_usage = g_platform.getMemoryUsage(),
os_name = g_platform.getOSName()
os_name = g_platform.getOSName(),
uptime = g_clock.seconds()
}
}
if g_proxy then

View File

@@ -9,9 +9,9 @@ end
function updateFeatures(version)
g_game.resetFeatures()
-- you can add custom features here, list of them in modules\gamelib\const.lua
-- you can add custom features here, list of them is in the modules\gamelib\const.lua
g_game.enableFeature(GameBot)
g_game.enableFeature(GameMinimapLimitedToSingleFloor)
--g_game.enableFeature(GameMinimapLimitedToSingleFloor) -- it will generate minimap only for current floor
--g_game.enableFeature(GameSpritesAlphaChannel)
if(version >= 770) then
@@ -91,6 +91,10 @@ function updateFeatures(version)
g_game.enableFeature(GameAdditionalVipInfo)
end
if(version >= 972) then
g_game.enableFeature(GameDoublePlayerGoodsMoney)
end
if(version >= 980) then
g_game.enableFeature(GamePreviewState)
g_game.enableFeature(GameClientVersion)

View File

@@ -67,7 +67,12 @@ end
function bindKeys()
gameRootPanel:setAutoRepeatDelay(10)
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
local lastAction = 0
g_keyboard.bindKeyPress('Escape', function()
if lastAction + 50 > g_clock.millis() then return end
lastAction = g_clock.millis()
g_game.cancelAttackAndFollow()
end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+=', function() if g_game.getFeature(GameNoDebug) then return end gameMapPanel:zoomIn() end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+-', function() if g_game.getFeature(GameNoDebug) then return end gameMapPanel:zoomOut() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+Q', function() tryLogout(false) end, gameRootPanel)

View File

@@ -7,6 +7,7 @@ lastFinishedStep = 0
autoWalkEvent = nil
firstStep = true
walkLock = 0
walkEvent = nil
lastWalk = 0
lastTurn = 0
lastTurnDirection = 0
@@ -202,7 +203,7 @@ function changeWalkDir(dir, pop)
end
function smartWalk(dir)
scheduleEvent(function()
walkEvent = scheduleEvent(function()
if g_keyboard.getModifiers() == KeyboardNoModifier then
local direction = smartWalkDir or dir
walk(direction)
@@ -371,6 +372,8 @@ function turn(dir, repeated)
return
end
removeEvent(walkEvent)
if not repeated or (lastTurn + 100 < g_clock.millis()) then
g_game.turn(dir)
changeWalkDir(dir)

View File

@@ -162,6 +162,10 @@ GamePrey = 78
GameExtendedOpcode = 80
GameMinimapLimitedToSingleFloor = 81
GameDoubleLevel = 83
GameDoubleSoul = 84
GameDoublePlayerGoodsMoney = 85
GameNewWalking = 90
GameSlowerManualWalking = 91
GameExtendedNewWalking = 92