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,22 +12,22 @@ function _M.addSellRpc( agent, data ) | ||
| 12 | 12 | ||
| 13 | local slot = msg.slot | 13 | local slot = msg.slot |
| 14 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then | 14 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
| 15 | - return | 15 | + return 1 |
| 16 | end | 16 | end |
| 17 | slot = tostring(slot) | 17 | slot = tostring(slot) |
| 18 | 18 | ||
| 19 | local dish = msg.dish | 19 | local dish = msg.dish |
| 20 | local dishSet = csvdb["diner_dishCsv"][dish] | 20 | local dishSet = csvdb["diner_dishCsv"][dish] |
| 21 | if not dishSet then | 21 | if not dishSet then |
| 22 | - return | 22 | + return 2 |
| 23 | end | 23 | end |
| 24 | local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0) | 24 | local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0) |
| 25 | if dishLevel == 0 then | 25 | if dishLevel == 0 then |
| 26 | - return | 26 | + return 3 |
| 27 | end | 27 | end |
| 28 | local dishData = dishSet[dishLevel] | 28 | local dishData = dishSet[dishLevel] |
| 29 | if not dishData then | 29 | if not dishData then |
| 30 | - return | 30 | + return 4 |
| 31 | end | 31 | end |
| 32 | 32 | ||
| 33 | local calSell = role.dinerData:updateSell(slot, true) or { | 33 | local calSell = role.dinerData:updateSell(slot, true) or { |
| @@ -38,7 +38,7 @@ function _M.addSellRpc( agent, data ) | @@ -38,7 +38,7 @@ function _M.addSellRpc( agent, data ) | ||
| 38 | local count = msg.count | 38 | local count = msg.count |
| 39 | local maxDishCount = role.dinerData:getMaxDishs() | 39 | local maxDishCount = role.dinerData:getMaxDishs() |
| 40 | if math.illegalNum(count + calSell.lastCount, 1, maxDishCount) then | 40 | if math.illegalNum(count + calSell.lastCount, 1, maxDishCount) then |
| 41 | - return | 41 | + return 5 |
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | local cost = dishData.material:toNumMap() | 44 | local cost = dishData.material:toNumMap() |
| @@ -46,7 +46,7 @@ function _M.addSellRpc( agent, data ) | @@ -46,7 +46,7 @@ function _M.addSellRpc( agent, data ) | ||
| 46 | n = n * count | 46 | n = n * count |
| 47 | end | 47 | end |
| 48 | if not role:checkItemEnough(cost) then | 48 | if not role:checkItemEnough(cost) then |
| 49 | - return | 49 | + return 6 |
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | role:costItems(cost) | 52 | role:costItems(cost) |
src/agent.lua
| @@ -201,8 +201,8 @@ skynet.register_protocol { | @@ -201,8 +201,8 @@ skynet.register_protocol { | ||
| 201 | 201 | ||
| 202 | if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end | 202 | if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end |
| 203 | local result = method(agentInfo, data) | 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 | end | 206 | end |
| 207 | end) | 207 | end) |
| 208 | end | 208 | end |