Support for Protocols up to 10.71, Adventurer Blessing

This commit is contained in:
TheSumm
2014-12-29 18:08:13 +01:00
parent 6ab69b499d
commit 7f3f18f991
21 changed files with 342 additions and 88 deletions

View File

@@ -45,13 +45,17 @@ CharacterWidget < UIWidget
MainWindow
id: charactersWindow
!text: tr('Character List')
size: 250 248
visible: false
@onEnter: CharacterList.doLogin()
@onEscape: CharacterList.hide(true)
@onSetup: |
g_keyboard.bindKeyPress('Up', function() self:getChildById('characters'):focusPreviousChild(KeyboardFocusReason) end, self)
g_keyboard.bindKeyPress('Down', function() self:getChildById('characters'):focusNextChild(KeyboardFocusReason) end, self)
if g_game.getFeature(GamePreviewState) then
self:setSize({width = 350, height = 400})
else
self:setSize({width = 250, height = 248})
end
TextList
id: characters

View File

@@ -59,6 +59,12 @@ local function onCharacterList(protocol, characters, account, otui)
loadBox:destroy()
loadBox = nil
for _, characterInfo in pairs(characters) do
if characterInfo.previewState and characterInfo.previewState ~= PreviewState.Default then
characterInfo.worldName = characterInfo.worldName .. ', Preview'
end
end
CharacterList.create(characters, account, otui)
CharacterList.show()
@@ -105,7 +111,7 @@ function EnterGame.init()
local port = g_settings.get('port')
local autologin = g_settings.getBoolean('autologin')
local clientVersion = g_settings.getInteger('client-version')
if clientVersion == 0 then clientVersion = 860 end
if clientVersion == 0 then clientVersion = 1071 end
if port == nil or port == 0 then port = 7171 end

View File

@@ -17,7 +17,10 @@ inventoryButton = nil
purseButton = nil
function init()
connect(LocalPlayer, { onInventoryChange = onInventoryChange })
connect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
connect(g_game, { onGameStart = refresh })
g_keyboard.bindKeyDown('Ctrl+I', toggle)
@@ -43,7 +46,10 @@ function init()
end
function terminate()
disconnect(LocalPlayer, { onInventoryChange = onInventoryChange })
disconnect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
disconnect(g_game, { onGameStart = refresh })
g_keyboard.unbindKeyDown('Ctrl+I')
@@ -52,6 +58,21 @@ function terminate()
inventoryButton:destroy()
end
function toggleAdventurerStyle(hasBlessing)
for slot = InventorySlotFirst, InventorySlotLast do
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if itemWidget then
if hasBlessing then
itemWidget:setBorderWidth(1)
itemWidget:setBorderColor('#F7C80C')
else
itemWidget:setBorderWidth(0)
itemWidget:setBorderColor('white')
end
end
end
end
function refresh()
local player = g_game.getLocalPlayer()
for i = InventorySlotFirst, InventorySlotPurse do
@@ -60,6 +81,7 @@ function refresh()
else
onInventoryChange(player, i, nil)
end
toggleAdventurerStyle(Bit.hasBit(player:getBlessings(), Blessings.Adventurer))
end
purseButton:setVisible(g_game.getFeature(GamePurseSlot))
@@ -99,3 +121,10 @@ function onInventoryChange(player, slot, item, oldItem)
itemWidget:setItem(nil)
end
end
function onBlessingsChange(player, blessings, oldBlessings)
local hasAdventurerBlessing = Bit.hasBit(blessings, Blessings.Adventurer)
if hasAdventurerBlessing ~= Bit.hasBit(oldBlessings, Blessings.Adventurer) then
toggleAdventurerStyle(hasAdventurerBlessing)
end
end

View File

