Multi-protocol

Lots of chagnes to add multi protocol flexibility, not really
completed yet, still have to rework text messages opcodes and other stuff,
so this still a working in progress feature

* Rework dat reader, the dat reader can now
* dinamically detect dat version
* Split game into gamelib and game_interface
* Lots of other minor changes
This commit is contained in:
Eduardo Bart
2012-07-17 20:49:21 -03:00
parent 6fc11d2fa9
commit eb24d6776e
64 changed files with 536 additions and 588 deletions

View File

@@ -54,7 +54,7 @@ local function updateWait(timeStart, timeEnd)
progressBar:setPercent(percent)
local label = waitingWindow:getChildById('timeLabel')
label:setText('Trying to reconnect in ' .. timeStr .. ' seconds.')
label:setText(tr('Trying to reconnect in %s seconds.', timeStr))
updateWaitEvent = scheduleEvent(function() updateWait(timeStart, timeEnd) end, 1000 * progressBar:getPercentPixels() / 100 * (timeEnd - timeStart))
return true

View File

@@ -5,6 +5,7 @@ local loadBox
local enterGame
local motdButton
local enterGameButton
local protocolBox
-- private functions
local function onError(protocol, message, errorCode)
@@ -66,6 +67,11 @@ function EnterGame.init()
local host = g_settings.get('host')
local port = g_settings.get('port')
local autologin = g_settings.getBoolean('autologin')
local protocol = g_settings.getInteger('protocol', 860)
if not protocol or protocol == 0 then
protocol = 860
end
if port == nil or port == 0 then port = 7171 end
@@ -77,6 +83,12 @@ function EnterGame.init()
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
enterGame:getChildById('accountNameTextEdit'):focus()
protocolBox = enterGame:getChildById('protocolComboBox')
for _i,proto in pairs(g_game.getSupportedProtocols()) do
protocolBox:addOption(proto)
end
protocolBox:setCurrentOption(protocol)
-- only open entergame when app starts
if not g_app.isRunning() then
if #host > 0 and #password > 0 and #account > 0 and autologin then
@@ -95,6 +107,7 @@ function EnterGame.terminate()
enterGameButton = nil
motdButton:destroy()
motdButton = nil
protocolBox = nil
EnterGame = nil
end
@@ -116,7 +129,6 @@ function EnterGame.openWindow()
end
end
function EnterGame.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
@@ -130,16 +142,18 @@ function EnterGame.doLogin()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
local protocol = tonumber(protocolBox:getText())
EnterGame.hide()
if G.host == '' or G.port == nil or G.port == 0 then
local errorBox = displayErrorBox(tr('Login Error'), tr('Enter a valid server host and port to login.'))
if g_game.isOnline() then
local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.'))
connect(errorBox, { onOk = EnterGame.show })
return
end
g_settings.set('host', G.host)
g_settings.set('port', G.port)
g_settings.set('protocol', protocol)
local protocolLogin = ProtocolLogin.create()
protocolLogin.onError = onError
@@ -153,6 +167,8 @@ function EnterGame.doLogin()
EnterGame.show()
end })
g_game.chooseRsa(G.host)
g_game.setProtocolVersion(protocol)
protocolLogin:login(G.host, G.port, G.account, G.password)
end

View File

@@ -1,7 +1,7 @@
MainWindow
id: enterGame
!text: tr('Enter Game')
size: 236 240
size: 236 274
@onEnter: EnterGame.doLogin()
@onEscape: EnterGame.hide()
@@ -43,26 +43,43 @@ MainWindow
TextEdit
id: serverHostTextEdit
!tooltip: tr('Make sure that your client uses\nthe correct game protocol version')
anchors.left: serverLabel.left
anchors.left: parent.left
anchors.right: parent.right
anchors.top: serverLabel.bottom
margin-top: 2
width: 140
Label
id: protocolLabel
!text: tr('Protocol')
anchors.left: parent.left
anchors.top: serverHostTextEdit.bottom
anchors.right: portLabel.left
margin-right: 10
margin-top: 8
ComboBox
id: protocolComboBox
anchors.left: protocolLabel.left
anchors.right: protocolLabel.right
anchors.top: protocolLabel.bottom
margin-top: 2
width: 90
Label
id: portLabel
!text: tr('Port')
anchors.left: serverHostTextEdit.right
anchors.top: serverLabel.top
margin-left: 10
text-auto-resize: true
anchors.right: parent.right
anchors.top: serverHostTextEdit.bottom
margin-top: 8
width: 70
TextEdit
id: serverPortTextEdit
text: 7171
anchors.right: parent.right
anchors.left: portLabel.left
anchors.top: portLabel.bottom
margin-top: 2
width: 55
CheckBox
id: rememberPasswordBox