Commit a0013f0b66f36f14f252f5c4599c849360ceec23
1 parent
ffe27b94
零件分批推送
Showing
2 changed files
with
32 additions
and
7 deletions
Show diff stats
src/actions/GmAction.lua
src/actions/RoleAction.lua
| ... | ... | @@ -15,6 +15,7 @@ local tconcat = table.concat |
| 15 | 15 | local httpc = require("http.httpc") |
| 16 | 16 | |
| 17 | 17 | local WAVE_HERO_NUMS = 150 |
| 18 | +local WAVE_RUNE_NUMS = 150 | |
| 18 | 19 | |
| 19 | 20 | local function validName(name) |
| 20 | 21 | name = string.upper(name) |
| ... | ... | @@ -141,6 +142,16 @@ function _M.loginRpc( agent, data ) |
| 141 | 142 | table_insert(modules, "heros") |
| 142 | 143 | end |
| 143 | 144 | |
| 145 | + local runeIds = {} | |
| 146 | + for id ,_ in pairs(role.runeBag) do | |
| 147 | + table.insert(runeIds, id) | |
| 148 | + end | |
| 149 | + local runeWave = math.ceil(#runeIds / WAVE_RUNE_NUMS) | |
| 150 | + if #runeIds <= 50 then | |
| 151 | + runeWave = 0 | |
| 152 | + table_insert(modules, "runeBag") | |
| 153 | + end | |
| 154 | + | |
| 144 | 155 | for _, name in ipairs(modules) do |
| 145 | 156 | response[name] = {} |
| 146 | 157 | for id, unit in pairs(role[name]) do |
| ... | ... | @@ -148,18 +159,31 @@ function _M.loginRpc( agent, data ) |
| 148 | 159 | end |
| 149 | 160 | end |
| 150 | 161 | |
| 151 | - response.wave = 2 + heroWave | |
| 162 | + response.wave = 1 + heroWave + runeWave | |
| 152 | 163 | |
| 153 | 164 | SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(response)) |
| 154 | 165 | |
| 155 | - local runeResp = {runeBag = {}} | |
| 156 | - for _,rune in pairs(role.runeBag) do | |
| 157 | - runeResp.runeBag[rune:getProperty("uid")]=rune:data() | |
| 166 | + local curWave = 1 | |
| 167 | + | |
| 168 | + local runeIndex = 1 | |
| 169 | + for index = curWave + 1, curWave + runeWave do | |
| 170 | + local runeResponse = {runeBag = {}} | |
| 171 | + for i = runeIndex, runeIndex + WAVE_RUNE_NUMS do | |
| 172 | + local runeId = runeIds[i] | |
| 173 | + if not runeId then | |
| 174 | + break | |
| 175 | + end | |
| 176 | + local rune = role.runeBag[runeId] | |
| 177 | + table.insert(runeResponse.runeBag, rune:data()) | |
| 178 | + runeIndex = runeIndex + 1 | |
| 179 | + end | |
| 180 | + runeResponse.runeWave = index | |
| 181 | + SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(runeResponse)) | |
| 158 | 182 | end |
| 159 | - SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(runeResp)) | |
| 183 | + curWave = curWave + runeWave | |
| 160 | 184 | |
| 161 | 185 | local heroIndex = 1 |
| 162 | - for index = 3, heroWave + 2 do | |
| 186 | + for index = curWave + 1, curWave + heroWave do | |
| 163 | 187 | local heroResponse = {heros = {}} |
| 164 | 188 | for i = heroIndex, heroIndex + WAVE_HERO_NUMS do |
| 165 | 189 | local heroId = heroIds[i] |
| ... | ... | @@ -173,6 +197,7 @@ function _M.loginRpc( agent, data ) |
| 173 | 197 | heroResponse.heroWave = index |
| 174 | 198 | SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(heroResponse)) |
| 175 | 199 | end |
| 200 | + curWave = curWave + heroWave | |
| 176 | 201 | |
| 177 | 202 | -- role:log("login", { ip = agent.ip, diamond = role:getProperty("diamond"), reDiamond = role:getProperty("reDiamond")}) |
| 178 | 203 | ... | ... |