Browse Source

“同步常规版修改”

gitxsm 3 tuần trước cách đây
mục cha
commit
0d3fb62119

+ 0 - 2
script/common/CommonDB.lua

@@ -45,7 +45,6 @@ KEY_BAN_DATA = "banData"								-- 封禁数据
 KEY_DESKTOP_DATA = "desktopData"					-- 桌面添加数据(账号级)
 KEY_REBATE_DATA = "rebateData"							-- 渠道返利数据
 KEY_ANOTHERWORLDBATTLE_START_TI = "anotherWorldBattleStart" -- 最近一轮异界之战开启时间
--- KEY_BIGRPLAYER_SHOW_DATA = "bigRPlayerShowData"				-- 大R玩家实力展示相关数据
 
 db = db or {
 	serverStartTime = nil,								-- 开服时间
@@ -74,7 +73,6 @@ db = db or {
 	commerceActInfo = {},								-- 跨服商业活动信息
 	jjcNewladderInfo = {},								-- 天梯赛信息
 	commerceMiddleActInfo = {},							-- 中心服跨服商业活动信息
-	-- bigRPlayerShowData = {},
 }
 
 

+ 1 - 1
script/core/Timer.lua

@@ -126,7 +126,7 @@ function doZhengDian(hour)
         BillboardLogic.onZero()
         ChatRecord.CHAT_RECORD_REPETITION = {}
         HeroGrowUp.actLoop()
-        LostTempleLogic.onZero()
+        -- LostTempleLogic.onZero()
 	    VoucherShopLogic.VoucherShop_OnZero()
         MainDianLogic.MaiDian_OnTime()
         ServerCommerceMiddle.CommerceMiddle_OnZero()

+ 3 - 0
script/module/bag/BagLogic.lua

@@ -285,6 +285,9 @@ function handlerSpObj(human, itemID, itemCnt, logType)
     	return
     end
 
+	Log.write(Log.LOGID_OSS_ITEM, human.db._id, human.db.account, human.db.name, human.db.lv,
+		LogDefine.DEFINE[logType] + LogDefine.TYPE["item"] , itemID, itemCnt, 0)
+
 	local cmdstr = itemConfig.cmd and itemConfig.cmd[1]
 	if cmdstr and ItemLogic.cmd[cmdstr] then
 		ItemLogic.onlyuse(human, itemID, itemCnt, logType, true)

+ 8 - 4
script/module/chengjiu/ChengjiuLogic.lua

@@ -297,6 +297,10 @@ function getReward(human,taskID)
     GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_JIEFENG_BAOJU)
     RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
 
+    -- 刷新洗练凤凰..
+    if taskID == 402 then
+        RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002)
+    end
 
     local giftType
     GiftLogic = GiftLogic or require("topup.GiftLogic")
@@ -377,10 +381,10 @@ function checkTaskState(human)
             human.db.chengjiu.task[k] = CJ_TASK_STATE_1
             RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
             -- 同时刷新秘宝/圣遗物/精灵入口的红点(强制发送,确保可解封时客户端能看到提示)
-            RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002,true)
-            RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2006, true)
-            RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2021, true)
-            RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2031, true)
+            -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002,true)
+            -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2006, true)
+            -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2021, true)
+            -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2031, true)
             local msgRet = Msg.gc.GC_DAILYSHARE_SET
             msgRet.type = 2
             msgRet.desc = v.desc

+ 1 - 2
script/module/elf/ElfLogic.lua

@@ -257,8 +257,7 @@ end
 local function updateDot(human, targetQuality)
     local cfgHtbl = generateCfgByQuality(targetQuality)
 
-    -- 如果该品质的精灵存在可激活或可升级的情况,发送红点
-    if dotJudgment(human, cfgHtbl) then
+    if not dotJudgment(human, cfgHtbl) then
         local dotID = 0
         if targetQuality == 1 then
             dotID = RoleSystemDefine.ROLE_SYS_ID_2032

+ 22 - 1
script/module/lostTemple/lostTempleLogic.lua

@@ -46,6 +46,13 @@ DAY_1s = 86400
 --跳过战斗需要的战力
 local SHOWQUICKPOWER = 0 --2000000
 
+local function resetDB(human)
+    local query = { _id = human.db._id }
+    LuaMongo.remove(DB.db_lost_temple, query)
+end
+
+
+
 function initAfterHot()
 
 end
@@ -113,7 +120,7 @@ function onZero()
     -- LuaMongo.remove(DB.db_lost_temple)
 
     -- 修改: 延迟60s再清除数据
-    Timer.addLater(60, LuaMongo.remove, DB.db_lost_temple)
+    -- Timer.addLater(60, LuaMongo.remove, DB.db_lost_temple)
 
     -- 已经关闭
     -- if (openDay - 7 + 1) % 2 ~= 0 then
@@ -127,6 +134,8 @@ function updateDaily(human)
         return
     end
 
+    resetDB(human)
+
     print("[lostTempleLogic - updateDaily] 天数刷新 玩家移除lostTemple数据 name = "..human.db.name)
     human.lostTemple = nil
     
