local Util = require("common.Util") local WarZoneConf = require("excel.WarZone") local MiddleConnect = require("middle.MiddleConnect") local MiddleManager = require("middle.MiddleManager") local InnerMsg = require("core.InnerMsg") local Config = require("Config") local CommonDB = require("common.CommonDB") local Timer = require("core.Timer") local CommerceManger = require("serverCommerce.ServerCommerceManager") -- 缓存开服天数 local tServerOpenDay = nil local SERVERCOMMERCEOPENDAY = 8 -- 活动开启要求天数 -- 获取(中心服主动去获取) function CommerceMiddle_GetOpen() local tWarZoneConf = WarZoneConf.group local tMsgData = InnerMsg.wl.WL_COMMERCE_QUERYOPENDAY for _, v in ipairs(tWarZoneConf) do local nFirstServerID = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(v.nMinServerID) local fd = MiddleManager.getFDBySvrIndex(nFirstServerID) if fd then InnerMsg.sendMsg(fd, tMsgData) end end end -- 回复开服天数 function CommerceMiddle_SendOpenDay(fd, msg) local nOpenDay = msg.nOpenDay local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID) if not tServerOpenDay then tServerOpenDay = {} end tServerOpenDay[nServerConfID] = nOpenDay end -- 请求开服天数 function CommerceMiddle_QueryOpenDay(fd, msg) local tMsgData = InnerMsg.lw.LW_COMMERCE_SENDOPENDAY tMsgData.nOpenDay = CommonDB.getServerOpenDay() tMsgData.nSrcServerID = Config.SVR_INDEX InnerMsg.sendMsg(0, tMsgData) end function CommerceMiddle_QueryOpenAct(fd, msg) local nConfServerID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID) local nFirstServerID for _, v in ipairs(WarZoneConf.group) do if v.nMinServerID <= nConfServerID and v.nMaxServerID >= nConfServerID then nFirstServerID = v.nMinServerID break end end if nil == nFirstServerID or not tServerOpenDay or not tServerOpenDay[nFirstServerID] then print("[QueryOpenAct] 获取不到战区的第一个服务器\n") return end local nSrcFD = MiddleManager.getFDBySvrIndex(msg.nSrcServerID) if not nSrcFD then return end local tMsgData = InnerMsg.wl.WL_COMMERCE_ACTOPEN tMsgData.nOpen = tServerOpenDay[nFirstServerID] >= SERVERCOMMERCEOPENDAY and 1 or 0 tMsgData.nOperate = msg.nOperate InnerMsg.sendMsg(nSrcFD, tMsgData) end function CommerceMiddle_SendOpenAct(fd, msg) CommerceManger.CommerceAct_ActCheckOpen(msg.nOpen, msg.nOperate) end ------------------ 活动管理器操作 ------------------------ -- 请求活动是否开启 function CommerceMiddle_IsActOpen(nOperate) local tMsgData = InnerMsg.lw.LW_COMMERCE_ACTOPEN tMsgData.nSrcServerID = Config.SVR_INDEX tMsgData.nOperate = nOperate InnerMsg.sendMsg(0, tMsgData) end