Use client version instead of entergame

master
Eduardo Bart 11 years ago
parent 5fbb71157d
commit b5911cf1de

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(otclient) project(otclient)
set(VERSION "0.6.2") set(VERSION "0.6.3")
option(FRAMEWORK_SOUND "Use SOUND " ON) option(FRAMEWORK_SOUND "Use SOUND " ON)
option(FRAMEWORK_GRAPHICS "Use GRAPHICS " ON) option(FRAMEWORK_GRAPHICS "Use GRAPHICS " ON)

@ -104,11 +104,6 @@ function terminate()
g_settings.set('window-size', g_window.getUnmaximizedSize()) g_settings.set('window-size', g_window.getUnmaximizedSize())
g_settings.set('window-pos', g_window.getUnmaximizedPos()) g_settings.set('window-pos', g_window.getUnmaximizedPos())
g_settings.set('window-maximized', g_window.isMaximized()) g_settings.set('window-maximized', g_window.isMaximized())
local protocolVersion = g_game.getProtocolVersion()
if protocolVersion ~= 0 then
g_settings.set('protocol-version', protocolVersion)
end
end end
function exit() function exit()

@ -19,4 +19,4 @@ Module
- client_terminal - client_terminal
- client_modulemanager - client_modulemanager
- client_serverlist - client_serverlist
//- client_stats - client_stats