@@ -1340,6 +1349,10 @@ end
 
 -- 查询一键扫荡状态
 function LostTemple_OneClickSweep_Query(human)
+    if not isOpen(human) then
+        return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
+    end
+
     local msgRet = Msg.gc.GC_LOGT_TEMPLE_ONECLICK_SWEEP_QUERY
     msgRet.state = 0
 
@@ -1357,6 +1370,9 @@ end
 
 -- 查询一键扫荡奖励
 function LostTemple_OneClickSweep_Award(human)
+    if not isOpen(human) then
+        return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
+    end
     local msgRet = Msg.gc.GC_LOGT_TEMPLE_ONECLICK_SWEEP_AWARD
     msgRet.awardArr[0] = 0
 
@@ -1372,6 +1388,9 @@ end
 
 -- 进行一键扫荡
 function LostTemple_OneClickSweep_Do(human)
+    if not isOpen(human) then
+        return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
+    end
     local isBuyKing = HeroGrowUp.isBuyKing(human)
     if not isBuyKing or isBuyKing ~= 1 then
         return Broadcast.sendErr(human, Lang.LOST_NO_BUY)
@@ -1411,6 +1430,8 @@ function LostTemple_OneClickSweep_Do(human)
 
     YunYingLogic.onCallBack(human, "lostTempleCombat", 1)
 
+    TriggerLogic.PublishEvent(TriggerDefine.LOSTTEMPLE_PASS_LAYER, human.db._id, 3)
+
     LostTemple_OneClickSweep_Query(human)
 
     RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1208)

+ 136 - 30
script/module/mail/MailManager.lua

@@ -9,6 +9,7 @@ local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
 local RoleSystemDefine = require("roleSystem.RoleSystemDefine") 
 local RoleDBLogic = require("role.RoleDBLogic")
 local MailExcel = require("excel.mail")
+local CommonDB = require("common.CommonDB")
 
 SYSTEM = 1 				-- 系统邮件
 GONGGAO = 2 				-- 公告
