[X] I have followed [proper The Forgotten Server code styling][code].
[X] I have read and understood the [contribution guidelines][cont] before making this PR.
[X] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
new CreatureEvent onConnectionRestoration
Handle switching game client without logout which is currently impossible.
example: call login CreatureEvent that will set bless icon status, after switching the client the icon will not be updated
local blessStatusLogin = CreatureEvent("blessStatusLogin")
function blessStatusLogin.onLogin(player)
local blessCount = 0
for b = 1, 5 do
if player:hasBlessing(b) then
blessCount = blessCount + 1
end
end
local msg = NetworkMessage()
msg:addByte(0x9C);
if blessCount == 0 then
msg:addU16(0)
msg:addByte(1)
msg:sendToPlayer(player)
msg:delete()
return true
end
local bits = bit.bor(4, 8, 16, 32, 64)
if blessCount == 4 then
msg:addU16(2)
msg:addByte(2)
elseif blessCount == 5 then
msg:addU16(255)
msg:addByte(3)
end
msg:sendToPlayer(player)
msg:delete()
return true
end
blessStatusLogin:register()
-- solution
local ce = CreatureEvent("blessStatusConnectionRestoration")
function ce.onConnectionRestoration(player)
print("blessStatusConnectionRestoration")
local blessCount = 0
for b = 1, 5 do
if player:hasBlessing(b) then
blessCount = blessCount + 1
end
end
local msg = NetworkMessage()
msg:addByte(0x9C);
if blessCount == 0 then
msg:addU16(0)
msg:addByte(1)
msg:sendToPlayer(player)
msg:delete()
return true
end
local bits = bit.bor(4, 8, 16, 32, 64)
if blessCount == 4 then
msg:addU16(2)
msg:addByte(2)
elseif blessCount == 5 then
msg:addU16(255)
msg:addByte(3)
end
msg:sendToPlayer(player)
msg:delete()
return true
end
ce:register()
Pull Request Prelude
Changes Proposed
new CreatureEvent
onConnectionRestoration
Handle switching game client without logout which is currently impossible. example: call login CreatureEvent that will set bless icon status, after switching the client the icon will not be updated