@@ -120,6 +120,13 @@ GameSpritesAlphaChannel = 56
GamePremiumExpiration = 57
GameBrowseField = 58
GameEnhancedAnimations = 59
GameOGLInformation = 60
GameMessageSizeCheck = 61
GamePreviewState = 62
GameLoginPacketEncryption = 63
GameClientVersion = 64
GameContentRevision = 65
GameExperienceBonus = 66
TextColors = {
red = '#f55e5e', --'#c83200'
@@ -201,7 +208,7 @@ CIPSOFT_RSA = "1321277432058722840622950990822933849527763264961655079678763618"
"88792221429527047321331896351555606801473202394175817"
-- set to the latest Tibia.pic signature to make otclient compatible with official tibia
PIC_SIGNATURE = 0x53208400
PIC_SIGNATURE = 0x542100C1
OsTypes = {
Linux = 1,
@@ -244,4 +251,20 @@ ExtendedIds = {
NeedsUpdate = 7
}
PreviewState = {
Default = 0,
Inactive = 1,
Active = 2
}
Blessings = {
None = 0,
Adventurer = 1,
SpiritualShielding = 2,
EmbraceOfTibia = 4,
FireOfSuns = 8,
WisdomOfSolitude = 16,
SparkOfPhoenix = 32
}
-- @}

View File

@@ -53,38 +53,39 @@ end
function g_game.getSupportedClients()
return {
740, 741, 750, 760, 770, 772,
740, 741, 750, 760, 770, 772,
780, 781, 782, 790, 792,
800, 810, 811, 820, 821, 822,
830, 831, 840, 842, 850, 853,
854, 855, 857, 860, 861, 862,
800, 810, 811, 820, 821, 822,
830, 831, 840, 842, 850, 853,
854, 855, 857, 860, 861, 862,
870, 871,
900, 910, 920, 931, 940, 943,
944, 951, 952, 953, 954, 960,
961, 963, 970, 971, 972, 973,
980, 981, 982, 983, 984, 985,
900, 910, 920, 931, 940, 943,
944, 951, 952, 953, 954, 960,
961, 963, 970, 971, 972, 973,
980, 981, 982, 983, 984, 985,
986,
1000, 1001, 1002, 1010, 1011,
1012, 1013, 1020, 1021, 1022,
1030, 1031, 1032, 1033, 1034,
1035, 1036, 1037, 1038, 1039,
1000, 1001, 1002, 1010, 1011,
1012, 1013, 1020, 1021, 1022,
1030, 1031, 1032, 1033, 1034,
1035, 1036, 1037, 1038, 1039,
1040, 1041, 1050, 1051, 1052,
1053, 1054, 1055, 1056, 1057,
1058, 1059, 1060, 1061
1058, 1059, 1060, 1061, 1062,
1063, 1064, 1070, 1071
}
end
-- The client version and protocol version where
-- unsynchronized for some releases, not sure if this
-- unsynchronized for some releases, not sure if this
-- will be the normal standard.
-- Client Version: Publicly given version when
-- Client Version: Publicly given version when
-- downloading Cipsoft client.
-- Protocol Version: Previously was the same as
-- 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.
@@ -92,7 +93,7 @@ end
-- Reason for defining both: The server now requires a
-- Client version and Protocol version from the client.
-- Important: Use getClientVersion for specific protocol
-- Important: Use getClientVersion for specific protocol
-- features to ensure we are using the proper version.
function g_game.getClientProtocolVersion(client)

View File

@@ -32,23 +32,28 @@ function ProtocolLogin:sendLoginPacket()
msg:addU16(g_game.getProtocolVersion())
if g_game.getClientVersion() >= 980 then
if g_game.getFeature(GameClientVersion) then
msg:addU32(g_game.getClientVersion())
end
msg:addU32(g_things.getDatSignature())
if g_game.getFeature(GameContentRevision) then
msg:addU16(g_things.getContentRevision())
msg:addU16(0)
else
msg:addU32(g_things.getDatSignature())
end
msg:addU32(g_sprites.getSprSignature())
msg:addU32(PIC_SIGNATURE)
if g_game.getClientVersion() >= 980 then
msg:addU8(0) -- clientType
if g_game.getFeature(GamePreviewState) then
msg:addU8(0)
end
local offset = msg:getMessageSize()
if g_game.getClientVersion() >= 770 then
if g_game.getFeature(GameLoginPacketEncryption) then
-- first RSA byte must be 0
msg:addU8(0)
-- xtea key
self:generateXteaKey()
local xteaKey = self:getXteaKey()
@@ -74,16 +79,23 @@ function ProtocolLogin:sendLoginPacket()
local paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
assert(paddingBytes >= 0)
msg:addPaddingBytes(paddingBytes, 0)
if g_game.getClientVersion() >= 770 then
if g_game.getFeature(GameLoginPacketEncryption) then
msg:encryptRsa()
end
if g_game.getFeature(GameOGLInformation) then
msg:addU8(1) --unknown
msg:addU8(1) --unknown
msg:addString(g_graphics.getRenderer())
msg:addString(g_graphics.getVersion())
end
if g_game.getFeature(GameProtocolChecksum) then
self:enableChecksum()
end
self:send(msg)
if g_game.getClientVersion() >= 770 then
if g_game.getFeature(GameLoginPacketEncryption) then
self:enableXteaEncryption()
end
self:recv()
@@ -141,7 +153,7 @@ function ProtocolLogin:parseCharacterList(msg)
world.worldName = msg:getString()
world.worldIp = msg:getString()
world.worldPort = msg:getU16()
msg:getU8() -- unknow byte?
world.previewState = msg:getU8()
worlds[worldId] = world
end
@@ -153,6 +165,7 @@ function ProtocolLogin:parseCharacterList(msg)
character.worldName = worlds[worldId].worldName
character.worldIp = worlds[worldId].worldIp
character.worldPort = worlds[worldId].worldPort
character.previewState = worlds[worldId].previewState
characters[i] = character
end
@@ -165,8 +178,8 @@ function ProtocolLogin:parseCharacterList(msg)
character.worldIp = iptostring(msg:getU32())
character.worldPort = msg:getU16()
if g_game.getClientVersion() >= 980 then
character.unknown = msg:getU8()
if g_game.getFeature(GamePreviewState) then
character.previewState = msg:getU8()
end
characters[i] = character