waiting list, u16 effects feature, protocolsend uses clientversion
This commit is contained in:
parent
3cb5216858
commit
86cade0aa9
|
@ -5,21 +5,9 @@ local charactersWindow
|
|||
local loadBox
|
||||
local characterList
|
||||
local errorBox
|
||||
local waitingWindow
|
||||
|
||||
-- private functions
|
||||
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyUp then
|
||||
characterList:focusPreviousChild(KeyboardFocusReason)
|
||||
return true
|
||||
elseif keyCode == KeyDown or keyCode == KeyTab then
|
||||
characterList:focusNextChild(KeyboardFocusReason)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function tryLogin(charInfo, tries)
|
||||
tries = tries or 1
|
||||
|
||||
|
@ -53,6 +41,67 @@ local function tryLogin(charInfo, tries)
|
|||
Settings.set('lastUsedCharacter', charInfo.characterName)
|
||||
end
|
||||
|
||||
local function updateWait()
|
||||
if waitingWindow then
|
||||
if waitingWindow.elapsedTime <= waitingWindow.totalTime then
|
||||
local percent = (waitingWindow.elapsedTime / waitingWindow.totalTime) * 100
|
||||
local timeStr = string.format("%.0f", (waitingWindow.totalTime - waitingWindow.elapsedTime))
|
||||
|
||||
local progressBar = waitingWindow:getChildById('progressBar')
|
||||
progressBar:setPercent(percent)
|
||||
|
||||
local label = waitingWindow:getChildById('timeLabel')
|
||||
label:setText('Trying to reconnect in ' .. timeStr .. ' seconds.')
|
||||
|
||||
waitingWindow.elapsedTime = waitingWindow.elapsedTime + (waitingWindow.totalTime / 100)
|
||||
scheduleEvent(updateWait, (waitingWindow.totalTime / 100) * 1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function resendWait()
|
||||
if waitingWindow then
|
||||
waitingWindow:destroy()
|
||||
waitingWindow = nil
|
||||
|
||||
if charactersWindow then
|
||||
local selected = charactersWindow:getChildById('characterList'):getFocusedChild()
|
||||
if selected then
|
||||
local charInfo = { worldHost = selected.worldHost,
|
||||
worldPort = selected.worldPort,
|
||||
characterName = selected.characterName }
|
||||
tryLogin(charInfo)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function onLoginWait(message, time)
|
||||
waitingWindow = displayUI('waitinglist.otui')
|
||||
|
||||
local label = waitingWindow:getChildById('infoLabel')
|
||||
label:setText(message)
|
||||
|
||||
waitingWindow.elapsedTime = 0
|
||||
waitingWindow.totalTime = time
|
||||
|
||||
scheduleEvent(updateWait, 0)
|
||||
scheduleEvent(resendWait, time * 1000)
|
||||
end
|
||||
|
||||
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyUp then
|
||||
characterList:focusPreviousChild(KeyboardFocusReason)
|
||||
return true
|
||||
elseif keyCode == KeyDown or keyCode == KeyTab then
|
||||
characterList:focusNextChild(KeyboardFocusReason)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function onGameLoginError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
errorBox = displayErrorBox(tr("Login Error"), message)
|
||||
|
@ -80,6 +129,7 @@ function CharacterList.init()
|
|||
connect(g_game, { onLoginError = onGameLoginError })
|
||||
connect(g_game, { onConnectionError = onGameConnectionError })
|
||||
connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
|
||||
connect(g_game, { onLoginWait = onLoginWait })
|
||||
connect(g_game, { onGameEnd = CharacterList.showAgain })
|
||||
|
||||
if G.characters then
|
||||
|
@ -91,6 +141,7 @@ function CharacterList.terminate()
|
|||
disconnect(g_game, { onLoginError = onGameLoginError })
|
||||
disconnect(g_game, { onConnectionError = onGameConnectionError })
|
||||
disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox })
|
||||
disconnect(g_game, { onLoginWait = onLoginWait })
|
||||
disconnect(g_game, { onGameEnd = CharacterList.showAgain })
|
||||
characterList = nil
|
||||
charactersWindow:destroy()
|
||||
|
@ -189,3 +240,12 @@ function CharacterList.destroyLoadBox()
|
|||
loadBox = nil
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.cancelWait()
|
||||
if waitingWindow then
|
||||
waitingWindow:destroy()
|
||||
waitingWindow = nil
|
||||
CharacterList.destroyLoadBox()
|
||||
CharacterList.showAgain()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
MainWindow
|
||||
id: waitingWindow
|
||||
!text: tr('Waiting List')
|
||||
size: 260 160
|
||||
@onEscape: CharacterList.cancelWait()
|
||||
|
||||
Label
|
||||
id: infoLabel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: progressBar.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text-wrap: true
|
||||
|
||||
ProgressBar
|
||||
id: progressBar
|
||||
height: 15
|
||||
background-color: #4444ff
|
||||
anchors.bottom: timeLabel.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-bottom: 10
|
||||
|
||||
Label
|
||||
id: timeLabel
|
||||
anchors.bottom: separator.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-bottom: 10
|
||||
|
||||
HorizontalSeparator
|
||||
id: separator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin-bottom: 10
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
!text: tr('Cancel')
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: CharacterList.cancelWait()
|
|
@ -312,6 +312,7 @@ namespace Otc
|
|||
GameItemAnimationPhase,
|
||||
GameTrucatedPingOpcode,
|
||||
GameReverseCreatureStack,
|
||||
GameMagicEffectU16,
|
||||
LastGameFeature
|
||||
};
|
||||
}
|
||||
|
|
|
@ -659,7 +659,11 @@ void ProtocolGame::parseWorldLight(const InputMessagePtr& msg)
|
|||
void ProtocolGame::parseMagicEffect(const InputMessagePtr& msg)
|
||||
{
|
||||
Position pos = getPosition(msg);
|
||||
int effectId = msg->getU8();
|
||||
int effectId;
|
||||
if(g_game.getFeature(Otc::GameMagicEffectU16))
|
||||
effectId = msg->getU16();
|
||||
else
|
||||
effectId = msg->getU8();
|
||||
|
||||
EffectPtr effect = EffectPtr(new Effect());
|
||||
effect->setId(effectId);
|
||||
|
|
|
@ -50,7 +50,7 @@ void ProtocolGame::sendLoginPacket(uint challangeTimestamp, uint8 challangeRando
|
|||
|
||||
msg->addU8(Proto::ClientEnterGame);
|
||||
msg->addU16(Proto::ClientOs);
|
||||
msg->addU16(Proto::ClientVersion);
|
||||
msg->addU16(g_game.getClientVersion());
|
||||
|
||||
int paddingBytes = 128;
|
||||
msg->addU8(0); // first RSA byte must be 0
|
||||
|
|
Loading…
Reference in New Issue