Full protocol 10.74 support (session key), entergame style fixes
This commit is contained in:
parent
64e9406488
commit
71931b961a
|
@ -27,7 +27,7 @@ local function tryLogin(charInfo, tries)
|
||||||
|
|
||||||
CharacterList.hide()
|
CharacterList.hide()
|
||||||
|
|
||||||
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName, G.authenticatorToken)
|
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName, G.authenticatorToken, G.sessionKey)
|
||||||
|
|
||||||
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
|
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
|
||||||
connect(loadBox, { onCancel = function()
|
connect(loadBox, { onCancel = function()
|
||||||
|
|
|
@ -33,10 +33,17 @@ local function onMotd(protocol, motd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function onSessionKey(protocol, sessionKey)
|
||||||
|
G.sessionKey = sessionKey
|
||||||
|
end
|
||||||
|
|
||||||
local function onCharacterList(protocol, characters, account, otui)
|
local function onCharacterList(protocol, characters, account, otui)
|
||||||
-- Try add server to the server list
|
-- Try add server to the server list
|
||||||
ServerList.add(G.host, G.port, g_game.getClientVersion())
|
ServerList.add(G.host, G.port, g_game.getClientVersion())
|
||||||
|
|
||||||
|
-- Save 'Stay logged in' setting
|
||||||
|
g_settings.set('staylogged', enterGame:getChildById('stayLoggedBox'):isChecked())
|
||||||
|
|
||||||
if enterGame:getChildById('rememberPasswordBox'):isChecked() then
|
if enterGame:getChildById('rememberPasswordBox'):isChecked() then
|
||||||
local account = g_crypt.encrypt(G.account)
|
local account = g_crypt.encrypt(G.account)
|
||||||
local password = g_crypt.encrypt(G.password)
|
local password = g_crypt.encrypt(G.password)
|
||||||
|
@ -109,9 +116,10 @@ function EnterGame.init()
|
||||||
local password = g_settings.get('password')
|
local password = g_settings.get('password')
|
||||||
local host = g_settings.get('host')
|
local host = g_settings.get('host')
|
||||||
local port = g_settings.get('port')
|
local port = g_settings.get('port')
|
||||||
|
local stayLogged = g_settings.getBoolean('staylogged')
|
||||||
local autologin = g_settings.getBoolean('autologin')
|
local autologin = g_settings.getBoolean('autologin')
|
||||||
local clientVersion = g_settings.getInteger('client-version')
|
local clientVersion = g_settings.getInteger('client-version')
|
||||||
if clientVersion == 0 then clientVersion = 1072 end
|
if clientVersion == 0 then clientVersion = 1074 end
|
||||||
|
|
||||||
if port == nil or port == 0 then port = 7171 end
|
if port == nil or port == 0 then port = 7171 end
|
||||||
|
|
||||||
|
@ -121,7 +129,7 @@ function EnterGame.init()
|
||||||
enterGame:getChildById('serverHostTextEdit'):setText(host)
|
enterGame:getChildById('serverHostTextEdit'):setText(host)
|
||||||
enterGame:getChildById('serverPortTextEdit'):setText(port)
|
enterGame:getChildById('serverPortTextEdit'):setText(port)
|
||||||
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
|
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
|
||||||
|
enterGame:getChildById('stayLoggedBox'):setChecked(stayLogged)
|
||||||
|
|
||||||
clientBox = enterGame:getChildById('clientComboBox')
|
clientBox = enterGame:getChildById('clientComboBox')
|
||||||
for _, proto in pairs(g_game.getSupportedClients()) do
|
for _, proto in pairs(g_game.getSupportedClients()) do
|
||||||
|
@ -130,6 +138,7 @@ function EnterGame.init()
|
||||||
clientBox:setCurrentOption(clientVersion)
|
clientBox:setCurrentOption(clientVersion)
|
||||||
|
|
||||||
EnterGame.toggleAuthenticatorToken(clientVersion, true)
|
EnterGame.toggleAuthenticatorToken(clientVersion, true)
|
||||||
|
EnterGame.toggleStayLoggedBox(clientVersion, true)
|
||||||
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
|
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
|
||||||
|
|
||||||
enterGame:hide()
|
enterGame:hide()
|
||||||
|
@ -227,48 +236,68 @@ function EnterGame.toggleAuthenticatorToken(clientVersion, init)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
enterGame:getChildById('authenticatorTokenLabel'):setOn(enabled)
|
||||||
|
enterGame:getChildById('authenticatorTokenTextEdit'):setOn(enabled)
|
||||||
|
|
||||||
|
local newHeight = enterGame:getHeight()
|
||||||
|
local newY = enterGame:getY()
|
||||||
if enabled then
|
if enabled then
|
||||||
enterGame:getChildById('authenticatorTokenLabel'):setVisible(true)
|
newY = newY - enterGame.authenticatorHeight
|
||||||
enterGame:getChildById('authenticatorTokenTextEdit'):setVisible(true)
|
newHeight = newHeight + enterGame.authenticatorHeight
|
||||||
|
|
||||||
local serverLabel = enterGame:getChildById('serverLabel')
|
|
||||||
serverLabel:setMarginTop(serverLabel:getMarginTop() + enterGame.authenticatorHeight)
|
|
||||||
|
|
||||||
if not init then
|
|
||||||
enterGame:breakAnchors()
|
|
||||||
enterGame:setY(enterGame:getY() - enterGame.authenticatorHeight)
|
|
||||||
enterGame:bindRectToParent()
|
|
||||||
end
|
|
||||||
|
|
||||||
enterGame:setHeight(enterGame:getHeight() + enterGame.authenticatorHeight)
|
|
||||||
else
|
else
|
||||||
enterGame:getChildById('authenticatorTokenLabel'):setVisible(false)
|
newY = newY + enterGame.authenticatorHeight
|
||||||
enterGame:getChildById('authenticatorTokenTextEdit'):setVisible(false)
|
newHeight = newHeight - enterGame.authenticatorHeight
|
||||||
|
|
||||||
local serverLabel = enterGame:getChildById('serverLabel')
|
|
||||||
serverLabel:setMarginTop(serverLabel:getMarginTop() - enterGame.authenticatorHeight)
|
|
||||||
|
|
||||||
if not init then
|
|
||||||
enterGame:breakAnchors()
|
|
||||||
enterGame:setY(enterGame:getY() + enterGame.authenticatorHeight)
|
|
||||||
enterGame:bindRectToParent()
|
|
||||||
end
|
|
||||||
|
|
||||||
enterGame:setHeight(enterGame:getHeight() - enterGame.authenticatorHeight)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not init then
|
||||||
|
enterGame:breakAnchors()
|
||||||
|
enterGame:setY(newY)
|
||||||
|
enterGame:bindRectToParent()
|
||||||
|
end
|
||||||
|
enterGame:setHeight(newHeight)
|
||||||
|
|
||||||
enterGame.authenticatorEnabled = enabled
|
enterGame.authenticatorEnabled = enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EnterGame.toggleStayLoggedBox(clientVersion, init)
|
||||||
|
local enabled = (clientVersion >= 1074)
|
||||||
|
if enabled == enterGame.stayLoggedBoxEnabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
enterGame:getChildById('stayLoggedBox'):setOn(enabled)
|
||||||
|
|
||||||
|
local newHeight = enterGame:getHeight()
|
||||||
|
local newY = enterGame:getY()
|
||||||
|
if enabled then
|
||||||
|
newY = newY - enterGame.stayLoggedBoxHeight
|
||||||
|
newHeight = newHeight + enterGame.stayLoggedBoxHeight
|
||||||
|
else
|
||||||
|
newY = newY + enterGame.stayLoggedBoxHeight
|
||||||
|
newHeight = newHeight - enterGame.stayLoggedBoxHeight
|
||||||
|
end
|
||||||
|
|
||||||
|
if not init then
|
||||||
|
enterGame:breakAnchors()
|
||||||
|
enterGame:setY(newY)
|
||||||
|
enterGame:bindRectToParent()
|
||||||
|
end
|
||||||
|
enterGame:setHeight(newHeight)
|
||||||
|
|
||||||
|
enterGame.stayLoggedBoxEnabled = enabled
|
||||||
|
end
|
||||||
|
|
||||||
function EnterGame.onClientVersionChange(comboBox, text, data)
|
function EnterGame.onClientVersionChange(comboBox, text, data)
|
||||||
local clientVersion = tonumber(text)
|
local clientVersion = tonumber(text)
|
||||||
EnterGame.toggleAuthenticatorToken(clientVersion)
|
EnterGame.toggleAuthenticatorToken(clientVersion)
|
||||||
|
EnterGame.toggleStayLoggedBox(clientVersion)
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnterGame.doLogin()
|
function EnterGame.doLogin()
|
||||||
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||||
G.authenticatorToken = enterGame:getChildById('authenticatorTokenTextEdit'):getText()
|
G.authenticatorToken = enterGame:getChildById('authenticatorTokenTextEdit'):getText()
|
||||||
|
G.stayLogged = enterGame:getChildById('stayLoggedBox'):isChecked()
|
||||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||||
local clientVersion = tonumber(clientBox:getText())
|
local clientVersion = tonumber(clientBox:getText())
|
||||||
|
@ -287,6 +316,7 @@ function EnterGame.doLogin()
|
||||||
protocolLogin = ProtocolLogin.create()
|
protocolLogin = ProtocolLogin.create()
|
||||||
protocolLogin.onLoginError = onError
|
protocolLogin.onLoginError = onError
|
||||||
protocolLogin.onMotd = onMotd
|
protocolLogin.onMotd = onMotd
|
||||||
|
protocolLogin.onSessionKey = onSessionKey
|
||||||
protocolLogin.onCharacterList = onCharacterList
|
protocolLogin.onCharacterList = onCharacterList
|
||||||
protocolLogin.onUpdateNeeded = onUpdateNeeded
|
protocolLogin.onUpdateNeeded = onUpdateNeeded
|
||||||
|
|
||||||
|
@ -302,7 +332,7 @@ function EnterGame.doLogin()
|
||||||
g_game.chooseRsa(G.host)
|
g_game.chooseRsa(G.host)
|
||||||
|
|
||||||
if modules.game_things.isLoaded() then
|
if modules.game_things.isLoaded() then
|
||||||
protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken)
|
protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken, G.stayLogged)
|
||||||
else
|
else
|
||||||
loadBox:destroy()
|
loadBox:destroy()
|
||||||
loadBox = nil
|
loadBox = nil
|
||||||
|
@ -344,13 +374,16 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
|
||||||
portTextEdit:setText(port)
|
portTextEdit:setText(port)
|
||||||
portTextEdit:setVisible(false)
|
portTextEdit:setVisible(false)
|
||||||
portTextEdit:setHeight(0)
|
portTextEdit:setHeight(0)
|
||||||
|
|
||||||
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
|
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
|
||||||
authenticatorTokenTextEdit:setText('')
|
authenticatorTokenTextEdit:setText('')
|
||||||
authenticatorTokenTextEdit:setVisible(false)
|
authenticatorTokenTextEdit:setOn(false)
|
||||||
authenticatorTokenTextEdit:setHeight(0)
|
|
||||||
local authenticatorTokenLabel = enterGame:getChildById('authenticatorTokenLabel')
|
local authenticatorTokenLabel = enterGame:getChildById('authenticatorTokenLabel')
|
||||||
authenticatorTokenLabel:setVisible(false)
|
authenticatorTokenLabel:setOn(false)
|
||||||
authenticatorTokenLabel:setHeight(0)
|
|
||||||
|
local stayLoggedBox = enterGame:getChildById('stayLoggedBox')
|
||||||
|
stayLoggedBox:setChecked(false)
|
||||||
|
stayLoggedBox:setOn(false)
|
||||||
|
|
||||||
clientBox:setCurrentOption(protocol)
|
clientBox:setCurrentOption(protocol)
|
||||||
clientBox:setVisible(false)
|
clientBox:setVisible(false)
|
||||||
|
@ -372,11 +405,11 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
|
||||||
serverListButton:setWidth(0)
|
serverListButton:setWidth(0)
|
||||||
|
|
||||||
local rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
|
local rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
|
||||||
rememberPasswordBox:setMarginTop(-14)
|
rememberPasswordBox:setMarginTop(-8)
|
||||||
|
|
||||||
if not windowWidth then windowWidth = 236 end
|
if not windowWidth then windowWidth = 236 end
|
||||||
enterGame:setWidth(windowWidth)
|
enterGame:setWidth(windowWidth)
|
||||||
if not windowHeight then windowHeight = 200 end
|
if not windowHeight then windowHeight = 210 end
|
||||||
enterGame:setHeight(windowHeight)
|
enterGame:setHeight(windowHeight)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
EnterGameWindow < MainWindow
|
EnterGameWindow < MainWindow
|
||||||
!text: tr('Enter Game')
|
!text: tr('Enter Game')
|
||||||
size: 236 274
|
size: 236 298
|
||||||
|
|
||||||
EnterGameButton < Button
|
EnterGameButton < Button
|
||||||
width: 64
|
width: 64
|
||||||
|
@ -23,6 +23,8 @@ EnterGameWindow
|
||||||
id: enterGame
|
id: enterGame
|
||||||
&authenticatorEnabled: false
|
&authenticatorEnabled: false
|
||||||
&authenticatorHeight: 44
|
&authenticatorHeight: 44
|
||||||
|
&stayLoggedBoxEnabled: false
|
||||||
|
&stayLoggedBoxHeight: 24
|
||||||
@onEnter: EnterGame.doLogin()
|
@onEnter: EnterGame.doLogin()
|
||||||
|
|
||||||
MenuLabel
|
MenuLabel
|
||||||
|
@ -58,24 +60,52 @@ EnterGameWindow
|
||||||
anchors.left: prev.left
|
anchors.left: prev.left
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
margin-top: 8
|
margin-top: -12
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
|
$on:
|
||||||
|
visible: true
|
||||||
|
margin-top: 8
|
||||||
|
|
||||||
TextEdit
|
TextEdit
|
||||||
id: authenticatorTokenTextEdit
|
id: authenticatorTokenTextEdit
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 2
|
margin-top: -22
|
||||||
visible: false
|
visible: false
|
||||||
max-length: 8
|
max-length: 8
|
||||||
|
|
||||||
|
$on:
|
||||||
|
visible: true
|
||||||
|
margin-top: 2
|
||||||
|
|
||||||
|
CheckBox
|
||||||
|
id: stayLoggedBox
|
||||||
|
!text: tr('Stay logged during session')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 6
|
||||||
|
margin-top: -16
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
$on:
|
||||||
|
visible: true
|
||||||
|
margin-top: 8
|
||||||
|
|
||||||
|
HorizontalSeparator
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 8
|
||||||
|
|
||||||
MenuLabel
|
MenuLabel
|
||||||
id: serverLabel
|
id: serverLabel
|
||||||
!text: tr('Server')
|
!text: tr('Server')
|
||||||
anchors.left: prev.left
|
anchors.left: prev.left
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: -36
|
margin-top: 8
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
|
|
||||||
ServerListButton
|
ServerListButton
|
||||||
|
@ -152,16 +182,24 @@ EnterGameWindow
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 2
|
margin-top: 2
|
||||||
|
|
||||||
|
HorizontalSeparator
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 6
|
||||||
|
|
||||||
EnterGameButton
|
EnterGameButton
|
||||||
!text: tr('Ok')
|
!text: tr('Ok')
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 4
|
||||||
@onClick: EnterGame.doLogin()
|
@onClick: EnterGame.doLogin()
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: serverInfoLabel
|
id: serverInfoLabel
|
||||||
font: verdana-11px-rounded
|
font: verdana-11px-rounded
|
||||||
anchors.bottom: parent.bottom
|
anchors.top: prev.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
margin-top: 5
|
||||||
color: green
|
color: green
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
|
@ -129,6 +129,7 @@ GameContentRevision = 65
|
||||||
GameExperienceBonus = 66
|
GameExperienceBonus = 66
|
||||||
GameAuthenticator = 67
|
GameAuthenticator = 67
|
||||||
GameUnjustifiedPoints = 68
|
GameUnjustifiedPoints = 68
|
||||||
|
GameSessionKey = 69
|
||||||
|
|
||||||
TextColors = {
|
TextColors = {
|
||||||
red = '#f55e5e', --'#c83200'
|
red = '#f55e5e', --'#c83200'
|
||||||
|
|
|
@ -73,7 +73,7 @@ function g_game.getSupportedClients()
|
||||||
1053, 1054, 1055, 1056, 1057,
|
1053, 1054, 1055, 1056, 1057,
|
||||||
1058, 1059, 1060, 1061, 1062,
|
1058, 1059, 1060, 1061, 1062,
|
||||||
1063, 1064, 1070, 1071, 1072,
|
1063, 1064, 1070, 1071, 1072,
|
||||||
1073
|
1073, 1074
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,11 @@ LoginServerTokenError = 13
|
||||||
LoginServerUpdate = 17
|
LoginServerUpdate = 17
|
||||||
LoginServerMotd = 20
|
LoginServerMotd = 20
|
||||||
LoginServerUpdateNeeded = 30
|
LoginServerUpdateNeeded = 30
|
||||||
|
LoginServerSessionKey = 40
|
||||||
LoginServerCharacterList = 100
|
LoginServerCharacterList = 100
|
||||||
LoginServerExtendedCharacterList = 101
|
LoginServerExtendedCharacterList = 101
|
||||||
|
|
||||||
function ProtocolLogin:login(host, port, accountName, accountPassword, authenticatorToken)
|
function ProtocolLogin:login(host, port, accountName, accountPassword, authenticatorToken, stayLogged)
|
||||||
if string.len(host) == 0 or port == nil or port == 0 then
|
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."))
|
signalcall(self.onLoginError, self, tr("You must enter a valid server address and port."))
|
||||||
return
|
return
|
||||||
|
@ -19,6 +20,7 @@ function ProtocolLogin:login(host, port, accountName, accountPassword, authentic
|
||||||
self.accountName = accountName
|
self.accountName = accountName
|
||||||
self.accountPassword = accountPassword
|
self.accountPassword = accountPassword
|
||||||
self.authenticatorToken = authenticatorToken
|
self.authenticatorToken = authenticatorToken
|
||||||
|
self.stayLogged = stayLogged
|
||||||
self.connectCallback = self.sendLoginPacket
|
self.connectCallback = self.sendLoginPacket
|
||||||
|
|
||||||
self:connect(host, port)
|
self:connect(host, port)
|
||||||
|
@ -109,6 +111,10 @@ function ProtocolLogin:sendLoginPacket()
|
||||||
msg:addU8(0)
|
msg:addU8(0)
|
||||||
msg:addString(self.authenticatorToken)
|
msg:addString(self.authenticatorToken)
|
||||||
|
|
||||||
|
if g_game.getFeature(GameSessionKey) then
|
||||||
|
msg:addU8(booleantonumber(self.stayLogged))
|
||||||
|
end
|
||||||
|
|
||||||
paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
|
paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset)
|
||||||
assert(paddingBytes >= 0)
|
assert(paddingBytes >= 0)
|
||||||
for i = 1, paddingBytes do
|
for i = 1, paddingBytes do
|
||||||
|
@ -144,8 +150,11 @@ function ProtocolLogin:onRecv(msg)
|
||||||
self:parseMotd(msg)
|
self:parseMotd(msg)
|
||||||
elseif opcode == LoginServerUpdateNeeded then
|
elseif opcode == LoginServerUpdateNeeded then
|
||||||
signalcall(self.onLoginError, self, tr("Client needs update."))
|
signalcall(self.onLoginError, self, tr("Client needs update."))
|
||||||
|
elseif opcode == LoginServerTokenSuccess then
|
||||||
|
local unknown = msg:getU8()
|
||||||
elseif opcode == LoginServerTokenError then
|
elseif opcode == LoginServerTokenError then
|
||||||
-- TODO: prompt for token here
|
-- TODO: prompt for token here
|
||||||
|
local unknown = msg:getU8()
|
||||||
signalcall(self.onLoginError, self, tr("Invalid authentification token."))
|
signalcall(self.onLoginError, self, tr("Invalid authentification token."))
|
||||||
elseif opcode == LoginServerCharacterList then
|
elseif opcode == LoginServerCharacterList then
|
||||||
self:parseCharacterList(msg)
|
self:parseCharacterList(msg)
|
||||||
|
@ -154,6 +163,8 @@ function ProtocolLogin:onRecv(msg)
|
||||||
elseif opcode == LoginServerUpdate then
|
elseif opcode == LoginServerUpdate then
|
||||||
local signature = msg:getString()
|
local signature = msg:getString()
|
||||||
signalcall(self.onUpdateNeeded, self, signature)
|
signalcall(self.onUpdateNeeded, self, signature)
|
||||||
|
elseif opcode == LoginServerSessionKey then
|
||||||
|
self:parseSessionKey(msg)
|
||||||
else
|
else
|
||||||
self:parseOpcode(opcode, msg)
|
self:parseOpcode(opcode, msg)
|
||||||
end
|
end
|
||||||
|
@ -171,6 +182,11 @@ function ProtocolLogin:parseMotd(msg)
|
||||||
signalcall(self.onMotd, self, motd)
|
signalcall(self.onMotd, self, motd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ProtocolLogin:parseSessionKey(msg)
|
||||||
|
local sessionKey = msg:getString()
|
||||||
|
signalcall(self.onSessionKey, self, sessionKey)
|
||||||
|
end
|
||||||
|
|
||||||
function ProtocolLogin:parseCharacterList(msg)
|
function ProtocolLogin:parseCharacterList(msg)
|
||||||
local characters = {}
|
local characters = {}
|
||||||
|
|
||||||
|
|
|
@ -401,6 +401,7 @@ namespace Otc
|
||||||
GameExperienceBonus = 66,
|
GameExperienceBonus = 66,
|
||||||
GameAuthenticator = 67,
|
GameAuthenticator = 67,
|
||||||
GameUnjustifiedPoints = 68,
|
GameUnjustifiedPoints = 68,
|
||||||
|
GameSessionKey = 69,
|
||||||
|
|
||||||
LastGameFeature = 101
|
LastGameFeature = 101
|
||||||
};
|
};
|
||||||
|
|
|
@ -534,7 +534,7 @@ void Game::processWalkCancel(Otc::Direction direction)
|
||||||
m_localPlayer->cancelWalk(direction);
|
m_localPlayer->cancelWalk(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken)
|
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
|
||||||
{
|
{
|
||||||
if(m_protocolGame || isOnline())
|
if(m_protocolGame || isOnline())
|
||||||
stdext::throw_exception("Unable to login into a world while already online or logging.");
|
stdext::throw_exception("Unable to login into a world while already online or logging.");
|
||||||
|
@ -549,7 +549,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
|
||||||
m_localPlayer->setName(characterName);
|
m_localPlayer->setName(characterName);
|
||||||
|
|
||||||
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
|
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
|
||||||
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken);
|
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken, sessionKey);
|
||||||
m_characterName = characterName;
|
m_characterName = characterName;
|
||||||
m_worldName = worldName;
|
m_worldName = worldName;
|
||||||
}
|
}
|
||||||
|
@ -1456,7 +1456,7 @@ void Game::setProtocolVersion(int version)
|
||||||
if(isOnline())
|
if(isOnline())
|
||||||
stdext::throw_exception("Unable to change protocol version while online");
|
stdext::throw_exception("Unable to change protocol version while online");
|
||||||
|
|
||||||
if(version != 0 && (version < 740 || version > 1073))
|
if(version != 0 && (version < 740 || version > 1074))
|
||||||
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
|
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
|
||||||
|
|
||||||
m_protocolVersion = version;
|
m_protocolVersion = version;
|
||||||
|
@ -1474,7 +1474,7 @@ void Game::setClientVersion(int version)
|
||||||
if(isOnline())
|
if(isOnline())
|
||||||
stdext::throw_exception("Unable to change client version while online");
|
stdext::throw_exception("Unable to change client version while online");
|
||||||
|
|
||||||
if(version != 0 && (version < 740 || version > 1073))
|
if(version != 0 && (version < 740 || version > 1074))
|
||||||
stdext::throw_exception(stdext::format("Client version %d not supported", version));
|
stdext::throw_exception(stdext::format("Client version %d not supported", version));
|
||||||
|
|
||||||
m_features.reset();
|
m_features.reset();
|
||||||
|
@ -1614,6 +1614,10 @@ void Game::setClientVersion(int version)
|
||||||
enableFeature(Otc::GameAuthenticator);
|
enableFeature(Otc::GameAuthenticator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(version >= 1074) {
|
||||||
|
enableFeature(Otc::GameSessionKey);
|
||||||
|
}
|
||||||
|
|
||||||
m_clientVersion = version;
|
m_clientVersion = version;
|
||||||
|
|
||||||
g_lua.callGlobalField("g_game", "onClientVersionChange", version);
|
g_lua.callGlobalField("g_game", "onClientVersionChange", version);
|
||||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// login related
|
// login related
|
||||||
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken);
|
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
|
||||||
void cancelLogin();
|
void cancelLogin();
|
||||||
void forceLogout();
|
void forceLogout();
|
||||||
void safeLogout();
|
void safeLogout();
|
||||||
|
|
|
@ -26,11 +26,12 @@
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "localplayer.h"
|
#include "localplayer.h"
|
||||||
|
|
||||||
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken)
|
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
|
||||||
{
|
{
|
||||||
m_accountName = accountName;
|
m_accountName = accountName;
|
||||||
m_accountPassword = accountPassword;
|
m_accountPassword = accountPassword;
|
||||||
m_authenticatorToken = authenticatorToken;
|
m_authenticatorToken = authenticatorToken;
|
||||||
|
m_sessionKey = sessionKey;
|
||||||
m_characterName = characterName;
|
m_characterName = characterName;
|
||||||
|
|
||||||
connect(host, port);
|
connect(host, port);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
class ProtocolGame : public Protocol
|
class ProtocolGame : public Protocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken);
|
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
|
||||||
void send(const OutputMessagePtr& outputMessage);
|
void send(const OutputMessagePtr& outputMessage);
|
||||||
|
|
||||||
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
|
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
|
||||||
|
@ -248,6 +248,7 @@ private:
|
||||||
std::string m_accountName;
|
std::string m_accountName;
|
||||||
std::string m_accountPassword;
|
std::string m_accountPassword;
|
||||||
std::string m_authenticatorToken;
|
std::string m_authenticatorToken;
|
||||||
|
std::string m_sessionKey;
|
||||||
std::string m_characterName;
|
std::string m_characterName;
|
||||||
LocalPlayerPtr m_localPlayer;
|
LocalPlayerPtr m_localPlayer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,16 +79,21 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
|
||||||
msg->addU8(0); // is gm set?
|
msg->addU8(0); // is gm set?
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_game.getFeature(Otc::GameAccountNames))
|
if(g_game.getFeature(Otc::GameSessionKey)) {
|
||||||
msg->addString(m_accountName);
|
msg->addString(m_sessionKey);
|
||||||
else
|
msg->addString(m_characterName);
|
||||||
msg->addU32(stdext::from_string<uint32>(m_accountName));
|
} else {
|
||||||
|
if(g_game.getFeature(Otc::GameAccountNames))
|
||||||
|
msg->addString(m_accountName);
|
||||||
|
else
|
||||||
|
msg->addU32(stdext::from_string<uint32>(m_accountName));
|
||||||
|
|
||||||
msg->addString(m_characterName);
|
msg->addString(m_characterName);
|
||||||
msg->addString(m_accountPassword);
|
msg->addString(m_accountPassword);
|
||||||
|
|
||||||
if(g_game.getFeature(Otc::GameAuthenticator))
|
if(g_game.getFeature(Otc::GameAuthenticator))
|
||||||
msg->addString(m_authenticatorToken);
|
msg->addString(m_authenticatorToken);
|
||||||
|
}
|
||||||
|
|
||||||
if(g_game.getFeature(Otc::GameChallengeOnLogin)) {
|
if(g_game.getFeature(Otc::GameChallengeOnLogin)) {
|
||||||
msg->addU32(challengeTimestamp);
|
msg->addU32(challengeTimestamp);
|
||||||
|
|
Loading…
Reference in New Issue