BaiZhanChengShenCS.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. -- 百战成神(跨服 CS)
  2. --
  3. -- 职责:
  4. -- 1) 活动周期: Timer.oneMin/onHour -> timedStageHandle 开/关轮、发奖
  5. -- 2) 玩家数据: 积分、排行、匹配、REGISTER/UPDATE_SHOW
  6. -- 3) 协议: 处理普通服 LW_* , 回 WL_* 到对应 logic fd
  7. -- 4) 断连补偿: 逻辑服 LW_HELLO -> onLogicServerConnect 补 ACT_START/待发奖
  8. --
  9. -- 对外导出:
  10. -- oneMin, onHour, onLogicServerConnect, syncActStateToAllConnected
  11. -- N2C_* (InnerHandler 注册)
  12. local InnerMsg = require("core.InnerMsg")
  13. local Util = require("common.Util")
  14. local Timer = require("core.Timer")
  15. local MiddleManager = require("middle.MiddleManager")
  16. local BaiZhanChengShenDB = require("baiZhanChengShen.BaiZhanChengShenDB")
  17. local BaiZhanChengShenDefine = require("baiZhanChengShen.BaiZhanChengShenDefine")
  18. local BzcsLog = require("baiZhanChengShen.BaiZhanChengShenLog")
  19. ------------------------------------ 活动周期调度 ------------------------------------
  20. local wDay
  21. -- 刷新缓存的当前星期
  22. local function updateWDay()
  23. wDay = Util.getWeekDay()
  24. end
  25. -- 今日 0 点时间戳
  26. local function getTodayStartTime()
  27. return Util.getDayStartTime(os.time())
  28. end
  29. -- 将 baseTime 对齐到所在周开放首日 0:10 (getWeekDay: 1=周日, 7=周六)
  30. local function alignRoundStart(baseTime)
  31. local startW = BaiZhanChengShenDefine.BZCS_OPEN_WDAY_AREA[1]
  32. local endW = BaiZhanChengShenDefine.BZCS_OPEN_WDAY_AREA[2]
  33. local w = Util.getWeekDay(baseTime)
  34. local sub
  35. if startW <= endW then
  36. if w >= startW and w <= endW then
  37. sub = w - startW
  38. elseif w < startW then
  39. sub = w + 7 - startW
  40. else
  41. sub = w - startW
  42. end
  43. elseif w >= startW then
  44. sub = w - startW
  45. else
  46. sub = w + 7 - startW
  47. end
  48. local dayStart = Util.getDayStartTime(baseTime)
  49. return dayStart - sub * 86400 + BaiZhanChengShenDefine.BZCS_START_SEC
  50. end
  51. -- 由开局时间推算结束日(周日) 23:00 时间戳
  52. local function calcRoundEnd(startTime)
  53. local openStart = alignRoundStart(startTime)
  54. local endDayOffset = BaiZhanChengShenDefine.GetOpenEndDayOffset()
  55. local endDayStart = Util.getDayStartTime(openStart) + endDayOffset * 86400
  56. return endDayStart + BaiZhanChengShenDefine.BZCS_END_SEC
  57. end
  58. -- 当前是否在周六~周日开放日
  59. local function isInOpenWday()
  60. if not wDay then updateWDay() end
  61. local startW = BaiZhanChengShenDefine.BZCS_OPEN_WDAY_AREA[1]
  62. local endW = BaiZhanChengShenDefine.BZCS_OPEN_WDAY_AREA[2]
  63. if startW <= endW then
  64. return wDay >= startW and wDay <= endW
  65. end
  66. return wDay >= startW or wDay <= endW
  67. end
  68. -- 活动是否在时间窗内且处于开放星期
  69. local function isRunning()
  70. local now = os.time()
  71. local startTime, endTime = BaiZhanChengShenDB.GetActivityTimes()
  72. if startTime == 0 or endTime == 0 then
  73. return false
  74. end
  75. if now < startTime or now > endTime then
  76. return false
  77. end
  78. return isInOpenWday()
  79. end
  80. -- 向单个逻辑服 fd 推送当前活动状态(重连/跨服重启后补偿, 避免错过广播)
  81. local function sendActStateToFd(fd)
  82. if not fd then return end
  83. local startTime, endTime = BaiZhanChengShenDB.GetActivityTimes()
  84. if startTime > 0 and endTime > 0 and isRunning() then
  85. local msgData = InnerMsg.wl.WL_BZCS_ACT_START
  86. msgData.startTime = startTime
  87. msgData.endTime = endTime
  88. InnerMsg.sendMsg(fd, msgData)
  89. else
  90. local msgData = InnerMsg.wl.WL_BZCS_ACT_END
  91. InnerMsg.sendMsg(fd, msgData)
  92. end
  93. end
  94. -- 逻辑服连上跨服时: 同步活动状态 + 补发断连期间缓存的周期奖励
  95. function onLogicServerConnect(fd)
  96. if _G.is_middle ~= true or not fd then return end
  97. sendActStateToFd(fd)
  98. local serverId = FD_2_SVRINDEX and FD_2_SVRINDEX[fd]
  99. if not serverId then return end
  100. local pending = BaiZhanChengShenDB.TakePendingRewards(serverId)
  101. if #pending > 0 then
  102. local msgData = InnerMsg.wl.WL_BZCS_ISSUE_REWARD
  103. msgData.rewardList = pending
  104. InnerMsg.sendMsg(fd, msgData)
  105. BzcsLog.logAction("reward_reissue", string.format("serverId=%s cnt=%s", serverId, #pending))
  106. end
  107. end
  108. -- 跨服启动后向已连接逻辑服同步活动状态
  109. function syncActStateToAllConnected()
  110. if _G.is_middle ~= true then return end
  111. local fdList = MiddleManager.MiddleManager_GetAllFD()
  112. for _, fd in pairs(fdList) do
  113. sendActStateToFd(fd)
  114. end
  115. end
  116. -- 广播活动开启, 普通服写入 KEY_BZCS_START_TIME
  117. function ActOpen(startTime)
  118. local msgData = InnerMsg.wl.WL_BZCS_ACT_START
  119. msgData.startTime = startTime or os.time()
  120. local _, endTime = BaiZhanChengShenDB.GetActivityTimes()
  121. msgData.endTime = endTime
  122. local fdList = MiddleManager.MiddleManager_GetAllFD()
  123. for _, fd in pairs(fdList) do
  124. InnerMsg.sendMsg(fd, msgData)
  125. end
  126. end
  127. -- 广播活动结束
  128. function ActEnd()
  129. local msgData = InnerMsg.wl.WL_BZCS_ACT_END
  130. local fdList = MiddleManager.MiddleManager_GetAllFD()
  131. for _, fd in pairs(fdList) do
  132. InnerMsg.sendMsg(fd, msgData)
  133. end
  134. end
  135. -- 按 serverId 汇总待发奖 {{uuid,rank},...}
  136. local function groupRewardsByServer(playerList)
  137. local byServer = {}
  138. for _, info in ipairs(playerList) do
  139. local uuid, rank, serverId = info[1], info[2], info[3]
  140. if serverId then
  141. local list = byServer[serverId]
  142. if not list then
  143. list = {}
  144. byServer[serverId] = list
  145. end
  146. list[#list + 1] = {uuid, rank}
  147. end
  148. end
  149. return byServer
  150. end
  151. -- 向指定逻辑服批量下发排名奖励(每服一次 WL); 未连接则整批入 pending
  152. local function issueRewardBatch(serverId, rewardList)
  153. if not rewardList or #rewardList == 0 then return end
  154. local fd = MiddleManager.getFDBySvrIndex(serverId)
  155. if fd then
  156. local msgData = InnerMsg.wl.WL_BZCS_ISSUE_REWARD
  157. msgData.rewardList = rewardList
  158. InnerMsg.sendMsg(fd, msgData)
  159. else
  160. BaiZhanChengShenDB.AddPendingRewards(serverId, rewardList)
  161. end
  162. end
  163. -- 末批发奖完成后标记 rewardIssued(1=最后一服)
  164. local function issueRewardBatchFinish(serverId, rewardList, markIssued)
  165. issueRewardBatch(serverId, rewardList)
  166. if markIssued == 1 then
  167. BaiZhanChengShenDB.SetRewardIssued(true)
  168. end
  169. end
  170. -- 活动结束发奖: 按逻辑服批量 WL_BZCS_ISSUE_REWARD(服与服之间 2s 节流)
  171. function IssueRewardManager()
  172. if BaiZhanChengShenDB.IsRewardIssued() then
  173. return
  174. end
  175. local rewardPlayers = BaiZhanChengShenDB.GetAllPlayersForReward()
  176. local byServer = groupRewardsByServer(rewardPlayers)
  177. local serverList = {}
  178. for serverId, rewardList in pairs(byServer) do
  179. serverList[#serverList + 1] = {serverId, rewardList}
  180. end
  181. if #serverList == 0 then
  182. BaiZhanChengShenDB.SetRewardIssued(true)
  183. return
  184. end
  185. BzcsLog.logAction("reward_issue", string.format("playerCnt=%s serverCnt=%s", #rewardPlayers, #serverList))
  186. local delay = 0
  187. for i, entry in ipairs(serverList) do
  188. delay = delay + 2
  189. local markIssued = (i == #serverList) and 1 or 0
  190. Timer.addLater(delay, issueRewardBatchFinish, entry[1], entry[2], markIssued)
  191. end
  192. end
  193. -- 开启新周期: 重置 DB 并 ActOpen
  194. local function newRoundHandle(now)
  195. now = now or os.time()
  196. local startTime = alignRoundStart(now)
  197. local endTime = calcRoundEnd(startTime)
  198. BaiZhanChengShenDB.ResetForNewRound(startTime, endTime)
  199. ActOpen(startTime)
  200. BzcsLog.logAction("act_open", string.format("start=%s end=%s", startTime, endTime))
  201. end
  202. -- 结束当前周期: 发奖 + ActEnd
  203. local function endRoundHandle()
  204. if BaiZhanChengShenDB.IsRewardIssued() then
  205. return
  206. end
  207. BzcsLog.logAction("act_end", "begin_issue_reward")
  208. IssueRewardManager()
  209. ActEnd()
  210. end
  211. -- 放弃上轮未完成的周期发奖(满21天开新轮时不再补发)
  212. local function abandonUnissuedRewards()
  213. if BaiZhanChengShenDB.IsRewardIssued() then
  214. return
  215. end
  216. BzcsLog.logAction("reward_abandon", "new_round_skip")
  217. BaiZhanChengShenDB.SetRewardIssued(true)
  218. BaiZhanChengShenDB.ClearAllPendingRewards()
  219. ActEnd()
  220. end
  221. -- 是否应开启新轮(首次开轮 / 满21天开放日); 成功则已执行 newRoundHandle
  222. local function tryOpenNewRound(now, lastReset, startTime, endTime)
  223. if not isInOpenWday() then
  224. return false
  225. end
  226. if lastReset == 0 then
  227. newRoundHandle(now)
  228. return true
  229. end
  230. if Util.diffDay(lastReset) < BaiZhanChengShenDefine.BZCS_CYCLE_DAYS then
  231. return false
  232. end
  233. if startTime > 0 and now < endTime then
  234. return false
  235. end
  236. if not BaiZhanChengShenDB.IsRewardIssued() then
  237. abandonUnissuedRewards()
  238. end
  239. newRoundHandle(now)
  240. return true
  241. end
  242. -- 周期阶段机 (oneMin/onHour 调用):
  243. -- 1) 满足新轮条件(含满21天且上轮未发奖则放弃发奖直接开轮) -> newRoundHandle
  244. -- 2) 已过 endTime 且未发奖且未满21天新轮 -> endRoundHandle
  245. -- 3) 活动记录中但 isRunning 为假(如跨天) -> 修正时间并 ActOpen
  246. local function timedStageHandle()
  247. local now = os.time()
  248. local lastReset = BaiZhanChengShenDB.GetLastResetTime()
  249. local startTime, endTime = BaiZhanChengShenDB.GetActivityTimes()
  250. if tryOpenNewRound(now, lastReset, startTime, endTime) then
  251. return
  252. end
  253. if startTime > 0 and now >= endTime and not BaiZhanChengShenDB.IsRewardIssued() then
  254. endRoundHandle()
  255. return
  256. end
  257. if startTime > 0 and now >= startTime and now < endTime and not isRunning() then
  258. if isInOpenWday() then
  259. local ts = alignRoundStart(now)
  260. local te = calcRoundEnd(ts)
  261. BaiZhanChengShenDB.SetActivityTimes(ts, te)
  262. ActOpen(ts)
  263. end
  264. end
  265. end
  266. -- Timer 每分钟(跳过整点)检查阶段
  267. function oneMin()
  268. if _G.is_middle ~= true then return end
  269. if Util.getMin() == 0 then return end
  270. timedStageHandle()
  271. end
  272. -- Timer 每小时检查阶段, 0 点刷新星期
  273. function onHour(hour)
  274. if _G.is_middle ~= true then return end
  275. if hour == 0 or not wDay then
  276. updateWDay()
  277. end
  278. timedStageHandle()
  279. end
  280. ------------------------------------ N2C (普通服 LW -> 本模块 -> WL 回包) ------------------------------------
  281. -- msg 中带 sourceServerId/playerUuid, 通过 MiddleManager.getFDBySvrIndex 回包
  282. -- 向逻辑服 fd 发送 WL 协议
  283. local function sendWL(fd, msgData)
  284. if not fd then return false end
  285. InnerMsg.sendMsg(fd, msgData)
  286. return true
  287. end
  288. -- 业务失败时回 WL_BZCS_TIPS
  289. local function errTips(sourceServerId, playerUuid, errCode)
  290. BzcsLog.logAction("err_tips", string.format("serverId=%s uuid=%s err=%s", sourceServerId or 0, playerUuid or "", errCode or 0))
  291. local msgData = InnerMsg.wl.WL_BZCS_TIPS
  292. msgData.playerUuid = playerUuid
  293. msgData.errCode = errCode
  294. local fd = MiddleManager.getFDBySvrIndex(sourceServerId)
  295. if not fd then return end
  296. sendWL(fd, msgData)
  297. end
  298. -- LW_BZCS_MATCH -> WL_BZCS_MATCH (±100 步进匹配最多3人; refreshRanks 非空时仅刷新展示)
  299. function N2C_Match(msg)
  300. local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
  301. if not isRunning() then
  302. return errTips(msg.sourceServerId, msg.playerUuid, BaiZhanChengShenDefine.BZCS_ERR_NOT_OPEN)
  303. end
  304. local pinfo = BaiZhanChengShenDB.GetPlayer(msg.playerUuid)
  305. local myScore = pinfo and pinfo.score or BaiZhanChengShenDefine.BZCS_INIT_SCORE
  306. local refreshRanks = msg.refreshRanks
  307. local opponents
  308. if refreshRanks and #refreshRanks > 0 then
  309. opponents = BaiZhanChengShenDB.GetMatchOpponentsByRanks(refreshRanks)
  310. if #opponents < #refreshRanks then
  311. opponents = BaiZhanChengShenDB.GetMatchOpponents(msg.playerUuid, myScore, {})
  312. end
  313. else
  314. opponents = BaiZhanChengShenDB.GetMatchOpponents(msg.playerUuid, myScore, {})
  315. end
  316. local msgData = InnerMsg.wl.WL_BZCS_MATCH
  317. msgData.playerUuid = msg.playerUuid
  318. msgData.myScore = myScore
  319. msgData.myRank = BaiZhanChengShenDB.GetRankByUuid(msg.playerUuid)
  320. msgData.opponentList = opponents
  321. sendWL(fd, msgData)
  322. end
  323. -- LW_BZCS_RANK_LIST -> WL_BZCS_RANK_LIST
  324. function N2C_RankList(msg)
  325. local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
  326. local msgData = InnerMsg.wl.WL_BZCS_RANK_LIST
  327. msgData.playerUuid = msg.playerUuid
  328. msgData.rankList = BaiZhanChengShenDB.GetRankList(BaiZhanChengShenDefine.BZCS_RANK_MAX)
  329. msgData.myRankInfo = BaiZhanChengShenDB.BuildPlayerRankInfo(msg.playerUuid)
  330. sendWL(fd, msgData)
  331. end
  332. -- LW_BZCS_OPPONENT_INFO -> WL_BZCS_OPPONENT_INFO
  333. function N2C_OpponentInfo(msg)
  334. local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
  335. local target = BaiZhanChengShenDB.GetPlayerByRank(msg.targetRank)
  336. local msgData = InnerMsg.wl.WL_BZCS_OPPONENT_INFO
  337. msgData.playerUuid = msg.playerUuid
  338. msgData.res = target and 0 or -1
  339. msgData.targetInfo = BaiZhanChengShenDB.BuildOpponentInfoSnapshot(target) or {}
  340. sendWL(fd, msgData)
  341. end
  342. -- LW_BZCS_OPPONENT_LINEUP -> WL_BZCS_OPPONENT_LINEUP (含机器人 showInfo)
  343. function N2C_OpponentLineup(msg)
  344. local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
  345. local target = BaiZhanChengShenDB.GetPlayerByRank(msg.targetRank)
  346. local msgData = InnerMsg.wl.WL_BZCS_OPPONENT_LINEUP
  347. msgData.playerUuid = msg.playerUuid
  348. msgData.targetRank = msg.targetRank
  349. msgData.showInfo = target and target.showInfo or {}
  350. msgData.isRobot = target and target.isRobot or 0
  351. sendWL(fd, msgData)
  352. end
  353. -- LW_BZCS_CAN_FIGHT -> WL_BZCS_CAN_FIGHT (按开战时全服名次锁定对手, 扣次在 NS C2N_CanFight)
  354. function N2C_CanFight(msg)
  355. local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
  356. if not isRunning() then
  357. return errTips(msg.sourceServerId, msg.playerUuid, BaiZhanChengShenDefine.BZCS_ERR_NOT_OPEN)
  358. end
  359. local targetRank = msg.targetRank
  360. if not targetRank or targetRank < 1 then
  361. return errTips(msg.sourceServerId, msg.playerUuid, BaiZhanChengShenDefine.BZCS_ERR_TARGET_INVALID)
  362. end
  363. local target = BaiZhanChengShenDB.GetPlayerByRank(targetRank)
  364. if not target then
  365. return errTips(msg.sourceServerId, msg.playerUuid, BaiZhanChengShenDefine.BZCS_ERR_TARGET_INVALID)
  366. end
  367. if target.uuid == msg.playerUuid then
  368. return errTips(msg.sourceServerId, msg.playerUuid, BaiZhanChengShenDefine.BZCS_ERR_TARGET_INVALID)
  369. end
  370. local msgData = InnerMsg.wl.WL_BZCS_CAN_FIGHT
  371. msgData.playerUuid = msg.playerUuid
  372. msgData.targetRank = targetRank
  373. msgData.defUuid = target.uuid
  374. msgData.defServerId = BaiZhanChengShenDefine.GetClientServerId(target)
  375. local si = target.showInfo or {}
  376. msgData.defName = si.name or ""
  377. msgData.defScore = target.score or BaiZhanChengShenDefine.BZCS_INIT_SCORE
  378. msgData.isRobot = target.isRobot or 0
  379. msgData.res = 0
  380. sendWL(fd, msgData)
  381. end
  382. -- LW_BZCS_REGISTER 首次挑战注册跨服玩家(保留已有积分/firstJoinTime)
  383. function N2C_Register(msg)
  384. local pinfo = msg.playerInfo
  385. if not pinfo or not pinfo.uuid then return end
  386. local old = BaiZhanChengShenDB.GetPlayer(pinfo.uuid)
  387. if old then
  388. pinfo.score = old.score
  389. pinfo.scoreTime = old.scoreTime
  390. if (old.firstJoinTime or 0) > 0 then
  391. pinfo.firstJoinTime = old.firstJoinTime
  392. end
  393. else
  394. pinfo.score = BaiZhanChengShenDefine.BZCS_INIT_SCORE
  395. pinfo.firstJoinTime = pinfo.firstJoinTime or os.time()
  396. pinfo.scoreTime = os.time()
  397. end
  398. pinfo.isRobot = 0
  399. BaiZhanChengShenDB.UpsertPlayer(pinfo.uuid, pinfo)
  400. BzcsLog.logAction("register", string.format("uuid=%s serverId=%s score=%s firstJoin=%s", pinfo.uuid, pinfo.serverId or 0, pinfo.score or 0, pinfo.firstJoinTime or 0))
  401. end
  402. -- LW_BZCS_UPDATE_SHOW 增量合并展示数据
  403. function N2C_UpdateShow(msg)
  404. local pinfo = BaiZhanChengShenDB.GetPlayer(msg.playerUuid)
  405. if not pinfo or not msg.showInfo then return end
  406. pinfo.showInfo = pinfo.showInfo or {}
  407. BaiZhanChengShenDefine.MergeShowInfo(pinfo.showInfo, msg.showInfo)
  408. BaiZhanChengShenDB.UpsertPlayer(msg.playerUuid, pinfo)
  409. BzcsLog.logAction("update_show", string.format("uuid=%s type=%s race=%s", msg.playerUuid, msg.updateType or 0, msg.race or 0))
  410. end
  411. -- LW_BZCS_FIGHT_END 整场结算: 攻守加减分, WL 通知攻方; 真人守方另发 WL_BZCS_DEF_NOTIFY
  412. function N2C_FightEnd(msg)
  413. local atkUuid = msg.atkUuid
  414. local defUuid = msg.defUuid
  415. local atkWin = msg.atkWin == 1
  416. local atkDelta = atkWin and BaiZhanChengShenDefine.BZCS_ATK_WIN_SCORE or BaiZhanChengShenDefine.BZCS_ATK_LOSE_SCORE
  417. local defDelta = atkWin and BaiZhanChengShenDefine.BZCS_DEF_LOSE_SCORE or BaiZhanChengShenDefine.BZCS_DEF_WIN_SCORE
  418. local atkScore = BaiZhanChengShenDB.UpdateScore(atkUuid, atkDelta)
  419. local defScore = BaiZhanChengShenDB.UpdateScore(defUuid, defDelta)
  420. BzcsLog.logAction("fight_end", string.format(
  421. "atk=%s def=%s atkWin=%s atkDelta=%s defDelta=%s atkScore=%s defScore=%s atkSvr=%s defSvr=%s",
  422. atkUuid or "", defUuid or "", msg.atkWin or 0, atkDelta, defDelta, atkScore or 0, defScore or 0,
  423. msg.atkServerId or 0, msg.defServerId or 0
  424. ))
  425. local atkFd = MiddleManager.getFDBySvrIndex(msg.atkServerId)
  426. local wlAtk = InnerMsg.wl.WL_BZCS_FIGHT_END
  427. wlAtk.playerUuid = atkUuid
  428. wlAtk.atkWin = msg.atkWin
  429. wlAtk.scoreChange = atkDelta
  430. wlAtk.myScore = atkScore
  431. wlAtk.defName = msg.defName
  432. wlAtk.defServerId = msg.defServerId
  433. wlAtk.raceResults = msg.raceResults
  434. if not sendWL(atkFd, wlAtk) then
  435. BzcsLog.logAction("fight_end_wl_fail", string.format("atk=%s atkSvr=%s", atkUuid or "", msg.atkServerId or 0))
  436. end
  437. local defInfo = BaiZhanChengShenDB.GetPlayer(defUuid)
  438. if defInfo and defInfo.isRobot ~= 1 and defInfo.serverId then
  439. local defFd = MiddleManager.getFDBySvrIndex(defInfo.serverId)
  440. if defFd then
  441. local wlDef = InnerMsg.wl.WL_BZCS_DEF_NOTIFY
  442. wlDef.playerUuid = defUuid
  443. wlDef.atkName = msg.atkName
  444. wlDef.atkServerId = msg.atkServerId
  445. wlDef.atkWin = msg.atkWin == 1 and 0 or 1
  446. wlDef.scoreChange = defDelta
  447. wlDef.myScore = defScore
  448. wlDef.raceResults = msg.raceResults
  449. sendWL(defFd, wlDef)
  450. end
  451. end
  452. end