From cc5ca7f30974819bdce0024506528c11cece9e1f Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Mon, 20 Apr 2020 16:10:56 +0800 Subject: [PATCH] 缓存battleKey --- src/actions/HangAction.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 4c2d8c3..f96b48e 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -120,6 +120,7 @@ function _M.checkRpc(agent, data) return true end +local _BattleKey = nil function _M.startBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) @@ -141,10 +142,8 @@ function _M.startBattleRpc(agent, data) return 3 end - local key = tostring(math.random()) - hangInfo.key = key - local nowTime = skynet.timex() - role:updateProperty({field = "hangInfo", value = hangInfo}) + _BattleKey = tostring(math.random()) + role:checkTaskEnter("HangBattle", {id = carbonId}) SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = key})) return true @@ -154,7 +153,7 @@ function _M.endBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local hangInfo = role:getProperty("hangInfo") - if not msg.key or msg.key ~= hangInfo.key then + if not msg.key or msg.key ~= _BattleKey then return 1 end local carbonId = msg.carbonId @@ -190,7 +189,6 @@ function _M.endBattleRpc(agent, data) role:checkTaskEnter("HangPass", {id = carbonId}) end - hangInfo.key = nil role:updateProperty({field = "hangInfo", value = hangInfo}) role:log("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId}) -- libgit2 0.21.2