From a0013f0b66f36f14f252f5c4599c849360ceec23 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Tue, 16 Jul 2019 20:56:11 +0800 Subject: [PATCH] 零件分批推送 --- src/actions/GmAction.lua | 2 +- src/actions/RoleAction.lua | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index ac06f24..882cad3 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -55,7 +55,7 @@ function _M.get(role, pms) elseif pms.pm1 == "RUNE" then for itemId = 2000 , 3000 do if csvdb["itemCsv"][itemId] then - role:award({[itemId] = 3}) + role:award({[itemId] = 1}) end end elseif pms.pm1 == "FRAG" then diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 01668ad..be4466b 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -15,6 +15,7 @@ local tconcat = table.concat local httpc = require("http.httpc") local WAVE_HERO_NUMS = 150 +local WAVE_RUNE_NUMS = 150 local function validName(name) name = string.upper(name) @@ -141,6 +142,16 @@ function _M.loginRpc( agent, data ) table_insert(modules, "heros") end + local runeIds = {} + for id ,_ in pairs(role.runeBag) do + table.insert(runeIds, id) + end + local runeWave = math.ceil(#runeIds / WAVE_RUNE_NUMS) + if #runeIds <= 50 then + runeWave = 0 + table_insert(modules, "runeBag") + end + for _, name in ipairs(modules) do response[name] = {} for id, unit in pairs(role[name]) do @@ -148,18 +159,31 @@ function _M.loginRpc( agent, data ) end end - response.wave = 2 + heroWave + response.wave = 1 + heroWave + runeWave SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(response)) - local runeResp = {runeBag = {}} - for _,rune in pairs(role.runeBag) do - runeResp.runeBag[rune:getProperty("uid")]=rune:data() + local curWave = 1 + + local runeIndex = 1 + for index = curWave + 1, curWave + runeWave do + local runeResponse = {runeBag = {}} + for i = runeIndex, runeIndex + WAVE_RUNE_NUMS do + local runeId = runeIds[i] + if not runeId then + break + end + local rune = role.runeBag[runeId] + table.insert(runeResponse.runeBag, rune:data()) + runeIndex = runeIndex + 1 + end + runeResponse.runeWave = index + SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(runeResponse)) end - SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(runeResp)) + curWave = curWave + runeWave local heroIndex = 1 - for index = 3, heroWave + 2 do + for index = curWave + 1, curWave + heroWave do local heroResponse = {heros = {}} for i = heroIndex, heroIndex + WAVE_HERO_NUMS do local heroId = heroIds[i] @@ -173,6 +197,7 @@ function _M.loginRpc( agent, data ) heroResponse.heroWave = index SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(heroResponse)) end + curWave = curWave + heroWave -- role:log("login", { ip = agent.ip, diamond = role:getProperty("diamond"), reDiamond = role:getProperty("reDiamond")}) -- libgit2 0.21.2