From e5bcadc1d3b9e76fdf5a9741d50c30c4535c2372 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 22 四月 2019 15:59:54 +0800
Subject: [PATCH] 6459 【后端】【2.0】缥缈仙域开发单(退出跨服副本,未拾取的物品发送邮件)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py                         |    4 ++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py          |    8 ++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py                     |    1 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py                      |    3 ++-
 ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py                                          |    1 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py |   11 ++++++++++-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py            |   23 ++++++++++++++++++++---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py                            |    9 +++++++++
 8 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
index 9aa5544..941b762 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
@@ -20,6 +20,7 @@
 import PlayerControl
 import IPY_GameServer
 import CrossRealmPlayer
+import PlayerCompensation
 import GameWorldBoss
 import CrossRealmPK
 import PlayerQuery
@@ -270,6 +271,9 @@
         elif msgType == ShareDefine.CrossServerMsg_EnterFBRet:
             PlayerFB.CrossServerMsg_EnterFBRet(msgData, tick)
             
+        elif msgType == ShareDefine.CrossServerMsg_SendMail:
+            PlayerCompensation.CrossServerMsg_SendMail(msgData)
+            
         # 需要发送到地图服务器处理的
         elif msgType in [ShareDefine.CrossServerMsg_RebornRet, ShareDefine.CrossServerMsg_CollectNPCOK, ShareDefine.CrossServerMsg_FBEnd,
                          ShareDefine.CrossServerMsg_NPCAttackCount]:
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
index e52e73f..9eb8675 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
@@ -130,6 +130,15 @@
     content = "<MailTemplate>%s</MailTemplate>%s" % (mailTypeKey, json.dumps(paramList, ensure_ascii=False))
     return SendPersonalItemMailEx(title, content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
 
+def CrossServerMsg_SendMail(msgData):
+    ## 收到跨服服务器同步的发送邮件
+    mailTypeKey = msgData["MailTypeKey"]
+    playerIDList = msgData["Player"]
+    addItemList = msgData.get("Item", [])
+    paramList = msgData.get("Param", [])
+    SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList)
+    return
+
 #  此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
 ## 功能发放物品补偿/奖励邮件
 #  @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
index e51cd45..321083b 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
@@ -1216,6 +1216,7 @@
 CrossServerMsg_EnterFBRet = "EnterFBRet"                # 请求进入跨服副本返回信息
 CrossServerMsg_FBEnd = "FBEnd"                          # 完成跨服副本
 CrossServerMsg_NPCAttackCount = "NPCAttackCount"        # 攻击NPC次数记录
+CrossServerMsg_SendMail = "SendMail"                    # 发送邮件
 
 # 子服发送跨服信息定义
 ClientServerMsg_ServerInitOK = "ServerInitOK"           # 子服启动成功
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
index e2a5eeb..ee6d852 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
@@ -22,6 +22,7 @@
 import PlayerSuccess
 import ReadChConfig
 import ShareDefine
+import PyGameData
 import FBCommon
 import GameMap
 import GameObj
@@ -501,6 +502,13 @@
             GameWorld.Log("玩家进入跨服副本动态分配的线路: fbZoneID=%s,playerZoneID=%s,fbFuncLineID=%s,playerFuncLineID=%s" 
                           % (fbZoneID, playerZoneID, fbFuncLineID, playerFuncLineID), curPlayerID)
             
+        gameWorld = GameWorld.GetGameWorld()
+        copyMapID = gameWorld.GetCopyMapID()
+        if copyMapID not in PyGameData.g_crossPlayerServerGroupIDInfo:
+            PyGameData.g_crossPlayerServerGroupIDInfo[copyMapID] = {}
+        playerServerGroupIDDict = PyGameData.g_crossPlayerServerGroupIDInfo[copyMapID]
+        playerServerGroupIDDict[curPlayerID] = PlayerControl.GetPlayerServerGroupID(curPlayer)
+        
     # 自伸缩副本根据玩家进入开启,主动调用一次,避免间隔调用时机未触发导致逻辑错乱
     GameWorldProcess.EnterOpenFB(tick)
     
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
index 8a104c0..7731ca7 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
@@ -44,6 +44,7 @@
 import EventShell
 import FBLogic
 import FBCommon
+import ShareDefine
 import EventReport
 import ItemCommon
 import PyGameData
@@ -98,6 +99,7 @@
     gameFBMgr.SetIsSafeClose(0)
     
     lineID = gameWorld.GetLineID()
+    copyMapID = gameWorld.GetCopyMapID()
     GameWorld.Log("FB Close! lineID = %s, openState = %s"%(lineID, gameWorld.GetOpenState()))
     
     gameWorld.SetOpenState(IPY_GameWorld.fbosClosed)
