From 71b4124bef7ec706c3d926adce5ed443f9d96e3e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 12 八月 2024 14:14:52 +0800
Subject: [PATCH] 10245 【越南】【砍树】【主干】【港台】古宝升星修改(支持额外扣除品质碎片数量)

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py |  147 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 137 insertions(+), 10 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
index b563069..3e85bec 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -19,25 +19,51 @@
 #---------------------------------------------------------------------
 
 import GameWorld
+import GameWorship
 import PlayerControl
 import NetPackCommon
+import GameWorldArena
 import ChPyNetSendPack
 import PlayerFBHelpBattle
+import GameWorldSkyTower
+import CrossChampionship
+import CrossBattlefield
+import CrossRealmPlayer
 import PyGameDataStruct
 import IpyGameDataPY
 import PyDataManager
+import ShareDefine
 import ChConfig
 
 import json
 import time
+import random
 
-def DoOnDay():
+def DoOnDayEx():
     DelOutofTimeViewCacheData()
     return
 
 def IsSaveDBViewCache(playerID, playerLV):
     ## 是否保存基本的缓存数据
     if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
+        return True
+    
+    if GameWorldArena.IsArenaBattlePlayer(playerID):
+        return True
+    
+    if CrossBattlefield.IsBattlefieldCallPlayer(playerID):
+        return True
+    
+    if CrossChampionship.IsChampionshipPlayer(playerID):
+        return True
+    
+    if GameWorship.IsWorshipPlayer(playerID):
+        return True
+    
+    if PyDataManager.GetDBPyFuncTeamManager().IsTeamPlayer(playerID):
+        return True
+    
+    if GameWorldSkyTower.IsSkyTowerPassPlayer(playerID):
         return True
     
     SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1)
@@ -50,6 +76,18 @@
 def IsSaveAllViewCache(playerID):
     ## 是否保存所有缓存数据
     
+    if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
+        return True
+    
+    if GameWorldArena.IsArenaBattlePlayer(playerID):
+        return True
+    
+    if CrossBattlefield.IsBattlefieldCallPlayer(playerID):
+        return True
+    
+    if CrossChampionship.IsChampionshipPlayer(playerID):
+        return True
+    
     NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
     #校验玩家是否上排行榜
     billboardMgr = GameWorld.GetBillboard()
@@ -60,13 +98,23 @@
         if curBillboard.FindByID(playerID):
             return True
         
+    #跨服榜单上的默认保留
+    if GameWorld.IsCrossServer():
+        billboardMgr = PyDataManager.GetCrossBillboardManager()
+        for billboardType in ShareDefine.CrossBillboardTypeList:
+            groupList = billboardMgr.GetBillboardGroupList(billboardType)
+            for billboardType, groupValue1, groupValue2 in groupList:
+                billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
+                if billboardObj.FindByID(playerID):
+                    return True
+                
     return False
 
 def DelOutofTimeViewCacheData():
     ## 删除过期的查看缓存数据
     
     curTime = int(time.time())
-    MaxTime = 30 * 3600 * 24 # 30天
+    MaxTime = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 3) * 3600 * 24
     
     pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
     playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
@@ -85,30 +133,105 @@
     ## 删除玩家缓存
     pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
     playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
-    playerViewCachePyDict.pop(playerID)
+    playerViewCachePyDict.pop(playerID, None)
     GameWorld.DebugLog("删除查看缓存!", playerID)
     return
 
-def FindViewCache(playerID, isAddNew=False):
+def FindViewCache(playerID, isAddNew=False, newPropData={}):
     ## 查找玩家缓存
+    # @param newPropData: 新数据初始PropData {}, key: LV,RealmLV,Job,VIPLV,Name,FamilyID,FamilyName,FightPower
     curCache = None
     pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
     playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
     if playerID in playerViewCachePyDict:
         curCache = playerViewCachePyDict[playerID]
-    elif isAddNew:
+    elif isAddNew or playerID < 10000:
+        # 内网测试假玩家
+        if playerID < 10000 and not newPropData:
+            openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1)
+            fakeName = "匿名玩家".decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
+            fakeName = "%s%s" % (fakeName, playerID)
+            serverID = random.randint(9900, 9950)
+            accID = "fake%s@test@s%s" % (playerID, serverID)
+            newPropData = {
+                           "AccID":accID, 
+                           "PlayerID":playerID, 
+                           "Name":fakeName, 
+                           "Job":random.choice(openJobList) if openJobList else 1, 
+                           "LV":random.randint(100, 200), 
+                           "RealmLV":random.randint(5, 15),
+                           "FightPower":random.randint(1000000, 100000000), 
+                           "ServerGroupID":serverID,
+                           }
         curCache = PyGameDataStruct.tagPlayerViewCachePy()
         curCache.PlayerID = playerID
