From b5911cf1de0e43f5c614025ba2a05bc68b81fc48 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sat, 3 Aug 2013 19:21:08 -0300 Subject: [PATCH] Use client version instead of entergame --- CMakeLists.txt | 2 +- modules/client/client.lua | 5 --- modules/client/client.otmod | 2 +- modules/client_entergame/entergame.lua | 46 +++++++++++------------- modules/client_entergame/entergame.otui | 16 ++++----- modules/client_serverlist/addserver.otui | 2 +- modules/game_console/console.lua | 2 +- modules/game_console/console.otui | 2 +- modules/game_things/things.lua | 2 +- modules/gamelib/game.lua | 30 ++++++++-------- 10 files changed, 47 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ab151f1..84a0e20f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(otclient) -set(VERSION "0.6.2") +set(VERSION "0.6.3") option(FRAMEWORK_SOUND "Use SOUND " ON) option(FRAMEWORK_GRAPHICS "Use GRAPHICS " ON) diff --git a/modules/client/client.lua b/modules/client/client.lua index 436a6f5a..99787b22 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -104,11 +104,6 @@ function terminate() g_settings.set('window-size', g_window.getUnmaximizedSize()) g_settings.set('window-pos', g_window.getUnmaximizedPos()) 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 function exit() diff --git a/modules/client/client.otmod b/modules/client/client.otmod index e66a7d0d..c250c3f0 100644 --- a/modules/client/client.otmod +++ b/modules/client/client.otmod @@ -19,4 +19,4 @@ Module - client_terminal - client_modulemanager - client_serverlist - //- client_stats + - client_stats diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 5c572a51..6fee2f48 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -6,7 +6,7 @@ local enterGame local motdWindow local motdButton local enterGameButton -local protocolBox +local clientBox local protocolLogin local motdEnabled = true @@ -73,11 +73,6 @@ local function onCharacterList(protocol, characters, account, otui) 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) loadBox:destroy() loadBox = nil @@ -109,7 +104,8 @@ function EnterGame.init() local host = g_settings.get('host') local port = g_settings.get('port') 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 @@ -120,11 +116,11 @@ function EnterGame.init() enterGame:getChildById('serverPortTextEdit'):setText(port) enterGame:getChildById('autoLoginBox'):setChecked(autologin) - protocolBox = enterGame:getChildById('protocolComboBox') - protocolBox.onOptionChange = onChangeProtocol - if protocolVersion then - protocolBox:setCurrentOption(protocolVersion) + clientBox = enterGame:getChildById('clientComboBox') + for _, proto in pairs(g_game.getSupportedClients()) do + clientBox:addOption(proto) end + clientBox:setCurrentOption(clientVersion) enterGame:hide() @@ -154,7 +150,7 @@ function EnterGame.terminate() enterGame = nil enterGameButton:destroy() enterGameButton = nil - protocolBox = nil + clientBox = nil if motdWindow then motdWindow:destroy() motdWindow = nil @@ -218,8 +214,7 @@ function EnterGame.doLogin() G.password = enterGame:getChildById('accountPasswordTextEdit'):getText() G.host = enterGame:getChildById('serverHostTextEdit'):getText() G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText()) - local protocolVersion = tonumber(protocolBox:getText()) - local clientVersions = g_game.getSupportedClients(protocolVersion) + local clientVersion = tonumber(clientBox:getText()) EnterGame.hide() if g_game.isOnline() then @@ -230,6 +225,7 @@ function EnterGame.doLogin() g_settings.set('host', G.host) g_settings.set('port', G.port) + g_settings.set('client-version', clientVersion) protocolLogin = ProtocolLogin.create() protocolLogin.onLoginError = onError @@ -245,10 +241,8 @@ function EnterGame.doLogin() end }) g_game.chooseRsa(G.host) - g_game.setProtocolVersion(protocolVersion) - if #clientVersions > 0 then - g_game.setClientVersion(clientVersions[#clientVersions]) - end + g_game.setClientVersion(clientVersion) + g_game.setProtocolVersion(g_game.getProtocolVersionForClient(clientVersion)) if modules.game_things.isLoaded() then protocolLogin:login(G.host, G.port, G.account, G.password) @@ -269,14 +263,14 @@ end function EnterGame.setDefaultServer(host, port, protocol) local hostTextEdit = enterGame:getChildById('serverHostTextEdit') local portTextEdit = enterGame:getChildById('serverPortTextEdit') - local protocolLabel = enterGame:getChildById('protocolLabel') + local clientLabel = enterGame:getChildById('clientLabel') local accountTextEdit = enterGame:getChildById('accountNameTextEdit') local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit') if hostTextEdit:getText() ~= host then hostTextEdit:setText(host) portTextEdit:setText(port) - protocolBox:setCurrentOption(protocol) + clientBox:setCurrentOption(protocol) accountTextEdit:setText('') passwordTextEdit:setText('') end @@ -292,9 +286,9 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig portTextEdit:setVisible(false) portTextEdit:setHeight(0) - protocolBox:setCurrentOption(protocol) - protocolBox:setVisible(false) - protocolBox:setHeight(0) + clientBox:setCurrentOption(protocol) + clientBox:setVisible(false) + clientBox:setHeight(0) local serverLabel = enterGame:getChildById('serverLabel') serverLabel:setVisible(false) @@ -302,9 +296,9 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig local portLabel = enterGame:getChildById('portLabel') portLabel:setVisible(false) portLabel:setHeight(0) - local protocolLabel = enterGame:getChildById('protocolLabel') - protocolLabel:setVisible(false) - protocolLabel:setHeight(0) + local clientLabel = enterGame:getChildById('clientLabel') + clientLabel:setVisible(false) + clientLabel:setHeight(0) local serverListButton = enterGame:getChildById('serverListButton') serverListButton:setVisible(false) diff --git a/modules/client_entergame/entergame.otui b/modules/client_entergame/entergame.otui index 8f35e137..0b97526f 100644 --- a/modules/client_entergame/entergame.otui +++ b/modules/client_entergame/entergame.otui @@ -68,7 +68,7 @@ EnterGameWindow TextEdit 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.right: serverListButton.left anchors.top: serverLabel.bottom @@ -76,8 +76,8 @@ EnterGameWindow margin-right: 4 MenuLabel - id: protocolLabel - !text: tr('Protocol') + id: clientLabel + !text: tr('Client Version') anchors.left: parent.left anchors.top: serverHostTextEdit.bottom text-auto-resize: true @@ -85,17 +85,13 @@ EnterGameWindow margin-top: 8 ComboBox - id: protocolComboBox + id: clientComboBox anchors.left: parent.left anchors.right: parent.horizontalCenter - anchors.top: protocolLabel.bottom + anchors.top: clientLabel.bottom margin-top: 2 margin-right: 3 width: 90 - @onSetup: | - for _, proto in pairs(g_game.getSupportedProtocols()) do - self:addOption(proto) - end MenuLabel id: portLabel @@ -110,7 +106,7 @@ EnterGameWindow text: 7171 anchors.right: parent.right anchors.left: parent.horizontalCenter - anchors.top: protocolComboBox.top + anchors.top: clientComboBox.top margin-left: 3 CheckBox diff --git a/modules/client_serverlist/addserver.otui b/modules/client_serverlist/addserver.otui index 3fd3b07d..a5d3a2cf 100644 --- a/modules/client_serverlist/addserver.otui +++ b/modules/client_serverlist/addserver.otui @@ -49,7 +49,7 @@ MainWindow anchors.left: protocolLabel.left anchors.right: port.right @onSetup: | - for _, proto in pairs(g_game.getSupportedProtocols()) do + for _, proto in pairs(g_game.getSupportedClients()) do self:addOption(proto) end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 767de81c..874b3262 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -170,7 +170,7 @@ function enableChat() gameInterface.unbindWalkKey("S") gameInterface.unbindWalkKey("A") - consoleToggleChat:setTooltip(tr("Disable chat mode")) + consoleToggleChat:setTooltip(tr("Disable chat mode, allow to walk using ASDW")) end function disableChat() diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 3b7c1e2c..98fe168b 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -58,7 +58,7 @@ Panel CheckBox id: toggleChat - !tooltip: tr('Disable chat mode') + !tooltip: tr('Disable chat mode, allow to walk using ASDW') anchors.left: parent.left anchors.top: parent.top margin-left: 13 diff --git a/modules/game_things/things.lua b/modules/game_things/things.lua index 6df3c9a7..3d3e8e7d 100644 --- a/modules/game_things/things.lua +++ b/modules/game_things/things.lua @@ -18,7 +18,7 @@ function isLoaded() end function load() - local version = g_game.getProtocolVersion() + local version = g_game.getClientVersion() local datPath, sprPath if filename then diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 325ba400..d53ed076 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -32,29 +32,29 @@ function g_game.isOfficialTibia() return currentRsa == CIPSOFT_RSA end -function g_game.getSupportedProtocols() +function g_game.getSupportedClients() return { 810, 811, 840, 842, 850, 853, 854, 860, 861, 862, 870, 910, 940, 944, - 953, 954, 960, 961, 963, 970, 971, - 973, 974, 975, 976, 977, 978, 979, - 980, 1010 + 953, 954, 960, 961, 963, 970, 980, + 981, 982, 983, 984, 985, 986, 1001, + 1002, 1010 } end -function g_game.getSupportedClients(protocol) +function g_game.getProtocolVersionForClient(client) clients = { - [971] = {980}, - [973] = {981}, - [974] = {982}, - [975] = {983}, - [976] = {984}, - [977] = {985}, - [978] = {986}, - [979] = {1001}, - [980] = {1002} + [980] = 971, + [981] = 973, + [982] = 974, + [983] = 975, + [984] = 976, + [985] = 977, + [986] = 978, + [1001] = 979, + [1002] = 980, } - return clients[protocol] or {protocol} + return clients[client] or client end g_game.setRsa(OTSERV_RSA)