|
@@ -21,7 +21,7 @@ local dbUpdate = {_id=nil}
|
|
|
local dbUpdateField = {}
|
|
local dbUpdateField = {}
|
|
|
|
|
|
|
|
local RANK_SHOW_NUM = 50 -- 排行榜显示的数量
|
|
local RANK_SHOW_NUM = 50 -- 排行榜显示的数量
|
|
|
-local notifyActEnd = false -- 是否收到活动结束通知的标识
|
|
|
|
|
|
|
+local repeateServerIdList = {}
|
|
|
|
|
|
|
|
local battleGroundData = {
|
|
local battleGroundData = {
|
|
|
-- allAreaRankList = { -- 各个战区排行榜, 榜上的都是真实玩家
|
|
-- allAreaRankList = { -- 各个战区排行榜, 榜上的都是真实玩家
|
|
@@ -149,6 +149,12 @@ function BattleGround_InitAfterStart()
|
|
|
loadData()
|
|
loadData()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+function onZero()
|
|
|
|
|
+ if next(repeateServerIdList) then
|
|
|
|
|
+ repeateServerIdList = {}
|
|
|
|
|
+ end
|
|
|
|
|
+end
|
|
|
|
|
+
|
|
|
|
|
|
|
|
-- 通过本服Id获取所在战区Id
|
|
-- 通过本服Id获取所在战区Id
|
|
|
local function getWarZoneServerIdx(sourceServerId)
|
|
local function getWarZoneServerIdx(sourceServerId)
|
|
@@ -157,6 +163,11 @@ local function getWarZoneServerIdx(sourceServerId)
|
|
|
return nServerKey
|
|
return nServerKey
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+-- 通服务器Id获取所在战区Id的最小服务器Id,最大服务器Id
|
|
|
|
|
+local function getWarZoneServerArea(sourceServerId)
|
|
|
|
|
+ local nServerKey = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(sourceServerId)
|
|
|
|
|
+ return MiddleConnect.MiddleConnect_GetWarZoneServer(nServerKey)
|
|
|
|
|
+end
|
|
|
|
|
|
|
|
-- 生成一个战区排行榜
|
|
-- 生成一个战区排行榜
|
|
|
local function genWarZoneRankList(warZoneServerIdx)
|
|
local function genWarZoneRankList(warZoneServerIdx)
|
|
@@ -467,73 +478,81 @@ function BG_N2C_Lineup_Update(msg)
|
|
|
updateValue("allAreaRankList".."."..warZoneServerIdx, battleGroundData.allAreaRankList[warZoneServerIdx])
|
|
updateValue("allAreaRankList".."."..warZoneServerIdx, battleGroundData.allAreaRankList[warZoneServerIdx])
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
-- 活动结束
|
|
-- 活动结束
|
|
|
function BG_N2C_Act_End(msg)
|
|
function BG_N2C_Act_End(msg)
|
|
|
- if notifyActEnd then
|
|
|
|
|
|
|
+ local warZoneServerIdMin, warZoneServerIdMax = getWarZoneServerArea(msg.sourceServerId)
|
|
|
|
|
+
|
|
|
|
|
+ if not warZoneServerIdMin or warZoneServerIdMin == 0 then
|
|
|
return
|
|
return
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- -- local logData = {
|
|
|
|
|
- -- joinList = battleGroundData.joinList,
|
|
|
|
|
- -- allAreaRankList = battleGroundData.allAreaRankList,
|
|
|
|
|
- -- }
|
|
|
|
|
-
|
|
|
|
|
- -- local logTb = Util.serialize(logData)
|
|
|
|
|
- -- local logStr = table.concat(logTb)
|
|
|
|
|
- -- writeLog(logStr)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- local logTab1 = Util.serialize(battleGroundData.joinList)
|
|
|
|
|
- local logStr1 = table.concat(logTab1)
|
|
|
|
|
- Timer.addLater(40, writeLog, logStr1)
|
|
|
|
|
-
|
|
|
|
|
- local logTab2 = Util.serialize(battleGroundData.allAreaRankList)
|
|
|
|
|
- local logStr2 = table.concat(logTab2)
|
|
|
|
|
- Timer.addLater(45, writeLog, logStr2)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if repeateServerIdList[warZoneServerIdMin] then
|
|
|
|
|
+ return
|
|
|
|
|
+ end
|
|
|
|
|
|
|
|
-- 更新标识
|
|
-- 更新标识
|
|
|
- notifyActEnd = true
|
|
|
|
|
|
|
+ repeateServerIdList[warZoneServerIdMin] = true
|
|
|
|
|
|
|
|
- local fd_2_Rank = {}
|
|
|
|
|
|
|
+ local fd_2_PlayerList = {}
|
|
|
local joinList = battleGroundData.joinList
|
|
local joinList = battleGroundData.joinList
|
|
|
- local allAreaRankList = battleGroundData.allAreaRankList
|
|
|
|
|
|
|
+
|
|
|
|
|
+ local serverIdxMin = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(warZoneServerIdMin)
|
|
|
|
|
+ local serverIdxMax = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(warZoneServerIdMax)
|
|
|
|
|
|
|
|
-- 参与玩家(包括在榜玩家)
|
|
-- 参与玩家(包括在榜玩家)
|
|
|
- for _, playerInfo in ipairs(joinList or {}) do
|
|
|
|
|
|
|
+ for k = #joinList, 1, -1 do
|
|
|
|
|
+ local playerInfo = joinList[k]
|
|
|
local serverId = playerInfo[1]
|
|
local serverId = playerInfo[1]
|
|
|
- local fd = MiddleManager.getFDBySvrIndex(serverId)
|
|
|
|
|
- if fd then
|
|
|
|
|
- fd_2_Rank[fd] = fd_2_Rank[fd] or {}
|
|
|
|
|
- fd_2_Rank[fd][#fd_2_Rank[fd]+1] = {ServerCommerceActDefine.COMMERCEACT_NPC_CNT, playerInfo[2]}
|
|
|
|
|
|
|
+ if serverId >= serverIdxMin and serverId <= serverIdxMax then
|
|
|
|
|
+ local fd = MiddleManager.getFDBySvrIndex(serverId)
|
|
|
|
|
+ if fd then
|
|
|
|
|
+ fd_2_PlayerList[fd] = fd_2_PlayerList[fd] or {}
|
|
|
|
|
+ fd_2_PlayerList[fd][#fd_2_PlayerList[fd]+1] = {ServerCommerceActDefine.COMMERCEACT_NPC_CNT, playerInfo[2]}
|
|
|
|
|
+ end
|
|
|
|
|
+ table.remove(joinList, k)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-- 在榜玩家
|
|
-- 在榜玩家
|
|
|
- for _, rankList in pairs(allAreaRankList or {}) do
|
|
|
|
|
- for _, player in pairs(rankList) do
|
|
|
|
|
- local fd = MiddleManager.getFDBySvrIndex(player.serverId)
|
|
|
|
|
- if fd then
|
|
|
|
|
- fd_2_Rank[fd] = fd_2_Rank[fd] or {}
|
|
|
|
|
- local idx = findVal(fd_2_Rank[fd], player.playerUuid)
|
|
|
|
|
- if idx then
|
|
|
|
|
- fd_2_Rank[fd][idx][1] = player.rank
|
|
|
|
|
- end
|
|
|
|
|
|
|
+ local myWarZoneRankList = getMyWarZoneRankList(msg.sourceServerId)
|
|
|
|
|
+ for _, player in pairs(myWarZoneRankList or {}) do
|
|
|
|
|
+ local fd = MiddleManager.getFDBySvrIndex(player.serverId)
|
|
|
|
|
+ if fd then
|
|
|
|
|
+ fd_2_PlayerList[fd] = fd_2_PlayerList[fd] or {}
|
|
|
|
|
+ local idx = findVal(fd_2_PlayerList[fd], player.playerUuid)
|
|
|
|
|
+ if idx then
|
|
|
|
|
+ fd_2_PlayerList[fd][idx][1] = player.rank
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- if next(fd_2_Rank) then
|
|
|
|
|
|
|
+ if battleGroundData.allAreaRankList and battleGroundData.allAreaRankList[warZoneServerIdMin] then
|
|
|
|
|
+ battleGroundData.allAreaRankList[warZoneServerIdMin] = nil
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ if next(fd_2_PlayerList) then
|
|
|
|
|
+ -- 写日志
|
|
|
|
|
+ local logTab2 = Util.serialize(fd_2_PlayerList)
|
|
|
|
|
+ local logStr2 = table.concat(logTab2)
|
|
|
|
|
+ Timer.addLater(45, writeLog, logStr2)
|
|
|
|
|
+
|
|
|
local delay_sec = 0
|
|
local delay_sec = 0
|
|
|
- for fd, rankArr in pairs(fd_2_Rank) do
|
|
|
|
|
|
|
+ for fd, rankArr in pairs(fd_2_PlayerList) do
|
|
|
delay_sec = delay_sec + 3
|
|
delay_sec = delay_sec + 3
|
|
|
Timer.addLater(delay_sec, issueReward, fd, rankArr)
|
|
Timer.addLater(delay_sec, issueReward, fd, rankArr)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- -- 重置排行榜数据
|
|
|
|
|
- battleGroundData.joinList = nil
|
|
|
|
|
|
|
+ -- 更新数据
|
|
|
|
|
+ if not next(battleGroundData.joinList) then
|
|
|
|
|
+ battleGroundData.joinList = nil
|
|
|
|
|
+ end
|
|
|
updateValue("joinList", battleGroundData.joinList)
|
|
updateValue("joinList", battleGroundData.joinList)
|
|
|
- battleGroundData.allAreaRankList = nil
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if not next(battleGroundData.allAreaRankList) then
|
|
|
|
|
+ battleGroundData.allAreaRankList = nil
|
|
|
|
|
+ end
|
|
|
updateValue("allAreaRankList", battleGroundData.allAreaRankList)
|
|
updateValue("allAreaRankList", battleGroundData.allAreaRankList)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|