MiddleCommonLogic.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --------------------------------
  2. -- 文件名 : MiddleCommonLogic
  3. -- 文件说明 : 跨服相关-通用管理(用于处理比较杂项的数据)
  4. -- 创建时间 : 2025/02/26
  5. -- 创建人 : FC
  6. --------------------------------
  7. local Config = require("Config")
  8. local Log = require("common.Log")
  9. local CommonDB = require("common.CommonDB")
  10. local InnerMsg = require("core.InnerMsg")
  11. local RoleLogic = require("role.RoleLogic")
  12. local Msg = require("core.Msg")
  13. local ObjHuman = require("core.ObjHuman")
  14. local function MiddleCommonLogic_WRITELOG(szText)
  15. Log.write(Log.LOGID_OSS_COMMON, "跨服通用管理"..szText)
  16. end
  17. -- 跨服获取玩家信息(源->中心服)
  18. function MiddleCommonLogic_GetChatPlayInfo_LW(human, msg)
  19. local tMsgData = InnerMsg.lw.LW_CHAT_PLAYER_INFO
  20. tMsgData.nSrcUID = human.db._id
  21. tMsgData.nDesUID = msg.uuid
  22. tMsgData.nSrcServerID = Config.SVR_INDEX
  23. tMsgData.nDesServerID = msg.nServerIndex
  24. print("[MiddleCommonLogic_GetChatPlayInfo_LW] ", tMsgData.nSrcUID, tMsgData.nDesUID, tMsgData.nSrcServerID, tMsgData.nDesServerID)
  25. InnerMsg.sendMsg(0, tMsgData)
  26. end
  27. -- 跨服获取玩家信息(中心服->目标)
  28. function MiddleCommonLogic_GetChatPlayInfo_WL(fd, msg)
  29. local msgRet = Msg.gc.GC_CHAT_PLAYER_INFO
  30. if not RoleLogic.makePlayInfo(msgRet.data, msg.nDesUID) then
  31. MiddleCommonLogic_WRITELOG("跨服获取玩家数据失败 nDesUID = "..msg.nDesUID.." nSrcUID = "..msg.nSrcUID.." nSrcServerID = "..msg.nSrcServerID)
  32. return
  33. end
  34. -- 获取数据发回中心服
  35. local tMsgData = InnerMsg.lw.LW_CHAT_PLAYER_INFO_SEND
  36. tMsgData.nSrcUID = msg.nSrcUID
  37. tMsgData.nSrcServerID = msg.nSrcServerID
  38. tMsgData.tData = msgRet
  39. InnerMsg.sendMsg(0, tMsgData)
  40. print("[MiddleCommonLogic_GetChatPlayInfo_WL] 跨服获取玩家信息(中心服->目标)")
  41. end
  42. -- 获取到数据发送给请求的玩家
  43. function MiddleCommonLogic_SendChatPlayInfo_WL(fd, msg)
  44. local nSrcUID = msg.nSrcUID
  45. local human = ObjHuman.onlineUuid[nSrcUID]
  46. if not human then
  47. print("[MiddleCommonLogic_SendChatPlayInfo_WL] 玩家不在线直接返回")
  48. return
  49. end
  50. local msgRet = Msg.gc.GC_CHAT_PLAYER_INFO
  51. msgRet.data = msg.tData.data
  52. Msg.send(msgRet, human.fd)
  53. print("[MiddleCommonLogic_SendChatPlayInfo_WL] 获取到数据发送给请求的玩家")
  54. end