mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
Started 1050 implementation and fix ups:
* Dat now loads (new animations aren't yet functional). * Fixed the way we reference client versions. TODO: Write new animation functionality & find out protocol changes.
This commit is contained in:
@@ -35,7 +35,7 @@ end
|
||||
|
||||
local function onCharacterList(protocol, characters, account, otui)
|
||||
-- Try add server to the server list
|
||||
ServerList.add(G.host, G.port, g_game.getProtocolVersion())
|
||||
ServerList.add(G.host, G.port, g_game.getClientVersion())
|
||||
|
||||
if enterGame:getChildById('rememberPasswordBox'):isChecked() then
|
||||
local account = g_crypt.encrypt(G.account)
|
||||
@@ -82,7 +82,7 @@ local function onUpdateNeeded(protocol, signature)
|
||||
local cancelFunc = EnterGame.show
|
||||
EnterGame.updateFunc(signature, continueFunc, cancelFunc)
|
||||
else
|
||||
local errorBox = displayErrorBox(tr('Update needed'), tr('Your client needs update, try redownloading it.'))
|
||||
local errorBox = displayErrorBox(tr('Update needed'), tr('Your client needs updating, try redownloading it.'))
|
||||
connect(errorBox, { onOk = EnterGame.show })
|
||||
end
|
||||
end
|
||||
@@ -242,7 +242,7 @@ function EnterGame.doLogin()
|
||||
|
||||
g_game.chooseRsa(G.host)
|
||||
g_game.setClientVersion(clientVersion)
|
||||
g_game.setProtocolVersion(g_game.getProtocolVersionForClient(clientVersion))
|
||||
g_game.setProtocolVersion(g_game.getClientProtocolVersion(clientVersion))
|
||||
|
||||
if modules.game_things.isLoaded() then
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||
|
@@ -324,7 +324,7 @@ end
|
||||
|
||||
function openHelp()
|
||||
local helpChannel = 9
|
||||
if g_game.getProtocolVersion() <= 810 then
|
||||
if g_game.getClientVersion() <= 810 then
|
||||
helpChannel = 8
|
||||
end
|
||||
g_game.joinChannel(helpChannel)
|
||||
@@ -1236,7 +1236,7 @@ function online()
|
||||
defaultTab = addTab(tr('Default'), true)
|
||||
serverTab = addTab(tr('Server Log'), false)
|
||||
|
||||
if g_game.getProtocolVersion() < 862 then
|
||||
if g_game.getClientVersion() < 862 then
|
||||
g_keyboard.bindKeyDown('Ctrl+R', openPlayerReportRuleViolationWindow)
|
||||
end
|
||||
-- open last channels
|
||||
@@ -1259,7 +1259,7 @@ function online()
|
||||
end
|
||||
|
||||
function offline()
|
||||
if g_game.getProtocolVersion() < 862 then
|
||||
if g_game.getClientVersion() < 862 then
|
||||
g_keyboard.unbindKeyDown('Ctrl+R')
|
||||
end
|
||||
clear()
|
||||
|
@@ -382,7 +382,7 @@ function doKeyCombo(keyCombo)
|
||||
modules.game_console.setTextEditText(hotKey.value)
|
||||
end
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USE then
|
||||
if g_game.getProtocolVersion() < 780 or hotKey.subType then
|
||||
if g_game.getClientVersion() < 780 or hotKey.subType then
|
||||
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
|
||||
if item then
|
||||
g_game.use(item)
|
||||
@@ -391,7 +391,7 @@ function doKeyCombo(keyCombo)
|
||||
g_game.useInventoryItem(hotKey.itemId)
|
||||
end
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
||||
if g_game.getProtocolVersion() < 780 or hotKey.subType then
|
||||
if g_game.getClientVersion() < 780 or hotKey.subType then
|
||||
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
|
||||
if item then
|
||||
g_game.useWith(item, g_game.getLocalPlayer())
|
||||
@@ -403,7 +403,7 @@ function doKeyCombo(keyCombo)
|
||||
local attackingCreature = g_game.getAttackingCreature()
|
||||
if not attackingCreature then
|
||||
local item = Item.create(hotKey.itemId)
|
||||
if g_game.getProtocolVersion() < 780 or hotKey.subType then
|
||||
if g_game.getClientVersion() < 780 or hotKey.subType then
|
||||
local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
|
||||
if not tmpItem then return end
|
||||
item = tmpItem
|
||||
@@ -414,7 +414,7 @@ function doKeyCombo(keyCombo)
|
||||
end
|
||||
|
||||
if not attackingCreature:getTile() then return end
|
||||
if g_game.getProtocolVersion() < 780 or hotKey.subType then
|
||||
if g_game.getClientVersion() < 780 or hotKey.subType then
|
||||
local item = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
|
||||
if item then
|
||||
g_game.useWith(item, attackingCreature)
|
||||
@@ -424,7 +424,7 @@ function doKeyCombo(keyCombo)
|
||||
end
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||
local item = Item.create(hotKey.itemId)
|
||||
if g_game.getProtocolVersion() < 780 or hotKey.subType then
|
||||
if g_game.getClientVersion() < 780 or hotKey.subType then
|
||||
local tmpItem = g_game.findPlayerItem(hotKey.itemId, hotKey.subType or -1)
|
||||
if not tmpItem then return true end
|
||||
item = tmpItem
|
||||
|
@@ -39,14 +39,14 @@ end
|
||||
-- parsing protocols
|
||||
local function parseMarketEnter(protocol, msg)
|
||||
local balance
|
||||
if g_game.getProtocolVersion() >= 973 then
|
||||
if g_game.getClientVersion() >= 981 then
|
||||
balance = msg:getU64()
|
||||
else
|
||||
balance = msg:getU32()
|
||||
end
|
||||
|
||||
local vocation = -1
|
||||
if g_game.getProtocolVersion() < 950 then
|
||||
if g_game.getClientVersion() < 950 then
|
||||
vocation = msg:getU8() -- get vocation id
|
||||
end
|
||||
local offers = msg:getU8()
|
||||
|
@@ -8,7 +8,8 @@ oldZoom = nil
|
||||
oldPos = nil
|
||||
|
||||
function init()
|
||||
minimapButton = modules.client_topmenu.addRightGameToggleButton('minimapButton', tr('Minimap') .. ' (Ctrl+M)', '/images/topbuttons/minimap', toggle)
|
||||
minimapButton = modules.client_topmenu.addRightGameToggleButton('minimapButton',
|
||||
tr('Minimap') .. ' (Ctrl+M)', '/images/topbuttons/minimap', toggle)
|
||||
minimapButton:setOn(true)
|
||||
|
||||
minimapWindow = g_ui.loadUI('minimap', modules.game_interface.getRightPanel())
|
||||
@@ -95,7 +96,7 @@ function offline()
|
||||
end
|
||||
|
||||
function loadMap(clean)
|
||||
local protocolVersion = g_game.getProtocolVersion()
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
|
||||
if clean then
|
||||
g_minimap.clean()
|
||||
@@ -107,7 +108,7 @@ function loadMap(clean)
|
||||
g_minimap.loadOtmm(minimapFile)
|
||||
end
|
||||
else
|
||||
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
|
||||
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
|
||||
if g_resources.fileExists(minimapFile) then
|
||||
g_map.loadOtcm(minimapFile)
|
||||
end
|
||||
@@ -116,12 +117,12 @@ function loadMap(clean)
|
||||
end
|
||||
|
||||
function saveMap()
|
||||
local protocolVersion = g_game.getProtocolVersion()
|
||||
local clientVersion = g_game.getClientVersion()
|
||||
if otmm then
|
||||
local minimapFile = '/minimap.otmm'
|
||||
g_minimap.saveOtmm(minimapFile)
|
||||
else
|
||||
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
|
||||
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
|
||||
g_map.saveOtcm(minimapFile)
|
||||
end
|
||||
minimapWidget:save()
|
||||
|
@@ -83,7 +83,7 @@ function online()
|
||||
end
|
||||
|
||||
-- Vocation is only send in newer clients
|
||||
if g_game.getProtocolVersion() >= 950 then
|
||||
if g_game.getClientVersion() >= 950 then
|
||||
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
|
||||
else
|
||||
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(false)
|
||||
|
@@ -2,11 +2,11 @@ filename = nil
|
||||
loaded = false
|
||||
|
||||
function init()
|
||||
connect(g_game, { onProtocolVersionChange = load })
|
||||
connect(g_game, { onClientVersionChange = load })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onProtocolVersionChange = load })
|
||||
disconnect(g_game, { onClientVersionChange = load })
|
||||
end
|
||||
|
||||
function setFileName(name)
|
||||
@@ -43,8 +43,9 @@ function load()
|
||||
local messageBox = displayErrorBox(tr('Error'), errorMessage)
|
||||
addEvent(function() messageBox:raise() messageBox:focus() end)
|
||||
|
||||
disconnect(g_game, { onProtocolVersionChange = load })
|
||||
disconnect(g_game, { onClientVersionChange = load })
|
||||
g_game.setClientVersion(0)
|
||||
g_game.setProtocolVersion(0)
|
||||
connect(g_game, { onProtocolVersionChange = load })
|
||||
connect(g_game, { onClientVersionChange = load })
|
||||
end
|
||||
end
|
||||
|
@@ -66,21 +66,40 @@ function g_game.getSupportedClients()
|
||||
1012, 1013, 1020, 1021, 1022,
|
||||
1030, 1031, 1032, 1033, 1034,
|
||||
1035, 1036, 1037, 1038, 1039,
|
||||
1040, 1041
|
||||
1040, 1041, 1050, 1051
|
||||
}
|
||||
end
|
||||
|
||||
function g_game.getProtocolVersionForClient(client)
|
||||
clients = {
|
||||
-- The client version and protocol version where
|
||||
-- unsynchronized for some releases, not sure if this
|
||||
-- will be the normal standard.
|
||||
|
||||
-- Client Version: Publicly given version when
|
||||
-- downloading Cipsoft client.
|
||||
|
||||
-- Protocol Version: Previously was the same as
|
||||
-- the client version, but was unsychronized in some
|
||||
-- releases, now it needs to be verified and added here
|
||||
-- if it does not match the client version.
|
||||
|
||||
-- Reason for defining both: The server now requires a
|
||||
-- Client version and Protocol version from the client.
|
||||
|
||||
-- Important: Use getClientVersion for specific protocol
|
||||
-- features to ensure we are using the proper version.
|
||||
|
||||
function g_game.getClientProtocolVersion(client)
|
||||
local clients = {
|
||||
[980] = 971,
|
||||
[981] = 973,
|
||||
[982] = 974,
|
||||
[983] = 975,
|
||||
[984] = 976,
|
||||
[985] = 977,
|
||||
[986] = 978,
|
||||
[1001] = 979,
|
||||
[1002] = 980,
|
||||
[983] = 975,
|
||||
[984] = 976,
|
||||
[985] = 977,
|
||||
[986] = 978,
|
||||
[1001] = 979,
|
||||
[1002] = 980,
|
||||
[1051] = 1000 -- no idea what protocol version is required (1051 doesn't work)
|
||||
}
|
||||
return clients[client] or client
|
||||
end
|
||||
|
@@ -32,7 +32,7 @@ function ProtocolLogin:sendLoginPacket()
|
||||
|
||||
msg:addU16(g_game.getProtocolVersion())
|
||||
|
||||
if g_game.getProtocolVersion() >= 971 then
|
||||
if g_game.getClientVersion() >= 980 then
|
||||
msg:addU32(g_game.getClientVersion())
|
||||
end
|
||||
|
||||
@@ -40,13 +40,13 @@ function ProtocolLogin:sendLoginPacket()
|
||||
msg:addU32(g_sprites.getSprSignature())
|
||||
msg:addU32(PIC_SIGNATURE)
|
||||
|
||||
if g_game.getProtocolVersion() >= 971 then
|
||||
if g_game.getClientVersion() >= 980 then
|
||||
msg:addU8(0) -- clientType
|
||||
end
|
||||
|
||||
local offset = msg:getMessageSize()
|
||||
|
||||
if g_game.getProtocolVersion() >= 770 then
|
||||
if g_game.getClientVersion() >= 770 then
|
||||
-- first RSA byte must be 0
|
||||
msg:addU8(0)
|
||||
-- xtea key
|
||||
@@ -74,7 +74,7 @@ function ProtocolLogin:sendLoginPacket()
|
||||
local paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
|
||||
assert(paddingBytes >= 0)
|
||||
msg:addPaddingBytes(paddingBytes, 0)
|
||||
if g_game.getProtocolVersion() >= 770 then
|
||||
if g_game.getClientVersion() >= 770 then
|
||||
msg:encryptRsa()
|
||||
end
|
||||
|
||||
@@ -83,7 +83,7 @@ function ProtocolLogin:sendLoginPacket()
|
||||
end
|
||||
|
||||
self:send(msg)
|
||||
if g_game.getProtocolVersion() >= 770 then
|
||||
if g_game.getClientVersion() >= 770 then
|
||||
self:enableXteaEncryption()
|
||||
end
|
||||
self:recv()
|
||||
@@ -131,7 +131,7 @@ end
|
||||
function ProtocolLogin:parseCharacterList(msg)
|
||||
local characters = {}
|
||||
|
||||
if g_game.getProtocolVersion() > 1010 then
|
||||
if g_game.getClientVersion() > 1010 then
|
||||
local worlds = {}
|
||||
|
||||
local worldsCount = msg:getU8()
|
||||
@@ -165,7 +165,7 @@ function ProtocolLogin:parseCharacterList(msg)
|
||||
character.worldIp = iptostring(msg:getU32())
|
||||
character.worldPort = msg:getU16()
|
||||
|
||||
if g_game.getProtocolVersion() >= 971 then
|
||||
if g_game.getClientVersion() >= 980 then
|
||||
character.unknown = msg:getU8()
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user