Commit 214061fabcfb64100eb3e9c09e84a09e1b3b6788
1 parent
37b1c73e
错误情况,返回错误码
Showing
2 changed files
with
8 additions
and
8 deletions
Show diff stats
src/actions/DinerAction.lua
| ... | ... | @@ -12,22 +12,22 @@ function _M.addSellRpc( agent, data ) |
| 12 | 12 | |
| 13 | 13 | local slot = msg.slot |
| 14 | 14 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
| 15 | - return | |
| 15 | + return 1 | |
| 16 | 16 | end |
| 17 | 17 | slot = tostring(slot) |
| 18 | 18 | |
| 19 | 19 | local dish = msg.dish |
| 20 | 20 | local dishSet = csvdb["diner_dishCsv"][dish] |
| 21 | 21 | if not dishSet then |
| 22 | - return | |
| 22 | + return 2 | |
| 23 | 23 | end |
| 24 | 24 | local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0) |
| 25 | 25 | if dishLevel == 0 then |
| 26 | - return | |
| 26 | + return 3 | |
| 27 | 27 | end |
| 28 | 28 | local dishData = dishSet[dishLevel] |
| 29 | 29 | if not dishData then |
| 30 | - return | |
| 30 | + return 4 | |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | local calSell = role.dinerData:updateSell(slot, true) or { |
| ... | ... | @@ -38,7 +38,7 @@ function _M.addSellRpc( agent, data ) |
| 38 | 38 | local count = msg.count |
| 39 | 39 | local maxDishCount = role.dinerData:getMaxDishs() |
| 40 | 40 | if math.illegalNum(count + calSell.lastCount, 1, maxDishCount) then |
| 41 | - return | |
| 41 | + return 5 | |
| 42 | 42 | end |
| 43 | 43 | |
| 44 | 44 | local cost = dishData.material:toNumMap() |
| ... | ... | @@ -46,7 +46,7 @@ function _M.addSellRpc( agent, data ) |
| 46 | 46 | n = n * count |
| 47 | 47 | end |
| 48 | 48 | if not role:checkItemEnough(cost) then |
| 49 | - return | |
| 49 | + return 6 | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | role:costItems(cost) | ... | ... |
src/agent.lua
| ... | ... | @@ -201,8 +201,8 @@ skynet.register_protocol { |
| 201 | 201 | |
| 202 | 202 | if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end |
| 203 | 203 | local result = method(agentInfo, data) |
| 204 | - if not result then | |
| 205 | - SendPacket(actionCodes.Sys_innerErrorMsg, MsgPack.pack({id = cmd})) | |
| 204 | + if not result or type(result) == "number" then | |
| 205 | + SendPacket(actionCodes.Sys_innerErrorMsg, MsgPack.pack({id = cmd * 100 + (result or 0)})) | |
| 206 | 206 | end |
| 207 | 207 | end) |
| 208 | 208 | end | ... | ... |