+        if newPropData:
+            curCache.PropData = json.dumps(newPropData, ensure_ascii=False).replace(" ", "")
+            curCache.PropDataSize = len(curCache.PropData)
         playerViewCachePyDict[playerID] = curCache
     return curCache
 
 def GetCachePropDataDict(curCache):
     ## 获取缓存基础属性字典信息
+    if not curCache:
+        return {}
     if not hasattr(curCache, "PropDataDict"):
         curCache.PropDataDict = {}
-    if not curCache.PropDataDict:
+    if not curCache.PropDataDict and curCache.PropData:
         curCache.PropDataDict = eval(curCache.PropData)
     return curCache.PropDataDict
+
+def GetShotCahceDict(playerID, withEquip=False):
+    ## 获取玩家简短的缓存信息字典
+    cacheDict = GetCachePropDataDict(FindViewCache(playerID))
+    if not cacheDict:
+        return {}
+    shotCacheDict = {
+                     "PlayerID":playerID, 
+                     "Name":cacheDict["Name"], 
+                     "Job":cacheDict["Job"], 
+                     "LV":cacheDict["LV"], 
+                     "RealmLV":cacheDict["RealmLV"], 
+                     "FightPower":cacheDict["FightPower"],
+                     "ServerID":GameWorld.GetAccIDServerID(cacheDict["AccID"]),
+                     }
+    if withEquip:
+        shotCacheDict.update({
+                              "TitleID":cacheDict.get("TitleID", 0),
+                              "EquipShowSwitch":cacheDict.get("EquipShowSwitch", 0),
+                              "EquipShowID":cacheDict.get("EquipShowID", 0),
+                              })
+    return shotCacheDict
+
+def GetSyncCrossCacheBase(curPlayer):
+    ## 获取同步跨服基础查看缓存,主要用于个别功能需要提前先同步玩家基础缓存到跨服,因为跨服不一定有玩家缓存,需要提前同步
+    playerID = curPlayer.GetPlayerID()
+    cacheDict = GetCachePropDataDict(FindViewCache(playerID))
+    cacheBase = {
+                 "AccID":curPlayer.GetAccID(),
+                 "LV":curPlayer.GetLV(),
+                 "RealmLV":curPlayer.GetOfficialRank(),
+                 "Job":curPlayer.GetJob(),
+                 "VIPLV":curPlayer.GetVIPLv(),
+                 "Name":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
+                 "FamilyID":curPlayer.GetFamilyID(),
+                 "FamilyName":cacheDict.get("FamilyName", ""),
+                 "TitleID":cacheDict.get("TitleID", 0),
+                 "FightPower":PlayerControl.GetFightPower(curPlayer),
+                 "EquipShowSwitch":cacheDict.get("EquipShowSwitch", 0),
+                 "EquipShowID":cacheDict.get("EquipShowID", 0),
+                 "ServerGroupID":PlayerControl.GetPlayerServerGroupID(curPlayer),
+                 }
+    return cacheBase
+
+def UpdCrossCacheBase(playerID, cacheBase):
+    ## 更新同步跨服基础查看缓存
+    cacheDict = GetCachePropDataDict(FindViewCache(playerID, True))
+    if not cacheBase:
+        return cacheDict
+    for k, v in cacheBase.items():
+        cacheDict[k] = v
+    return cacheDict
 
 #//04 01 地图同步玩家缓存数据到GameServer#tagMGUpdatePlayerCache
 #
@@ -126,8 +249,8 @@
 #    WORD        ItemDataSize1;
 #    char        ItemData1[ItemDataSize1];    //1阶装备数据
 #    ...         ...
-#    WORD        ItemDataSize15;
-#    char        ItemData15[ItemDataSize15];
+#    WORD        ItemDataSize20;
+#    char        ItemData20[ItemDataSize20];
 #};
 def OnMGUpdatePlayerCache(routeIndex, mapID, curPackData, tick):
     playerID = curPackData.PlayerID
@@ -164,7 +287,7 @@
     #GameWorld.DebugLog("    更新Plus数据: size=%s, %s" % (curCache.PlusDataSize, curCache.PlusData), playerID)
     
     # 装备数据存储,不保存装备数据的话则清空
-    for classLV in xrange(1, 15 + 1):
+    for classLV in xrange(1, 20 + 1):
         if not isSaveAll:
             itemDataSize = 0
             itemData = ""
@@ -263,7 +386,11 @@
             answerPack.LV = cacheDict["LV"]
             answerPack.RealmLV = cacheDict["RealmLV"]
             answerPack.OnlineType = ChConfig.Def_Offline
-            answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
+            
+            if GameWorld.IsCrossServer():
+                answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
+            else:
+                answerPack.ServerGroupID = GameWorld.GetServerGroupID()
     else:
         answerPack.PlayerID = clientPack.PlayerID
         answerPack.PlayerName = tagPlayer.GetName()

--
Gitblit v1.8.0