mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
Progress updating to cv981/pv973:
* Implemented the new client AND protocol version methods. * Implemented the new speed laws added in cv980 (http://www.tibia.com/news/?subtopic=newsarchive&id=2251). * Added more missing bytea to login packets (client version/type and some unknown bytes). * Fixed the InputMessage::getDouble method. * Cleaned up some of the const values. * Started on the pending state features. TODO: * Pending game state feature. * Ensure version compatibility hasn't been compromised.
This commit is contained in:
@@ -82,9 +82,9 @@ function Client.terminate()
|
||||
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||
g_settings.set('window-maximized', g_window.isMaximized())
|
||||
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
if clientVersion ~= 0 then
|
||||
g_settings.set('client-version', clientVersion)
|
||||
local protocolVersion = g_game.getProtocolVersion()
|
||||
if protocolVersion ~= 0 then
|
||||
g_settings.set('protocol-version', protocolVersion)
|
||||
end
|
||||
|
||||
Client = nil
|
||||
|
@@ -52,6 +52,11 @@ local function onCharacterList(protocol, characters, account, otui)
|
||||
end
|
||||
end
|
||||
|
||||
local function onChangeProtocol(combobox, option)
|
||||
local clients = g_game.getSupportedClients(option)
|
||||
protocolBox:setTooltip("Supports Client" .. (#clients > 1 and "s" or "") .. ": " .. table.toString(clients))
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function EnterGame.init()
|
||||
enterGame = g_ui.displayUI('entergame.otui')
|
||||
@@ -69,7 +74,7 @@ function EnterGame.init()
|
||||
local host = g_settings.get('host')
|
||||
local port = g_settings.get('port')
|
||||
local autologin = g_settings.getBoolean('autologin')
|
||||
local clientVersion = g_settings.getInteger('client-version')
|
||||
local protocolVersion = g_settings.getInteger('protocol-version')
|
||||
|
||||
if port == nil or port == 0 then port = 7171 end
|
||||
|
||||
@@ -82,12 +87,13 @@ function EnterGame.init()
|
||||
enterGame:getChildById('accountNameTextEdit'):focus()
|
||||
|
||||
protocolBox = enterGame:getChildById('protocolComboBox')
|
||||
protocolBox.onOptionChange = onChangeProtocol
|
||||
for _i, proto in pairs(g_game.getSupportedProtocols()) do
|
||||
protocolBox:addOption(proto)
|
||||
end
|
||||
|
||||
if clientVersion then
|
||||
protocolBox:setCurrentOption(clientVersion)
|
||||
if protocolVersion then
|
||||
protocolBox:setCurrentOption(protocolVersion)
|
||||
end
|
||||
|
||||
enterGame:hide()
|
||||
@@ -153,7 +159,8 @@ function EnterGame.doLogin()
|
||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
local clientVersion = tonumber(protocolBox:getText())
|
||||
local protocolVersion = tonumber(protocolBox:getText())
|
||||
local clientVersions = g_game.getSupportedClients(protocolVersion)
|
||||
EnterGame.hide()
|
||||
|
||||
if g_game.isOnline() then
|
||||
@@ -178,7 +185,10 @@ function EnterGame.doLogin()
|
||||
end })
|
||||
|
||||
g_game.chooseRsa(G.host)
|
||||
g_game.setClientVersion(clientVersion)
|
||||
g_game.setProtocolVersion(protocolVersion)
|
||||
if #clientVersions > 0 then
|
||||
g_game.setClientVersion(clientVersions[#clientVersions])
|
||||
end
|
||||
|
||||
if modules.game_tibiafiles.isLoaded() then
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||
|
@@ -64,7 +64,8 @@ function onConnect(protocol)
|
||||
post = post .. '&world_name=' .. g_game.getWorldName()
|
||||
post = post .. '&otserv_host=' .. G.host
|
||||
post = post .. '&otserv_port=' .. G.port
|
||||
post = post .. '&otserv_protocol=' .. g_game.getClientVersion()
|
||||
post = post .. '&otserv_protocol=' .. g_game.getProtocolVersion()
|
||||
--post = post .. '&otserv_client=' .. g_game.getClientVersion()
|
||||
post = post .. '&build_version=' .. g_app.getVersion()
|
||||
post = post .. '&build_revision=' .. g_app.getBuildRevision()
|
||||
post = post .. '&build_commit=' .. g_app.getBuildCommit()
|
||||
|
@@ -29,7 +29,7 @@ function string:trim()
|
||||
end
|
||||
|
||||
function string:explode(sep, limit)
|
||||
if(type(sep) ~= 'string' or tostring(self):len() == 0 or sep:len() == 0) then
|
||||
if type(sep) ~= 'string' or tostring(self):len() == 0 or sep:len() == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ function string:explode(sep, limit)
|
||||
pos = e + 1
|
||||
|
||||
i = i + 1
|
||||
if(limit ~= nil and i == limit) then
|
||||
if limit ~= nil and i == limit then
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -49,3 +49,4 @@ function string:explode(sep, limit)
|
||||
table.insert(t, tmp)
|
||||
return t
|
||||
end
|
||||
|
||||
|
@@ -92,3 +92,18 @@ function table.empty(t)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function table.toString(t)
|
||||
local maxn = #t
|
||||
local str = ""
|
||||
for k,v in pairs(t) do
|
||||
if k == maxn and k ~= 1 then
|
||||
str = str .. " and " .. v
|
||||
elseif maxn > 1 and k ~= 1 then
|
||||
str = str .. ", " .. v
|
||||
else
|
||||
str = str .. " " .. v
|
||||
end
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
@@ -192,8 +192,8 @@ end
|
||||
|
||||
function addTab(name, focus)
|
||||
local tab = getTab(name)
|
||||
if(tab) then -- is channel already open
|
||||
if(not focus) then focus = true end
|
||||
if tab then -- is channel already open
|
||||
if not focus then focus = true end
|
||||
else
|
||||
tab = consoleTabBar:addTab(name)
|
||||
end
|
||||
|
@@ -39,14 +39,14 @@ end
|
||||
-- parsing protocols
|
||||
local function parseMarketEnter(msg)
|
||||
local balance
|
||||
if(g_game.getClientVersion() >= 980) then
|
||||
if g_game.getProtocolVersion() >= 973 then
|
||||
balance = msg:getU64()
|
||||
else
|
||||
balance = msg:getU32()
|
||||
end
|
||||
|
||||
local vocation = -1
|
||||
if g_game.getClientVersion() < 950 then
|
||||
if g_game.getProtocolVersion() < 950 then
|
||||
vocation = msg:getU8() -- get vocation id
|
||||
end
|
||||
local offers = msg:getU8()
|
||||
|
@@ -182,7 +182,7 @@ function addMapFlag(pos, icon, message, flagId, version)
|
||||
return
|
||||
end
|
||||
|
||||
version = version or g_game.getClientVersion()
|
||||
version = version or g_game.getProtocolVersion()
|
||||
-- Check if flag is set for that position
|
||||
for i = 1, flagsPanel:getChildCount() do
|
||||
local flag = flagsPanel:getChildByIndex(i)
|
||||
@@ -218,7 +218,7 @@ function getMapArea()
|
||||
end
|
||||
|
||||
function isFlagVisible(flag, firstPosition, lastPosition)
|
||||
return flag.version == g_game.getClientVersion() and (minimapWidget:getZoom() >= 30 and minimapWidget:getZoom() <= 150) and flag.position.x >= firstPosition.x and flag.position.x <= lastPosition.x and flag.position.y >= firstPosition.y and flag.position.y <= lastPosition.y and flag.position.z == firstPosition.z
|
||||
return flag.version == g_game.getProtocolVersion() and (minimapWidget:getZoom() >= 30 and minimapWidget:getZoom() <= 150) and flag.position.x >= firstPosition.x and flag.position.x <= lastPosition.x and flag.position.y >= firstPosition.y and flag.position.y <= lastPosition.y and flag.position.z == firstPosition.z
|
||||
end
|
||||
|
||||
function updateMapFlag(id)
|
||||
@@ -267,8 +267,8 @@ function offline()
|
||||
end
|
||||
|
||||
function loadMap()
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
|
||||
local protocolVersion = g_game.getProtocolVersion()
|
||||
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
|
||||
if g_resources.fileExists(minimapFile) then
|
||||
g_map.clean()
|
||||
g_map.loadOtcm(minimapFile)
|
||||
@@ -276,8 +276,8 @@ function loadMap()
|
||||
end
|
||||
|
||||
function saveMap()
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
|
||||
local protocolVersion = g_game.getProtocolVersion()
|
||||
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
|
||||
g_map.saveOtcm(minimapFile)
|
||||
end
|
||||
|
||||
|
@@ -80,7 +80,7 @@ function getIconImageClip(id)
|
||||
end
|
||||
|
||||
function setOptions()
|
||||
if g_game.getClientVersion() >= 950 then -- Vocation is only send in newer clients
|
||||
if g_game.getProtocolVersion() >= 950 then -- Vocation is only send in newer clients
|
||||
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
|
||||
else
|
||||
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(false)
|
||||
|
@@ -118,14 +118,14 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||
end
|
||||
|
||||
local newLineCount = string.count(textEdit:getText(), '\n')
|
||||
if(newLineCount >= 9) then
|
||||
if newLineCount >= 9 then
|
||||
textScroll:setMaximum(newLineCount-9)
|
||||
end
|
||||
|
||||
local _prev, _next = 0, 11
|
||||
local scrollOnValueChange = function(widget, value, delta)
|
||||
local line = getLineByCursorPos(textEdit:getText(), textEdit:getCursorPos(), newLineCount)
|
||||
if(delta > 0) then
|
||||
if delta > 0 then
|
||||
textEdit:setCursorPos(getCursorPosByNewLine(textEdit:getText(), _next + delta - 1))
|
||||
if writeable then textEdit:setCursorPos(getCursorPosByNewLine(textEdit:getText(), line + delta)) end
|
||||
else
|
||||
@@ -180,7 +180,7 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||
return false
|
||||
end
|
||||
|
||||
if(not writeable) then
|
||||
if not writeable then
|
||||
textEdit:setCursorPos(0)
|
||||
textWindow.onKeyPress = onKeyPress -- textEdit won't receive focus
|
||||
else
|
||||
@@ -244,4 +244,4 @@ function onGameEditList(id, doorId, text)
|
||||
okButton.onClick = doneFunc
|
||||
textWindow.onEnter = doneFunc
|
||||
textWindow.onEscape = destroy
|
||||
end
|
||||
end
|
||||
|
@@ -2,11 +2,11 @@ filename = 'Tibia'
|
||||
loaded = false
|
||||
|
||||
function init()
|
||||
connect(g_game, { onClientVersionChange = load })
|
||||
connect(g_game, { onProtocolVersionChange = load })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onClientVersionChange = load })
|
||||
disconnect(g_game, { onProtocolVersionChange = load })
|
||||
end
|
||||
|
||||
function setFileName(name)
|
||||
@@ -18,7 +18,7 @@ function isLoaded()
|
||||
end
|
||||
|
||||
function load()
|
||||
local version = g_game.getClientVersion()
|
||||
local version = g_game.getProtocolVersion()
|
||||
local datPath = resolvepath(version .. '/' .. filename .. '.dat')
|
||||
local sprPath = resolvepath(version .. '/' .. filename .. '.spr')
|
||||
|
||||
@@ -36,8 +36,8 @@ function load()
|
||||
local messageBox = displayErrorBox(tr('Error'), errorMessage)
|
||||
addEvent(function() messageBox:raise() messageBox:focus() end)
|
||||
|
||||
disconnect(g_game, { onClientVersionChange = load })
|
||||
g_game.setClientVersion(0)
|
||||
connect(g_game, { onClientVersionChange = load })
|
||||
disconnect(g_game, { onProtocolVersionChange = load })
|
||||
g_game.setprotocolVersion(0)
|
||||
connect(g_game, { onProtocolVersionChange = load })
|
||||
end
|
||||
end
|
||||
|
@@ -50,8 +50,16 @@ function g_game.getSupportedProtocols()
|
||||
return {
|
||||
810, 853, 854, 860, 861, 862, 870,
|
||||
910, 940, 944, 953, 954, 960, 961,
|
||||
963, 970, 971, 980, 981
|
||||
963, 970, 971, 973
|
||||
}
|
||||
end
|
||||
|
||||
function g_game.getSupportedClients(protocol)
|
||||
clients = {
|
||||
[971] = {980},
|
||||
[973] = {981}
|
||||
}
|
||||
return clients[protocol] or {protocol}
|
||||
end
|
||||
|
||||
g_game.setRsa(OTSERV_RSA)
|
||||
|
@@ -28,7 +28,12 @@ function ProtocolLogin:sendLoginPacket()
|
||||
local msg = OutputMessage.create()
|
||||
msg:addU8(ClientOpcodes.ClientEnterAccount)
|
||||
msg:addU16(g_game.getOsType())
|
||||
msg:addU16(g_game.getClientVersion())
|
||||
msg:addU16(g_game.getProtocolVersion())
|
||||
|
||||
if g_game.getProtocolVersion() >= 971 then
|
||||
msg:addU32(g_game.getClientVersion())
|
||||
msg:addU8(182) -- clientType
|
||||
end
|
||||
|
||||
msg:addU32(g_things.getDatSignature())
|
||||
msg:addU32(g_sprites.getSprSignature())
|
||||
@@ -113,6 +118,11 @@ function ProtocolLogin:parseCharacterList(msg)
|
||||
character.worldIp = iptostring(msg:getU32())
|
||||
character.worldPort = msg:getU16()
|
||||
characters[i] = character
|
||||
|
||||
-- ??
|
||||
if g_game.getProtocolVersion() >= 971 then
|
||||
msg:getU8()
|
||||
end
|
||||
end
|
||||
|
||||
local account = {}
|
||||
|
Reference in New Issue
Block a user