@ -6,7 +6,7 @@ local enterGame
local motdWindow local motdWindow
local motdButton local motdButton
local enterGameButton local enterGameButton
local protocolBox local clientBox
local protocolLogin local protocolLogin
local motdEnabled = true local motdEnabled = true
@ -73,11 +73,6 @@ local function onCharacterList(protocol, characters, account, otui)
end end
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
local function onUpdateNeeded(protocol, signature) local function onUpdateNeeded(protocol, signature)
loadBox:destroy() loadBox:destroy()
loadBox = nil loadBox = nil
@ -109,7 +104,8 @@ function EnterGame.init()
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 autologin = g_settings.getBoolean('autologin') local autologin = g_settings.getBoolean('autologin')
local protocolVersion = g_settings.getInteger('protocol-version') local clientVersion = g_settings.getInteger('client-version')
if clientVersion == 0 then clientVersion = 860 end
if port == nil or port == 0 then port = 7171 end if port == nil or port == 0 then port = 7171 end
@ -120,11 +116,11 @@ function EnterGame.init()
enterGame:getChildById('serverPortTextEdit'):setText(port) enterGame:getChildById('serverPortTextEdit'):setText(port)
enterGame:getChildById('autoLoginBox'):setChecked(autologin) enterGame:getChildById('autoLoginBox'):setChecked(autologin)
protocolBox = enterGame:getChildById('protocolComboBox') clientBox = enterGame:getChildById('clientComboBox')
protocolBox.onOptionChange = onChangeProtocol for _, proto in pairs(g_game.getSupportedClients()) do
if protocolVersion then clientBox:addOption(proto)
protocolBox:setCurrentOption(protocolVersion)
end end
clientBox:setCurrentOption(clientVersion)
enterGame:hide() enterGame:hide()
@ -154,7 +150,7 @@ function EnterGame.terminate()
enterGame = nil enterGame = nil
enterGameButton:destroy() enterGameButton:destroy()
enterGameButton = nil enterGameButton = nil
protocolBox = nil clientBox = nil
if motdWindow then if motdWindow then
motdWindow:destroy() motdWindow:destroy()
motdWindow = nil motdWindow = nil
@ -218,8 +214,7 @@ function EnterGame.doLogin()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText() G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
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 protocolVersion = tonumber(protocolBox:getText()) local clientVersion = tonumber(clientBox:getText())
local clientVersions = g_game.getSupportedClients(protocolVersion)
EnterGame.hide() EnterGame.hide()
if g_game.isOnline() then if g_game.isOnline() then
@ -230,6 +225,7 @@ function EnterGame.doLogin()
g_settings.set('host', G.host) g_settings.set('host', G.host)
g_settings.set('port', G.port) g_settings.set('port', G.port)
g_settings.set('client-version', clientVersion)
protocolLogin = ProtocolLogin.create() protocolLogin = ProtocolLogin.create()
protocolLogin.onLoginError = onError protocolLogin.onLoginError = onError
@ -245,10 +241,8 @@ function EnterGame.doLogin()
end }) end })
g_game.chooseRsa(G.host) g_game.chooseRsa(G.host)
g_game.setProtocolVersion(protocolVersion) g_game.setClientVersion(clientVersion)
if #clientVersions > 0 then g_game.setProtocolVersion(g_game.getProtocolVersionForClient(clientVersion))
g_game.setClientVersion(clientVersions[#clientVersions])
end
if modules.game_things.isLoaded() then 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)
@ -269,14 +263,14 @@ end
function EnterGame.setDefaultServer(host, port, protocol) function EnterGame.setDefaultServer(host, port, protocol)
local hostTextEdit = enterGame:getChildById('serverHostTextEdit') local hostTextEdit = enterGame:getChildById('serverHostTextEdit')
local portTextEdit = enterGame:getChildById('serverPortTextEdit') local portTextEdit = enterGame:getChildById('serverPortTextEdit')
local protocolLabel = enterGame:getChildById('protocolLabel') local clientLabel = enterGame:getChildById('clientLabel')
local accountTextEdit = enterGame:getChildById('accountNameTextEdit') local accountTextEdit = enterGame:getChildById('accountNameTextEdit')
local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit') local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit')
if hostTextEdit:getText() ~= host then if hostTextEdit:getText() ~= host then
hostTextEdit:setText(host) hostTextEdit:setText(host)
portTextEdit:setText(port) portTextEdit:setText(port)
protocolBox:setCurrentOption(protocol) clientBox:setCurrentOption(protocol)
accountTextEdit:setText('') accountTextEdit:setText('')
passwordTextEdit:setText('') passwordTextEdit:setText('')
end end
@ -292,9 +286,9 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
portTextEdit:setVisible(false) portTextEdit:setVisible(false)
portTextEdit:setHeight(0) portTextEdit:setHeight(0)
protocolBox:setCurrentOption(protocol) clientBox:setCurrentOption(protocol)
protocolBox:setVisible(false) clientBox:setVisible(false)
protocolBox:setHeight(0) clientBox:setHeight(0)
local serverLabel = enterGame:getChildById('serverLabel') local serverLabel = enterGame:getChildById('serverLabel')
serverLabel:setVisible(false) serverLabel:setVisible(false)
@ -302,9 +296,9 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
local portLabel = enterGame:getChildById('portLabel') local portLabel = enterGame:getChildById('portLabel')
portLabel:setVisible(false) portLabel:setVisible(false)
portLabel:setHeight(0) portLabel:setHeight(0)
local protocolLabel = enterGame:getChildById('protocolLabel') local clientLabel = enterGame:getChildById('clientLabel')
protocolLabel:setVisible(false) clientLabel:setVisible(false)
protocolLabel:setHeight(0) clientLabel:setHeight(0)
local serverListButton = enterGame:getChildById('serverListButton') local serverListButton = enterGame:getChildById('serverListButton')
serverListButton:setVisible(false) serverListButton:setVisible(false)