@@ -154,9 +156,15 @@
         
     #发送未拾取的物品给玩家
     if mapID in ChConfig.Def_SendUnPickItemMailMapIDList and unPickItemDict:
+        isCrossServer = GameWorld.IsCrossServer()
+        playerServerGroupIDDict = PyGameData.g_crossPlayerServerGroupIDInfo.get(copyMapID, {})
         for ownerID, mailItemList in unPickItemDict.items():
             GameWorld.Log("发送未拾取的物品给玩家: %s" % mailItemList, ownerID)
-            PlayerControl.SendMailByKey("ItemNoPickUp", [ownerID], mailItemList, [gameWorld.GetMapID()])
+            if isCrossServer:
+                serverGroupID = playerServerGroupIDDict.get(ownerID, 0)
+                PlayerControl.SendCrossMail(serverGroupID, "ItemNoPickUp", [ownerID], mailItemList, [gameWorld.GetMapID()])
+            else:
+                PlayerControl.SendMailByKey("ItemNoPickUp", [ownerID], mailItemList, [gameWorld.GetMapID()])
         
     playerManager = gameWorld.GetMapCopyPlayerManager()
     
@@ -174,6 +182,7 @@
         GameServer_DynamicLineMapStateChange(gameWorld, IPY_GameWorld.fbosClosed)
         
     gameWorld.SetPropertyID(0)
+    PyGameData.g_crossPlayerServerGroupIDInfo.pop(copyMapID, None)
     return
 
 def GameServer_DynamicLineMapStateChange(gameWorld, state):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index e1a2d29..edf4546 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -352,6 +352,18 @@
     SendMail("", content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
     return
 
+def SendCrossMail(serverGroupID, mailTypeKey, playerIDList, addItemList, paramList=[]):
+    ## 发送跨服邮件
+    if not serverGroupID:
+        return
+    dataMsg = {"MailTypeKey":mailTypeKey, "Player":playerIDList}
+    if addItemList:
+        dataMsg["Item"] = CombineMailItem(addItemList)
+    if paramList:
+        dataMsg["Param"] = paramList
+    GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_SendMail, dataMsg, [serverGroupID])
+    return
+
 ## 功能发放物品补偿/奖励邮件
 #  @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
 #  @return
@@ -370,6 +382,13 @@
     if GameWorld.IsCrossServer():
         return
     
+    combineItemList = CombineMailItem(addItemList)
+    cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver, detail, moneySource]
+    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMail", '%s' % (cmdList), len(str(cmdList)))
+    return True
+
+def CombineMailItem(addItemList):
+    ## 合并邮件物品
     itemCountDict = {}
     combineItemList = [] # 合并后的物品列表
     for mailItem in addItemList:
@@ -399,9 +418,7 @@
     for key, itemCnt in itemCountDict.items():
         itemID, isAuctionItem = key
         combineItemList.append((itemID, itemCnt, isAuctionItem))
-    cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver, detail, moneySource]
-    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMail", '%s' % (cmdList), len(str(cmdList)))
-    return True
+    return combineItemList
 
 ## 构建系统提示参数列表
 #  @param msgParamList 信息参数列表
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
index ee13c09..9d9fbee 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
@@ -103,4 +103,5 @@
 g_customFBPrizeInfo = {} #自定义副本奖励 {playerID:[mapID, funcLineID, [奖励物品列表], ...}
 
 g_crossFuncLineDataCache = {} # 动态分配的跨服虚拟分线数据缓存 {(mapID, copyMapID):funcLineDataCache, ...}
-g_fbBuyBuffTimeDict = {} # 副本购买buff时间缓存{playerID:{moneyCnt:time}}
\ No newline at end of file
+g_crossPlayerServerGroupIDInfo = {} #跨服玩家服务器组ID缓存,副本线路关闭时才释放,所以支持离线跨服玩家 {copyMapID:{playerID:serverGroupID, ...}, ...}
+g_fbBuyBuffTimeDict = {} # 副本购买buff时间缓存{playerID:{moneyCnt:time}}
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
index e51cd45..321083b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
@@ -1216,6 +1216,7 @@
 CrossServerMsg_EnterFBRet = "EnterFBRet"                # 请求进入跨服副本返回信息
 CrossServerMsg_FBEnd = "FBEnd"                          # 完成跨服副本
 CrossServerMsg_NPCAttackCount = "NPCAttackCount"        # 攻击NPC次数记录
+CrossServerMsg_SendMail = "SendMail"                    # 发送邮件
 
 # 子服发送跨服信息定义
 ClientServerMsg_ServerInitOK = "ServerInitOK"           # 子服启动成功

--
Gitblit v1.8.0