|
|
@@ -18,6 +18,8 @@ local wDay
|
|
|
-- 玩家战斗数据缓存表
|
|
|
local battleDataCache = {}
|
|
|
|
|
|
+local requestArr = {}
|
|
|
+
|
|
|
|
|
|
local function updateWDay()
|
|
|
wDay = Util.getWeekDay()
|
|
|
@@ -203,31 +205,30 @@ local function getPlayerBattleData(serverId, playerUuid, extraArgs)
|
|
|
BattleDataCS.GetPlayerCombatData(serverId, playerUuid, BattleDataCS.AREABTTLE_TAG, CombatDefine.COMBAT_TYPE33, extraArgs)
|
|
|
end
|
|
|
|
|
|
--- 处于准备阶段处理, 给服务器进行匹配, 并通知普通服上传玩家战斗数据
|
|
|
-local function prepareHandle()
|
|
|
- local stateDB = AreaBattleDB.GetState()
|
|
|
- if stateDB ~= AreaBattleDefine.STATE_PREPARE then
|
|
|
+function Timed_GetPlayerBattleData()
|
|
|
+ if not requestArr or not next(requestArr) then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- -- 服务器进行匹配
|
|
|
- genMacthArr()
|
|
|
+ local maxNum = math.min(#requestArr, AreaBattleDefine.GET_BATTLE_MAX_CNT_TIMES)
|
|
|
+ for i=1, maxNum do
|
|
|
+ local info = table.remove(requestArr)
|
|
|
+ getPlayerBattleData(info[1], info[2], info[3])
|
|
|
+ end
|
|
|
|
|
|
- -- 让普通服上传战斗数据
|
|
|
+ if #requestArr > 0 then
|
|
|
+ Timer.addLater(1, Timed_GetPlayerBattleData, requestArr)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+-- 向普通服请求战斗数据
|
|
|
+local function requestPlayerBattleData()
|
|
|
local matchSrvArr = AreaBattleDB.GetMatchSrvArr()
|
|
|
local serverList = AreaBattleDB.GetServerList()
|
|
|
if not matchSrvArr or #matchSrvArr == 0 or not next(serverList) then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- local args = {
|
|
|
- firstIdx = 0,
|
|
|
- secondIdx = 0,
|
|
|
- identity = 0, --身份,1-进攻方, 2-防御方
|
|
|
- serverId = 0,
|
|
|
- playerUuid = "",
|
|
|
- }
|
|
|
-
|
|
|
for idx, matchSrvTb in ipairs(matchSrvArr) do
|
|
|
local serverId1 = matchSrvTb[1]
|
|
|
local serverId2 = matchSrvTb[2]
|
|
|
@@ -235,24 +236,53 @@ local function prepareHandle()
|
|
|
local playerArr2 = serverList[serverId2] and serverList[serverId2].playerInfoArr or {}
|
|
|
local maxPlayerCnt = math.max(#playerArr1, #playerArr2)
|
|
|
|
|
|
- args.firstIdx = idx
|
|
|
-
|
|
|
for i=1, maxPlayerCnt do
|
|
|
- args.secondIdx = i
|
|
|
local playerUuid1 = playerArr1[i].uuid
|
|
|
local playerUuid2 = playerArr2[i].uuid
|
|
|
|
|
|
if playerUuid1 then
|
|
|
- args.identity = 1
|
|
|
- getPlayerBattleData(serverId1, playerUuid1, args)
|
|
|
+ local args = {
|
|
|
+ firstIdx = idx,
|
|
|
+ secondIdx = i,
|
|
|
+ identity = 1, --身份,1-进攻方, 2-防御方
|
|
|
+ serverId = 0,
|
|
|
+ playerUuid = "",
|
|
|
+ }
|
|
|
+ -- getPlayerBattleData(serverId1, playerUuid1, args)
|
|
|
+ requestArr[#requestArr+1] = {serverId1, playerUuid1, args}
|
|
|
end
|
|
|
|
|
|
if playerUuid2 then
|
|
|
- args.identity = 2
|
|
|
- getPlayerBattleData(serverId2, playerUuid2, args)
|
|
|
+ local args = {
|
|
|
+ firstIdx = idx,
|
|
|
+ secondIdx = i,
|
|
|
+ identity = 2, --身份,1-进攻方, 2-防御方
|
|
|
+ serverId = 0,
|
|
|
+ playerUuid = "",
|
|
|
+ }
|
|
|
+ -- getPlayerBattleData(serverId2, playerUuid2, args)
|
|
|
+ requestArr[#requestArr+1] = {serverId2, playerUuid2, args}
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+ Timed_GetPlayerBattleData()
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+-- 处于准备阶段处理, 给服务器进行匹配, 并通知普通服上传玩家战斗数据
|
|
|
+local function prepareHandle()
|
|
|
+ local stateDB = AreaBattleDB.GetState()
|
|
|
+ if stateDB ~= AreaBattleDefine.STATE_PREPARE then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 服务器进行匹配
|
|
|
+ genMacthArr()
|
|
|
+
|
|
|
+ -- 让普通服上传战斗数据
|
|
|
+ requestPlayerBattleData()
|
|
|
end
|
|
|
|
|
|
-- 上一轮 ~ 新一轮准备阶段的处理
|
|
|
@@ -455,7 +485,7 @@ function N2C_GetBaseInfo(msg)
|
|
|
msgData.endTime = toDayStartTime + AreaBattleDefine.END_STATE_START_SEC
|
|
|
|
|
|
local now = os.time()
|
|
|
- if state == AreaBattleDefine.STATE_AWARD and now < toDayStartTime + END_STATE_START_SEC then
|
|
|
+ if state == AreaBattleDefine.STATE_AWARD and now < toDayStartTime + AreaBattleDefine.END_STATE_START_SEC then
|
|
|
msgData.stage = AreaBattleDefine.STATE_BATTLE
|
|
|
end
|
|
|
else
|
|
|
@@ -609,7 +639,6 @@ function oneMin()
|
|
|
return
|
|
|
end
|
|
|
|
|
|
-
|
|
|
local now = os.time()
|
|
|
local toDayStartTime = getTodayStartTime()
|
|
|
|
|
|
@@ -629,6 +658,23 @@ function oneMin()
|
|
|
if now >= (toDayStartTime + AreaBattleDefine.BATTLE_STATE_START_SEC) and stateDB == AreaBattleDefine.STATE_PREPARE then
|
|
|
-- 防止某些情况下,进入准备阶段后普通服数据还没上传完就进入对战阶段
|
|
|
if now - nowRoundStartTi > AreaBattleDefine.BATTLE_DATA_TIME then
|
|
|
+
|
|
|
+ -- 重启跨服后导致战斗数据缓存没了,则重新获取
|
|
|
+ if not next(battleDataCache) then
|
|
|
+ -- 可能存在响应比较慢的情况,保证只执行一次 requestPlayerBattleData
|
|
|
+ print("=============战斗数据缓存没了,重新请求=====================")
|
|
|
+ if #requestArr == 0 then
|
|
|
+ return requestPlayerBattleData()
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 处于请求战斗数据过程中, 等请求完再进入战斗
|
|
|
+ if #requestArr > 0 then
|
|
|
+ print("=============处于请求战斗缓存中,请稍后=====================")
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
print("======================时间周日, 通过oneMin()进入对战阶段========================")
|
|
|
AreaBattleDB.UpdateState(AreaBattleDefine.STATE_BATTLE)
|
|
|
BattleStageHandle()
|
|
|
@@ -664,6 +710,20 @@ function onHour(hour)
|
|
|
|
|
|
-- 防止某些情况下,进入准备阶段后,普通服数据还没上传完就进入对战阶段
|
|
|
if stateDB == AreaBattleDefine.STATE_PREPARE and (now - nowRoundStartTi > AreaBattleDefine.BATTLE_DATA_TIME) then
|
|
|
+
|
|
|
+ -- 重启跨服后导致战斗数据缓存没了,则重新获取
|
|
|
+ if not next(battleDataCache) then
|
|
|
+ -- 可能存在响应比较慢的情况,保证只执行一次 requestPlayerBattleData
|
|
|
+ if #requestArr == 0 then
|
|
|
+ return requestPlayerBattleData()
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 处于请求战斗数据过程中, 等请求完再进入战斗
|
|
|
+ if #requestArr > 0 then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
AreaBattleDB.UpdateState(AreaBattleDefine.STATE_BATTLE)
|
|
|
BattleStageHandle()
|
|
|
end
|