@ -68,7 +68,7 @@ EnterGameWindow
TextEdit TextEdit
id: serverHostTextEdit id: serverHostTextEdit
!tooltip: tr('Make sure that your client uses\nthe correct game protocol version') !tooltip: tr('Make sure that your client uses\nthe correct game client version')
anchors.left: parent.left anchors.left: parent.left
anchors.right: serverListButton.left anchors.right: serverListButton.left
anchors.top: serverLabel.bottom anchors.top: serverLabel.bottom
@ -76,8 +76,8 @@ EnterGameWindow
margin-right: 4 margin-right: 4
MenuLabel MenuLabel
id: protocolLabel id: clientLabel
!text: tr('Protocol') !text: tr('Client Version')
anchors.left: parent.left anchors.left: parent.left
anchors.top: serverHostTextEdit.bottom anchors.top: serverHostTextEdit.bottom
text-auto-resize: true text-auto-resize: true
@ -85,17 +85,13 @@ EnterGameWindow
margin-top: 8 margin-top: 8
ComboBox ComboBox
id: protocolComboBox id: clientComboBox
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.horizontalCenter anchors.right: parent.horizontalCenter
anchors.top: protocolLabel.bottom anchors.top: clientLabel.bottom
margin-top: 2 margin-top: 2
margin-right: 3 margin-right: 3
width: 90 width: 90
@onSetup: |
for _, proto in pairs(g_game.getSupportedProtocols()) do
self:addOption(proto)
end
MenuLabel MenuLabel
id: portLabel id: portLabel
@ -110,7 +106,7 @@ EnterGameWindow
text: 7171 text: 7171
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.horizontalCenter anchors.left: parent.horizontalCenter
anchors.top: protocolComboBox.top anchors.top: clientComboBox.top
margin-left: 3 margin-left: 3
CheckBox CheckBox

@ -49,7 +49,7 @@ MainWindow
anchors.left: protocolLabel.left anchors.left: protocolLabel.left
anchors.right: port.right anchors.right: port.right
@onSetup: | @onSetup: |
for _, proto in pairs(g_game.getSupportedProtocols()) do for _, proto in pairs(g_game.getSupportedClients()) do
self:addOption(proto) self:addOption(proto)
end end

@ -170,7 +170,7 @@ function enableChat()
gameInterface.unbindWalkKey("S") gameInterface.unbindWalkKey("S")
gameInterface.unbindWalkKey("A") gameInterface.unbindWalkKey("A")
consoleToggleChat:setTooltip(tr("Disable chat mode")) consoleToggleChat:setTooltip(tr("Disable chat mode, allow to walk using ASDW"))
end end
function disableChat() function disableChat()

@ -58,7 +58,7 @@ Panel
CheckBox CheckBox
id: toggleChat id: toggleChat
!tooltip: tr('Disable chat mode') !tooltip: tr('Disable chat mode, allow to walk using ASDW')
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin-left: 13 margin-left: 13

@ -18,7 +18,7 @@ function isLoaded()
end end
function load() function load()
local version = g_game.getProtocolVersion() local version = g_game.getClientVersion()
local datPath, sprPath local datPath, sprPath
if filename then if filename then

@ -32,29 +32,29 @@ function g_game.isOfficialTibia()
return currentRsa == CIPSOFT_RSA return currentRsa == CIPSOFT_RSA
end end
function g_game.getSupportedProtocols() function g_game.getSupportedClients()
return { return {
810, 811, 840, 842, 850, 853, 854, 810, 811, 840, 842, 850, 853, 854,
860, 861, 862, 870, 910, 940, 944, 860, 861, 862, 870, 910, 940, 944,
953, 954, 960, 961, 963, 970, 971, 953, 954, 960, 961, 963, 970, 980,
973, 974, 975, 976, 977, 978, 979, 981, 982, 983, 984, 985, 986, 1001,
980, 1010 1002, 1010
} }
end end
function g_game.getSupportedClients(protocol) function g_game.getProtocolVersionForClient(client)
clients = { clients = {
[971] = {980}, [980] = 971,
[973] = {981}, [981] = 973,
[974] = {982}, [982] = 974,
[975] = {983}, [983] = 975,
[976] = {984}, [984] = 976,
[977] = {985}, [985] = 977,
[978] = {986}, [986] = 978,
[979] = {1001}, [1001] = 979,
[980] = {1002} [1002] = 980,
} }
return clients[protocol] or {protocol} return clients[client] or client
end end
g_game.setRsa(OTSERV_RSA) g_game.setRsa(OTSERV_RSA)

Loading…
Cancel
Save