From 214061fabcfb64100eb3e9c09e84a09e1b3b6788 Mon Sep 17 00:00:00 2001 From: zhengshouren <448949750@qq.com> Date: Fri, 17 May 2019 14:19:12 +0800 Subject: [PATCH] 错误情况,返回错误码 --- src/actions/DinerAction.lua | 12 ++++++------ src/agent.lua | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 449669b..4d2fd0f 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -12,22 +12,22 @@ function _M.addSellRpc( agent, data ) local slot = msg.slot if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then - return + return 1 end slot = tostring(slot) local dish = msg.dish local dishSet = csvdb["diner_dishCsv"][dish] if not dishSet then - return + return 2 end local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0) if dishLevel == 0 then - return + return 3 end local dishData = dishSet[dishLevel] if not dishData then - return + return 4 end local calSell = role.dinerData:updateSell(slot, true) or { @@ -38,7 +38,7 @@ function _M.addSellRpc( agent, data ) local count = msg.count local maxDishCount = role.dinerData:getMaxDishs() if math.illegalNum(count + calSell.lastCount, 1, maxDishCount) then - return + return 5 end local cost = dishData.material:toNumMap() @@ -46,7 +46,7 @@ function _M.addSellRpc( agent, data ) n = n * count end if not role:checkItemEnough(cost) then - return + return 6 end role:costItems(cost) diff --git a/src/agent.lua b/src/agent.lua index 9c9d5aa..c740d69 100644 --- a/src/agent.lua +++ b/src/agent.lua @@ -201,8 +201,8 @@ skynet.register_protocol { if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end local result = method(agentInfo, data) - if not result then - SendPacket(actionCodes.Sys_innerErrorMsg, MsgPack.pack({id = cmd})) + if not result or type(result) == "number" then + SendPacket(actionCodes.Sys_innerErrorMsg, MsgPack.pack({id = cmd * 100 + (result or 0)})) end end) end -- libgit2 0.21.2