mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Protocol 10.72 (Authenticator) Support, Unjustified Points diplay
- Unjustified Points (Better topbar icon would be nice)  - Authenticator token support - adjusted 'can change pvp frame' to 1054 - ...
This commit is contained in:
@@ -27,7 +27,7 @@ local function tryLogin(charInfo, tries)
|
||||
|
||||
CharacterList.hide()
|
||||
|
||||
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName, G.authenticatorToken)
|
||||
|
||||
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
|
||||
connect(loadBox, { onCancel = function()
|
||||
@@ -109,6 +109,16 @@ function onGameLoginError(message)
|
||||
end
|
||||
end
|
||||
|
||||
function onGameLoginToken(unknown)
|
||||
CharacterList.destroyLoadBox()
|
||||
-- TODO: make it possible to enter a new token here / prompt token
|
||||
errorBox = displayErrorBox(tr("Two-Factor Authentification"), 'A new authentification token is required.\nPlease login again.')
|
||||
errorBox.onOk = function()
|
||||
errorBox = nil
|
||||
EnterGame.show()
|
||||
end
|
||||
end
|
||||
|
||||
function onGameConnectionError(message, code)
|
||||
CharacterList.destroyLoadBox()
|
||||
local text = translateNetworkError(code, g_game.getProtocolGame() and g_game.getProtocolGame():isConnecting(), message)
|
||||
@@ -131,6 +141,7 @@ end
|
||||
-- public functions
|
||||
function CharacterList.init()
|
||||
connect(g_game, { onLoginError = onGameLoginError })
|
||||
connect(g_game, { onLoginToken = onGameLoginToken })
|
||||
connect(g_game, { onUpdateNeeded = onGameUpdateNeeded })
|
||||
connect(g_game, { onConnectionError = onGameConnectionError })
|
||||
connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
|
||||
@@ -144,6 +155,7 @@ end
|
||||
|
||||
function CharacterList.terminate()
|
||||
disconnect(g_game, { onLoginError = onGameLoginError })
|
||||
disconnect(g_game, { onLoginToken = onGameLoginToken })
|
||||
disconnect(g_game, { onUpdateNeeded = onGameUpdateNeeded })
|
||||
disconnect(g_game, { onConnectionError = onGameConnectionError })
|
||||
disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox })
|
||||
|
||||
@@ -16,7 +16,7 @@ CharacterWidget < UIWidget
|
||||
|
||||
Label
|
||||
id: name
|
||||
color: #aaaaaa
|
||||
color: #bbbbbb
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
font: verdana-11px-monochrome
|
||||
@@ -29,8 +29,7 @@ CharacterWidget < UIWidget
|
||||
|
||||
Label
|
||||
id: worldName
|
||||
color: #ffffff
|
||||
color: #aaaaaa
|
||||
color: #bbbbbb
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin-right: 5
|
||||
@@ -59,6 +58,7 @@ MainWindow
|
||||
|
||||
TextList
|
||||
id: characters
|
||||
background-color: #565656
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: characterListScrollBar.left
|
||||
|
||||
@@ -111,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 = 1071 end
|
||||
if clientVersion == 0 then clientVersion = 1072 end
|
||||
|
||||
if port == nil or port == 0 then port = 7171 end
|
||||
|
||||
@@ -122,7 +122,10 @@ function EnterGame.init()
|
||||
enterGame:getChildById('serverPortTextEdit'):setText(port)
|
||||
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
|
||||
|
||||
|
||||
clientBox = enterGame:getChildById('clientComboBox')
|
||||
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
|
||||
|
||||
for _, proto in pairs(g_game.getSupportedClients()) do
|
||||
clientBox:addOption(proto)
|
||||
end
|
||||
@@ -152,6 +155,7 @@ end
|
||||
|
||||
function EnterGame.terminate()
|
||||
g_keyboard.unbindKeyDown('Ctrl+G')
|
||||
disconnect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
|
||||
enterGame:destroy()
|
||||
enterGame = nil
|
||||
enterGameButton:destroy()
|
||||
@@ -210,14 +214,55 @@ end
|
||||
function EnterGame.clearAccountFields()
|
||||
enterGame:getChildById('accountNameTextEdit'):clearText()
|
||||
enterGame:getChildById('accountPasswordTextEdit'):clearText()
|
||||
enterGame:getChildById('authenticatorTokenTextEdit'):clearText()
|
||||
enterGame:getChildById('accountNameTextEdit'):focus()
|
||||
g_settings.remove('account')
|
||||
g_settings.remove('password')
|
||||
end
|
||||
|
||||
function EnterGame.toggleAuthenticatorToken(enabled)
|
||||
if enabled == enterGame.authenticatorEnabled then
|
||||
return
|
||||
end
|
||||
|
||||
if enabled then
|
||||
enterGame:getChildById('authenticatorTokenLabel'):setVisible(true)
|
||||
enterGame:getChildById('authenticatorTokenTextEdit'):setVisible(true)
|
||||
|
||||
local serverLabel = enterGame:getChildById('serverLabel')
|
||||
serverLabel:setMarginTop(serverLabel:getMarginTop() + enterGame.authenticatorHeight)
|
||||
|
||||
enterGame:breakAnchors()
|
||||
enterGame:setY(enterGame:getY() - enterGame.authenticatorHeight)
|
||||
enterGame:bindRectToParent()
|
||||
|
||||
enterGame:setHeight(enterGame:getHeight() + enterGame.authenticatorHeight)
|
||||
else
|
||||
enterGame:getChildById('authenticatorTokenLabel'):setVisible(false)
|
||||
enterGame:getChildById('authenticatorTokenTextEdit'):setVisible(false)
|
||||
|
||||
local serverLabel = enterGame:getChildById('serverLabel')
|
||||
serverLabel:setMarginTop(serverLabel:getMarginTop() - enterGame.authenticatorHeight)
|
||||
|
||||
enterGame:breakAnchors()
|
||||
enterGame:setY(enterGame:getY() + enterGame.authenticatorHeight)
|
||||
enterGame:bindRectToParent()
|
||||
|
||||
enterGame:setHeight(enterGame:getHeight() - enterGame.authenticatorHeight)
|
||||
end
|
||||
|
||||
enterGame.authenticatorEnabled = enabled
|
||||
end
|
||||
|
||||
function EnterGame.onClientVersionChange(comboBox, text, data)
|
||||
local clientVersion = tonumber(text)
|
||||
EnterGame.toggleAuthenticatorToken(clientVersion >= 1072)
|
||||
end
|
||||
|
||||
function EnterGame.doLogin()
|
||||
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
G.authenticatorToken = enterGame:getChildById('authenticatorTokenTextEdit'):getText()
|
||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
local clientVersion = tonumber(clientBox:getText())
|
||||
@@ -251,7 +296,7 @@ function EnterGame.doLogin()
|
||||
g_game.chooseRsa(G.host)
|
||||
|
||||
if modules.game_things.isLoaded() then
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken)
|
||||
else
|
||||
loadBox:destroy()
|
||||
loadBox = nil
|
||||
@@ -272,6 +317,7 @@ function EnterGame.setDefaultServer(host, port, protocol)
|
||||
local clientLabel = enterGame:getChildById('clientLabel')
|
||||
local accountTextEdit = enterGame:getChildById('accountNameTextEdit')
|
||||
local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit')
|
||||
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
|
||||
|
||||
if hostTextEdit:getText() ~= host then
|
||||
hostTextEdit:setText(host)
|
||||
@@ -279,6 +325,7 @@ function EnterGame.setDefaultServer(host, port, protocol)
|
||||
clientBox:setCurrentOption(protocol)
|
||||
accountTextEdit:setText('')
|
||||
passwordTextEdit:setText('')
|
||||
authenticatorTokenTextEdit:setText('')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -291,6 +338,13 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
|
||||
portTextEdit:setText(port)
|
||||
portTextEdit:setVisible(false)
|
||||
portTextEdit:setHeight(0)
|
||||
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
|
||||
authenticatorTokenTextEdit:setText('')
|
||||
authenticatorTokenTextEdit:setVisible(false)
|
||||
authenticatorTokenTextEdit:setHeight(0)
|
||||
local authenticatorTokenLabel = enterGame:getChildById('authenticatorTokenLabel')
|
||||
authenticatorTokenLabel:setVisible(false)
|
||||
authenticatorTokenLabel:setHeight(0)
|
||||
|
||||
clientBox:setCurrentOption(protocol)
|
||||
clientBox:setVisible(false)
|
||||
@@ -312,7 +366,7 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
|
||||
serverListButton:setWidth(0)
|
||||
|
||||
local rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
|
||||
rememberPasswordBox:setMarginTop(-5)
|
||||
rememberPasswordBox:setMarginTop(-14)
|
||||
|
||||
if not windowWidth then windowWidth = 236 end
|
||||
enterGame:setWidth(windowWidth)
|
||||
|
||||
@@ -21,6 +21,8 @@ ServerListButton < UIButton
|
||||
|
||||
EnterGameWindow
|
||||
id: enterGame
|
||||
&authenticatorEnabled: false
|
||||
&authenticatorHeight: 44
|
||||
@onEnter: EnterGame.doLogin()
|
||||
|
||||
MenuLabel
|
||||
@@ -50,12 +52,30 @@ EnterGameWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 2
|
||||
|
||||
MenuLabel
|
||||
id: authenticatorTokenLabel
|
||||
!text: tr('Authenticator Token')
|
||||
anchors.left: prev.left
|
||||
anchors.top: prev.bottom
|
||||
text-auto-resize: true
|
||||
margin-top: 8
|
||||
visible: false
|
||||
|
||||
TextEdit
|
||||
id: authenticatorTokenTextEdit
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 2
|
||||
visible: false
|
||||
max-length: 8
|
||||
|
||||
MenuLabel
|
||||
id: serverLabel
|
||||
!text: tr('Server')
|
||||
anchors.left: prev.left
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 8
|
||||
margin-top: -36
|
||||
text-auto-resize: true
|
||||
|
||||
ServerListButton
|
||||
|
||||
@@ -30,5 +30,6 @@ Module
|
||||
- game_spelllist
|
||||
- game_cooldown
|
||||
- game_modaldialog
|
||||
- game_unjustifiedpoints
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
||||
135
modules/game_unjustifiedpoints/unjustifiedpoints.lua
Normal file
135
modules/game_unjustifiedpoints/unjustifiedpoints.lua
Normal file
@@ -0,0 +1,135 @@
|
||||
unjustifiedPointsWindow = nil
|
||||
unjustifiedPointsButton = nil
|
||||
contentsPanel = nil
|
||||
|
||||
openPvpSituationsLabel = nil
|
||||
currentSkullWidget = nil
|
||||
skullTimeLabel = nil
|
||||
|
||||
dayProgressBar = nil
|
||||
weekProgressBar = nil
|
||||
monthProgressBar = nil
|
||||
|
||||
daySkullWidget = nil
|
||||
weekSkullWidget = nil
|
||||
monthSkullWidget = nil
|
||||
|
||||
function init()
|
||||
connect(g_game, { onGameStart = online,
|
||||
onUnjustifiedPointsChange = onUnjustifiedPointsChange,
|
||||
onOpenPvpSituationsChange = onOpenPvpSituationsChange })
|
||||
connect(LocalPlayer, { onSkullChange = onSkullChange } )
|
||||
|
||||
unjustifiedPointsButton = modules.client_topmenu.addRightGameToggleButton('unjustifiedPointsButton',
|
||||
tr('Unjustified Points'), '/images/topbuttons/unjustifiedpoints', toggle)
|
||||
unjustifiedPointsButton:setOn(true)
|
||||
unjustifiedPointsButton:hide()
|
||||
|
||||
unjustifiedPointsWindow = g_ui.loadUI('unjustifiedpoints', modules.game_interface.getRightPanel())
|
||||
unjustifiedPointsWindow:disableResize()
|
||||
unjustifiedPointsWindow:setup()
|
||||
|
||||
contentsPanel = unjustifiedPointsWindow:getChildById('contentsPanel')
|
||||
|
||||
openPvpSituationsLabel = contentsPanel:getChildById('openPvpSituationsLabel')
|
||||
currentSkullWidget = contentsPanel:getChildById('currentSkullWidget')
|
||||
skullTimeLabel = contentsPanel:getChildById('skullTimeLabel')
|
||||
|
||||
dayProgressBar = contentsPanel:getChildById('dayProgressBar')
|
||||
weekProgressBar = contentsPanel:getChildById('weekProgressBar')
|
||||
monthProgressBar = contentsPanel:getChildById('monthProgressBar')
|
||||
daySkullWidget = contentsPanel:getChildById('daySkullWidget')
|
||||
weekSkullWidget = contentsPanel:getChildById('weekSkullWidget')
|
||||
monthSkullWidget = contentsPanel:getChildById('monthSkullWidget')
|
||||
|
||||
if g_game.isOnline() then
|
||||
online()
|
||||
end
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onGameStart = online,
|
||||
onUnjustifiedPointsChange = onUnjustifiedPointsChange,
|
||||
onOpenPvpSituationsChange = onOpenPvpSituationsChange })
|
||||
disconnect(LocalPlayer, { onSkullChange = onSkullChange } )
|
||||
|
||||
unjustifiedPointsWindow:destroy()
|
||||
unjustifiedPointsButton:destroy()
|
||||
end
|
||||
|
||||
function onMiniWindowClose()
|
||||
unjustifiedPointsButton:setOn(false)
|
||||
end
|
||||
|
||||
function toggle()
|
||||
if unjustifiedPointsButton:isOn() then
|
||||
unjustifiedPointsWindow:close()
|
||||
unjustifiedPointsButton:setOn(false)
|
||||
else
|
||||
unjustifiedPointsWindow:open()
|
||||
unjustifiedPointsButton:setOn(true)
|
||||
end
|
||||
end
|
||||
|
||||
function online()
|
||||
if g_game.getFeature(GameUnjustifiedPoints) then
|
||||
unjustifiedPointsButton:show()
|
||||
else
|
||||
unjustifiedPointsButton:hide()
|
||||
unjustifiedPointsWindow:close()
|
||||
end
|
||||
|
||||
refresh()
|
||||
end
|
||||
|
||||
function refresh()
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
|
||||
local unjustifiedPoints = g_game.getUnjustifiedPoints()
|
||||
onUnjustifiedPointsChange(unjustifiedPoints)
|
||||
|
||||
onSkullChange(localPlayer, localPlayer:getSkull())
|
||||
onOpenPvpSituationsChange(g_game.getOpenPvpSituations())
|
||||
end
|
||||
|
||||
function onSkullChange(localPlayer, skull)
|
||||
if not localPlayer:isLocalPlayer() then return end
|
||||
|
||||
if skull == SkullRed or skull == SkullBlack then
|
||||
currentSkullWidget:setIcon(getSkullImagePath(skull))
|
||||
currentSkullWidget:setTooltip('Remaining skull time')
|
||||
else
|
||||
currentSkullWidget:setIcon('')
|
||||
currentSkullWidget:setTooltip('You have no skull')
|
||||
end
|
||||
|
||||
daySkullWidget:setIcon(getSkullImagePath(getNextSkullId(skull)))
|
||||
weekSkullWidget:setIcon(getSkullImagePath(getNextSkullId(skull)))
|
||||
monthSkullWidget:setIcon(getSkullImagePath(getNextSkullId(skull)))
|
||||
end
|
||||
|
||||
function onOpenPvpSituationsChange(amount)
|
||||
openPvpSituationsLabel:setText(amount)
|
||||
end
|
||||
|
||||
function onUnjustifiedPointsChange(unjustifiedPoints)
|
||||
if unjustifiedPoints.skullTime == 0 then
|
||||
skullTimeLabel:setText('No skull')
|
||||
skullTimeLabel:setTooltip('You have no skull')
|
||||
else
|
||||
skullTimeLabel:setText(unjustifiedPoints.skullTime .. ' days')
|
||||
skullTimeLabel:setTooltip('Remaining skull time')
|
||||
end
|
||||
|
||||
dayProgressBar:setValue(unjustifiedPoints.killsDay, 0, 100)
|
||||
dayProgressBar:setTooltip(string.format('Unjustified points gained during the last 24 hours.\n%i kills left.', unjustifiedPoints.killsDayRemaining))
|
||||
dayProgressBar:setText(unjustifiedPoints.killsDayRemaining .. ' kills left')
|
||||
|
||||
weekProgressBar:setValue(unjustifiedPoints.killsWeek, 0, 100)
|
||||
weekProgressBar:setTooltip(string.format('Unjustified points gained during the last 7 days.\n%i kills left.', unjustifiedPoints.killsWeekRemaining))
|
||||
weekProgressBar:setText(unjustifiedPoints.killsWeekRemaining .. ' kills left')
|
||||
|
||||
monthProgressBar:setValue(unjustifiedPoints.killsMonth, 0, 100)
|
||||
monthProgressBar:setTooltip(string.format('Unjustified points gained during the last 30 days.\n%i kills left.', unjustifiedPoints.killsMonthRemaining))
|
||||
monthProgressBar:setText(unjustifiedPoints.killsMonthRemaining .. ' kills left')
|
||||
end
|
||||
8
modules/game_unjustifiedpoints/unjustifiedpoints.otmod
Normal file
8
modules/game_unjustifiedpoints/unjustifiedpoints.otmod
Normal file
@@ -0,0 +1,8 @@
|
||||
Module
|
||||
name: game_unjustifiedpoints
|
||||
description: View unjustified points
|
||||
author: Summ
|
||||
sandboxed: true
|
||||
scripts: [ unjustifiedpoints ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
80
modules/game_unjustifiedpoints/unjustifiedpoints.otui
Normal file
80
modules/game_unjustifiedpoints/unjustifiedpoints.otui
Normal file
@@ -0,0 +1,80 @@
|
||||
SkullProgressBar < ProgressBar
|
||||
height: 13
|
||||
margin: 4 18 0 10
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
SkullWidget < UIWidget
|
||||
size: 13 13
|
||||
margin-right: 2
|
||||
anchors.right: parent.right
|
||||
image-source: /images/game/skull_socket
|
||||
|
||||
MiniWindow
|
||||
id: unjustifiedPointsWindow
|
||||
!text: tr('Unjustified Points')
|
||||
height: 114
|
||||
icon: /images/topbuttons/unjustifiedpoints
|
||||
@onClose: modules.game_unjustifiedpoints.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
Label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
!text: tr('Open PvP')
|
||||
!tooltip: tr('Open PvP Situations')
|
||||
phantom: false
|
||||
margin-top: 2
|
||||
margin-left: 10
|
||||
|
||||
Label
|
||||
id: openPvpSituationsLabel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
font: verdana-11px-rounded
|
||||
margin-left: 12
|
||||
phantom: false
|
||||
|
||||
Label
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
!text: tr('Skull Time')
|
||||
margin-top: 2
|
||||
margin-right: 10
|
||||
|
||||
SkullWidget
|
||||
id: currentSkullWidget
|
||||
anchors.top: prev.bottom
|
||||
margin-right: 10
|
||||
|
||||
Label
|
||||
id: skullTimeLabel
|
||||
anchors.top: prev.top
|
||||
anchors.right: prev.left
|
||||
font: verdana-11px-rounded
|
||||
margin-right: 6
|
||||
phantom: false
|
||||
|
||||
SkullProgressBar
|
||||
id: dayProgressBar
|
||||
margin-top: 10
|
||||
|
||||
SkullWidget
|
||||
id: daySkullWidget
|
||||
anchors.top: prev.top
|
||||
|
||||
SkullProgressBar
|
||||
id: weekProgressBar
|
||||
|
||||
SkullWidget
|
||||
id: weekSkullWidget
|
||||
anchors.top: prev.top
|
||||
|
||||
SkullProgressBar
|
||||
id: monthProgressBar
|
||||
|
||||
SkullWidget
|
||||
id: monthSkullWidget
|
||||
anchors.top: prev.top
|
||||
@@ -127,6 +127,8 @@ GameLoginPacketEncryption = 63
|
||||
GameClientVersion = 64
|
||||
GameContentRevision = 65
|
||||
GameExperienceBonus = 66
|
||||
GameAuthenticator = 67
|
||||
GameUnjustifiedPoints = 68
|
||||
|
||||
TextColors = {
|
||||
red = '#f55e5e', --'#c83200'
|
||||
|
||||
@@ -35,6 +35,13 @@ NpcIconTradeQuest = 4
|
||||
|
||||
-- @}
|
||||
|
||||
function getNextSkullId(skullId)
|
||||
if skullId == SkullRed or skullId == SkullBlack then
|
||||
return SkullBlack
|
||||
end
|
||||
return SkullRed
|
||||
end
|
||||
|
||||
function getSkullImagePath(skullId)
|
||||
local path
|
||||
if skullId == SkullYellow then
|
||||
|
||||
@@ -74,7 +74,7 @@ function g_game.getSupportedClients()
|
||||
1040, 1041, 1050, 1051, 1052,
|
||||
1053, 1054, 1055, 1056, 1057,
|
||||
1058, 1059, 1060, 1061, 1062,
|
||||
1063, 1064, 1070, 1071
|
||||
1063, 1064, 1070, 1071, 1072
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
ProtocolLogin = extends(Protocol, "ProtocolLogin")
|
||||
|
||||
LoginServerError = 10
|
||||
LoginServerTokenSuccess = 12
|
||||
LoginServerTokenError = 13
|
||||
LoginServerUpdate = 17
|
||||
LoginServerMotd = 20
|
||||
LoginServerUpdateNeeded = 30
|
||||
LoginServerCharacterList = 100
|
||||
LoginServerExtendedCharacterList = 101
|
||||
|
||||
function ProtocolLogin:login(host, port, accountName, accountPassword)
|
||||
function ProtocolLogin:login(host, port, accountName, accountPassword, authenticatorToken)
|
||||
if string.len(host) == 0 or port == nil or port == 0 then
|
||||
signalcall(self.onLoginError, self, tr("You must enter a valid server address and port."))
|
||||
return
|
||||
@@ -16,6 +18,7 @@ function ProtocolLogin:login(host, port, accountName, accountPassword)
|
||||
|
||||
self.accountName = accountName
|
||||
self.accountPassword = accountPassword
|
||||
self.authenticatorToken = authenticatorToken
|
||||
self.connectCallback = self.sendLoginPacket
|
||||
|
||||
self:connect(host, port)
|
||||
@@ -78,7 +81,10 @@ function ProtocolLogin:sendLoginPacket()
|
||||
|
||||
local paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
|
||||
assert(paddingBytes >= 0)
|
||||
msg:addPaddingBytes(paddingBytes, 0)
|
||||
for i = 1, paddingBytes do
|
||||
msg:addU8(math.random(0, 0xff))
|
||||
end
|
||||
|
||||
if g_game.getFeature(GameLoginPacketEncryption) then
|
||||
msg:encryptRsa()
|
||||
end
|
||||
@@ -86,10 +92,32 @@ function ProtocolLogin:sendLoginPacket()
|
||||
if g_game.getFeature(GameOGLInformation) then
|
||||
msg:addU8(1) --unknown
|
||||
msg:addU8(1) --unknown
|
||||
msg:addString(g_graphics.getRenderer())
|
||||
|
||||
if g_game.getClientVersion() >= 1072 then
|
||||
msg:addString(string.format('%s %s', g_graphics.getVendor(), g_graphics.getRenderer()))
|
||||
else
|
||||
msg:addString(g_graphics.getRenderer())
|
||||
end
|
||||
msg:addString(g_graphics.getVersion())
|
||||
end
|
||||
|
||||
-- add RSA encrypted auth token
|
||||
if g_game.getFeature(GameAuthenticator) then
|
||||
offset = msg:getMessageSize()
|
||||
|
||||
-- first RSA byte must be 0
|
||||
msg:addU8(0)
|
||||
msg:addString(self.authenticatorToken)
|
||||
|
||||
paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
|
||||
assert(paddingBytes >= 0)
|
||||
for i = 1, paddingBytes do
|
||||
msg:addU8(math.random(0, 0xff))
|
||||
end
|
||||
|
||||
msg:encryptRsa()
|
||||
end
|
||||
|
||||
if g_game.getFeature(GameProtocolChecksum) then
|
||||
self:enableChecksum()
|
||||
end
|
||||
@@ -116,6 +144,9 @@ function ProtocolLogin:onRecv(msg)
|
||||
self:parseMotd(msg)
|
||||
elseif opcode == LoginServerUpdateNeeded then
|
||||
signalcall(self.onLoginError, self, tr("Client needs update."))
|
||||
elseif opcode == LoginServerTokenError then
|
||||
-- TODO: prompt for token here
|
||||
signalcall(self.onLoginError, self, tr("Invalid authentification token."))
|
||||
elseif opcode == LoginServerCharacterList then
|
||||
self:parseCharacterList(msg)
|
||||
elseif opcode == LoginServerExtendedCharacterList then
|
||||
|
||||
Reference in New Issue
Block a user