From cf15819d21dce2b5772a40e9a79b30334e863fbf Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 15 十二月 2020 10:01:31 +0800
Subject: [PATCH] 4882 【BT】充值仙玉返利邮件多发(地图玩家的GetGameServerInitOK为True时才能发送邮件到GameServer);

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py |   66 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 1 deletions(-)

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 7dd2c75..1f70a34 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -333,6 +333,22 @@
     @param batchDetail: [记录邮件流向用, ...]
     @param moneySource: 货币来源
     '''
+    
+    copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
+    for i, playerIDList in enumerate(batchPlayerIDList):
+        for playerID in playerIDList[::-1]:
+            curPlayer = copyMapPlayerManager.FindPlayerByID(playerID)
+            if curPlayer and not curPlayer.GetGameServerInitOK():
+                bAddItemList = [batchAddItemList[i]] if len(batchAddItemList) > i else []
+                bParamList = [batchParamList[i]] if len(batchParamList) > i else []
+                bGold = [batchGold[i]] if len(batchGold) > i else []
+                bGoldPaper = [batchGoldPaper[i]] if len(batchGoldPaper) > i else []
+                bSilver = [batchSilver[i]] if len(batchSilver) > i else []
+                bDetail = [batchDetail[i]] if len(batchDetail) > i else []
+                AddUnLoginOKPlayerMailCache(playerID, "ByMailTemplate", [mailTypeKey, bAddItemList, bParamList, bGold, bGoldPaper, bSilver, bDetail, moneySource])
+                playerIDList.pop(playerIDList.index(playerID))
+                continue
+            
     msgInfo = str([mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver, batchDetail, moneySource])
     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMailBatch", msgInfo, len(msgInfo))
     GameWorld.Log("SendMailBatch %s, batchPlayerIDList=%s, batchAddItemList=%s, batchParamList=%s, batchGold=%s, batchGoldPaper=%s, batchSilver=%s" 
@@ -404,10 +420,57 @@
     if GameWorld.IsCrossServer():
         return
     
+    sendPlayerIDList = []
+    copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
+    for playerID in playerIDList:
+        curPlayer = copyMapPlayerManager.FindPlayerByID(playerID)
+        if curPlayer and not curPlayer.GetGameServerInitOK():
+            AddUnLoginOKPlayerMailCache(playerID, "ByMailContent", [title, content, getDays, addItemList, gold, goldPaper, silver, detail, moneySource])
+            continue
+        sendPlayerIDList.append(playerID)
+        
     combineItemList = CombineMailItem(addItemList)
-    cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver, detail, moneySource]
+    cmdList = [title, content, getDays, sendPlayerIDList, combineItemList, gold, goldPaper, silver, detail, moneySource]
     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMail", '%s' % (cmdList), len(str(cmdList)))
     return True
+
+def AddUnLoginOKPlayerMailCache(playerID, cacheType, mailInfo):
+    ''' 添加未登录成功的玩家个人邮件发送缓存
+    '''
+    if playerID not in PyGameData.g_unLoginOKPlayerMailInfo:
+        PyGameData.g_unLoginOKPlayerMailInfo[playerID] = []
+    mailList = PyGameData.g_unLoginOKPlayerMailInfo[playerID]
+    mailList.append([cacheType, mailInfo])
+    # curPlayer.GetGameServerInitOK()
+    GameWorld.Log("添加GetGameServerInitOK未登录成功的玩家个人邮件发送缓存! mailCount=%s, %s" % (len(mailList), str(PyGameData.g_unLoginOKPlayerMailInfo)), playerID)
+    return
+
+def ClearUnLoginOKPlayerMailCache(playerID):
+    ## 清除未登录成功的玩家个人邮件发送缓存
+    if playerID not in PyGameData.g_unLoginOKPlayerMailInfo:
+        return
+    PyGameData.g_unLoginOKPlayerMailInfo.pop(playerID)
+    GameWorld.Log("清除未登录成功的玩家个人邮件发送缓存!", playerID)
+    return
+
+def SendUnLoginOKPlayerMailCache(curPlayer):
+    ## 未登录成功的玩家个人邮件发送缓存  - 登录成功后处理
+    if not curPlayer.GetGameServerInitOK():
+        return
+    playerID = curPlayer.GetPlayerID()
+    if playerID not in PyGameData.g_unLoginOKPlayerMailInfo:
+        return
+    mailList = PyGameData.g_unLoginOKPlayerMailInfo.pop(playerID)
+    for cacheType, mailInfo in mailList:
+        playerIDList = [playerID]
+        GameWorld.Log("发送未登录成功时缓存的待发送邮件! cacheType=%s, mailInfo=%s" % (cacheType, str(mailInfo)), playerID)
+        if cacheType == "ByMailContent":
+            title, content, getDays, addItemList, gold, goldPaper, silver, detail, moneySource = mailInfo
+            SendMail(title, content, getDays, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
+        elif cacheType == "ByMailTemplate":
+            mailTypeKey, bAddItemList, bParamList, bGold, bGoldPaper, bSilver, bDetail, moneySource = mailInfo
+            SendMailBatch(mailTypeKey, [playerIDList], bAddItemList, bParamList, bGold, bGoldPaper, bSilver, bDetail, moneySource)
+    return
 
 def CombineMailItem(addItemList):
     ## 合并邮件物品
@@ -1263,6 +1326,7 @@
     PyGameData.g_playerEquipPartAttrDict.pop(playerID, None)
     PyGameData.g_equipChangeClassLVInfo.pop(playerID, None)
     NPCCommon.ClearPriWoodPile(curPlayer)
+    ClearUnLoginOKPlayerMailCache(playerID)
     return
 
 ##更新保存玩家在线时间

--
Gitblit v1.8.0