@@ -75,7 +76,8 @@ function add(type,receiverUuid,title,content,items,senderName,sender,time,fbTime
         mail.flag = 1
     end
 	LuaMongo.insert(DB.db_mail, mail)
-	RoleSystemLogic.onDotByUuid(receiverUuid, RoleSystemDefine.ROLE_SYS_ID_204)
+	-- 检测红点会调用getMails(), 短时间插入多封邮件加上玩家邮件数量过多,会发生段错误
+	-- RoleSystemLogic.onDotByUuid(receiverUuid, RoleSystemDefine.ROLE_SYS_ID_204)
 	return mail
 
 end
@@ -156,45 +158,149 @@ local function cmpMail(a, b)
 end
 
 local mails = {}
-function getMails(receiverUuid,mailType)
-	for key in ipairs(mails) do 
-		mails[key] = nil
-	end
+-- function getMails(receiverUuid,mailType)
+-- 	for key in ipairs(mails) do 
+-- 		mails[key] = nil
+-- 	end
+
+-- 	FIELD_RECEIVER.receiverUuid = receiverUuid
+-- 	FIELD_RECEIVER.type = mailType
+
+--     LuaMongo.find(DB.db_mail,{["$query"]=FIELD_RECEIVER})
+    
+-- 	local lastTime = os.time() - 7 * 86400
+--     local mailCnt = 0
+-- 	while true do
+-- 		local mail = {}
+-- 		-- if not LuaMongo.next(mail) then
+-- 		-- 	break
+-- 		-- end
 
-	FIELD_RECEIVER.receiverUuid = receiverUuid
-	FIELD_RECEIVER.type = mailType
+-- 		local res, err = pcall(function ()
+-- 			return LuaMongo.next(mail)
+-- 		end)
 
-    LuaMongo.find(DB.db_mail,{["$query"]=FIELD_RECEIVER})
+-- 		if not res then
+-- 			Log.write(Log.LOGID_DEBUG, "MailManager.getMails err = ".. err)
+-- 			break
+-- 		end
+
+-- 		if not err then
+-- 			break
+-- 		end
+
+--        if mail.expireTime then  -- 有指定过期时间
+--             if mail.time > os.time() - mail.expireTime then
+-- 			    mailCnt = mailCnt + 1
+-- 			    mails[mailCnt] = mail
+--             end
+--        elseif mail.time > lastTime then -- 没有就用默认过期时间
+--             mailCnt = mailCnt + 1
+-- 			mails[mailCnt] = mail
+--        end
+-- 	end
     
-	local lastTime = os.time() - 7 * 86400
+--     if mailCnt > MAIL_MAX_CNT then
+-- 		table.sort(mails, cmpMail)
+-- 		for i = MAIL_MAX_CNT + 1, mailCnt do
+-- 			mails[i] = nil
+-- 		end
+-- 	end    
+-- 	return mails
+-- end
+
+-- 替换原有的 getMails 函数
+function getMails(receiverUuid, mailType)
+    -- 1. 清空缓存表
+    for i = 1, #mails do mails[i] = nil end
+
+    local now = os.time()
     local mailCnt = 0
-	while true do
-		local mail = {}
-		if not LuaMongo.next(mail) then
-			break
-		end
+    local tempMails = {}
+    local SCAN_LIMIT = 2000  -- 单次分段查询安全上限
+    local foundEnough = false
+
+    -- 2.将时间划分为多个小窗口,避免单次 find 触发底层 OOM
+    -- 窗口设计:最近7天 -> 7~14天 -> 14~30天 -> 30~60天
+    local timeWindows = {
+        {now - 7*86400,   now},
+        {now - 14*86400,  now - 7*86400},
+        {now - 30*86400,  now - 14*86400},
+        {now - 60*86400,  now - 30*86400}
+    }
+	-- 60天 -> 开服
+	local serverOpenTime = CommonDB.getServerOpenTime()
+	timeWindows[#timeWindows+1] = { serverOpenTime, now - 60*86400 }
+
+    for _, window in ipairs(timeWindows) do
+        if foundEnough then break end
+
+        -- 使用最简平铺查询,彻底避开 C 扩展解析缺陷
+        local query = {
+            receiverUuid = receiverUuid,
+            type = mailType,
+            time = { ["$gte"] = window[1], ["$lte"] = window[2] }
+        }
 
-       if mail.expireTime then  -- 有指定过期时间
-            if mail.time > os.time() - mail.expireTime then
-			    mailCnt = mailCnt + 1
-			    mails[mailCnt] = mail
+        LuaMongo.find(DB.db_mail, query)
+
+        local mail = {}
+        local scanCnt = 0
+        while true do
+            local has_next = LuaMongo.next(mail)
+            if not has_next then break end
+            
+            scanCnt = scanCnt + 1
+            if scanCnt > SCAN_LIMIT then 
+                Log.write(Log.LOGID_DEBUG, string.format("Mail segment limit hit! uuid=%s window=%d~%d", 
+                    receiverUuid, window[1], window[2]))
+                break 
             end
-       elseif mail.time > lastTime then -- 没有就用默认过期时间
+
+            -- 浅拷贝隔离 C 驱动内部 Buffer
+            local m = {}
+            for k, v in pairs(mail) do m[k] = v end
+            tempMails[#tempMails + 1] = m
+
+            -- 清空复用表
+            for k in pairs(mail) do mail[k] = nil end
+        end
+
+        -- 如果已收集足够多数据(留足过滤冗余),提前终止后续窗口查询
+        if #tempMails >= 500 then 
+            foundEnough = true 
+            break 
+        end
+    end
+
+    -- 3.按时间倒序排序,确保后续取到的是“最新”的
+    table.sort(tempMails, cmpMail)
+
+    -- 4. 过滤过期邮件,精准截取最新 100 条
+    for _, m in ipairs(tempMails) do
+        if type(m.time) ~= "number" then m.time = 0 end
+
+        local isExpired = false
+        local expireTime = m.expireTime
+        if expireTime and type(expireTime) == "number" then
+            if m.time <= now - expireTime then isExpired = true end
+        elseif m.time <= now - 7 * 86400 then
+            isExpired = true
+        end
+
+        if not isExpired then
             mailCnt = mailCnt + 1
-			mails[mailCnt] = mail
-       end
-	end
-    
-    if mailCnt > MAIL_MAX_CNT then
-		table.sort(mails, cmpMail)
-		for i = MAIL_MAX_CNT + 1, mailCnt do
-			mails[i] = nil
-		end
-	end    
-	return mails
+            mails[mailCnt] = m
+            if mailCnt >= MAIL_MAX_CNT then break end -- 达到 100 条立即退出
+        end
+    end
+
+    return mails
 end
 
 
+
+
 function saveMail(mail)
     FIELD_ID._id = mail._id
     LuaMongo.update(DB.db_mail, FIELD_ID, mail)

+ 2 - 2
script/module/serverCommerce/ServerCommerceActDefine.lua

@@ -9,8 +9,8 @@ COMMERCEACT_BEGINTIME = 0               -- 开启时间
 COMMERCEACT_ENDTIME = 23                -- 结束时间
 COMMERCEACT_LASTDAY = 7                 -- 持续时间
 COMMERCEACT_BEGINDELATTIME = 10 * 60    -- 延迟10分钟开始
-COMMERCEACT_INITSERVERTIME =4 * 60     -- 普通服 起服3分钟请求活动是否开始
-COMMERCEACT_INITOPENDAY = 3 * 60        -- 中心服2分钟后请求普通服开服时间
+COMMERCEACT_INITSERVERTIME = 10 * 60 --4 * 60     -- 普通服 起服3分钟请求活动是否开始
+COMMERCEACT_INITOPENDAY = 9 * 60 -- 3 * 60        -- 中心服2分钟后请求普通服开服时间
 COMMERCEACT_RANKUPDATE = 150            -- 普通服 5 分钟请求排行榜数据
 COMMERCEACT_ENDBATCH = 3                -- 结束批次