From 11a8ef04dc70453203e1f1ab7b0bceffd6a7774a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 05 七月 2024 16:35:12 +0800
Subject: [PATCH] 10198 【香港】【越南】【主干】【砍树】【后端】BOSS凭证优化(优化凭证转化: 活动开始后到参与结束都不转化,包含活动开始参与前;)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py | 163 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 126 insertions(+), 37 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
index 9709ed7..5d8626c 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -19,38 +19,47 @@
#---------------------------------------------------------------------
import GameWorld
+import GameWorship
import PlayerControl
import NetPackCommon
+import GameWorldArena
import ChPyNetSendPack
+import ChGameToMapPyPack
import PlayerFBHelpBattle
+import GameWorldSkyTower
+import CrossChampionship
+import CrossBattlefield
import PyGameDataStruct
import IpyGameDataPY
import PyDataManager
+import ShareDefine
import ChConfig
import json
+import time
-ViewCacheMgr = GameWorld.GameWorldData.GetPlayerViewCacheMgr()
-
-
-# 优先取缓存数据,后取可保存数据
-def GetItemData(curCache):
- result = curCache.GetItemDataNoSave()
- if not result:
- return curCache.GetItemData()
-
- return result
-
-def GetPlusData(curCache):
- result = curCache.GetPlusDataNoSave()
- if not result:
- return curCache.GetPlusData()
-
- return result
+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 GameWorldSkyTower.IsSkyTowerPassPlayer(playerID):
return True
SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1)
@@ -63,6 +72,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()
@@ -73,18 +94,48 @@
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 = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 3) * 3600 * 24
+
+ pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
+ playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
+ for playerID, viewCache in playerViewCachePyDict.items():
+
+ passTime = curTime - viewCache.OffTime
+ if passTime < MaxTime:
+ continue
+ if IsSaveAllViewCache(playerID):
+ continue
+ playerViewCachePyDict.pop(playerID)
+
+ return
def DeleteViewCache(playerID):
## 删除玩家缓存
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
@@ -93,8 +144,21 @@
elif isAddNew:
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 and curCache.PropData:
+ curCache.PropDataDict = eval(curCache.PropData)
+ return curCache.PropDataDict
#//04 01 地图同步玩家缓存数据到GameServer#tagMGUpdatePlayerCache
#
@@ -112,8 +176,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
@@ -134,12 +198,8 @@
return
curCache.LV = curPackData.PlayerLV
curCache.OffTime = curPackData.OffTime
- if isLogout:
- curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- if curPlayer:
- curCache.GeTuiID = curPlayer.GetGeTuiClientID()
- curCache.GeTuiIDSize = len(curCache.GeTuiID)
-
+
+ curCache.PropDataDict = {} # 每次更新数据时,重置字典缓存,下次获取时重新eval缓存
curCache.PropData = curPackData.PropData
curCache.PropDataSize = curPackData.PropDataSize
curCache.PlusData = curPackData.PlusData
@@ -149,7 +209,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 = ""
@@ -165,8 +225,7 @@
#GameWorld.DebugLog(" %s" % curCache.outputString())
# 同步更新助战信息
if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
- #PropDataDict = json.loads(curCache.PropData)
- PropDataDict = eval(curCache.PropData)
+ PropDataDict = GetCachePropDataDict(curCache)
fightPower = PropDataDict.get("FightPower", 0)
familyID = PropDataDict.get("FamilyID", 0)
playerName = PropDataDict.get("Name", "")
@@ -181,22 +240,46 @@
# DWORD PlayerID; //玩家ID
# DWORD FindPlayerID; //要查询的玩家ID
# BYTE EquipClassLV; //大于0为查看指定境界阶装备信息, 0为查看默认信息
+# BYTE CallMap; //是否需要通知地图
#};
def OnMGQueryPlayerCache(routeIndex, mapID, curPackData, tick):
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID)
findPlayerID = curPackData.FindPlayerID
equipClassLV = curPackData.EquipClassLV
+ callMap = curPackData.CallMap
curCache = FindViewCache(findPlayerID)
if not curCache:
PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine")
+ if callMap:
+ sendPack = ChGameToMapPyPack.tagGMPlayerCache()
+ sendPack.PlayerID = curPlayer.GetPlayerID()
+ sendPack.FindPlayerID = findPlayerID
+ sendPack.PropData = ""
+ sendPack.PropDataSize = len(sendPack.PropData)
+ sendPack.PlusData = ""
+ sendPack.PlusDataSize = len(sendPack.PlusData)
+ NetPackCommon.SendPyPackToMapServer(routeIndex, mapID, sendPack)
return
-
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV)
+ if callMap:
+ sendPack = ChGameToMapPyPack.tagGMPlayerCache()
+ sendPack.PlayerID = curPlayer.GetPlayerID()
+ sendPack.FindPlayerID = findPlayerID
+ sendPack.PropData = curCache.PropData
+ sendPack.PropDataSize = len(sendPack.PropData)
+ sendPack.PlusData = curCache.PlusData
+ sendPack.PlusDataSize = len(sendPack.PlusData)
+ NetPackCommon.SendPyPackToMapServer(routeIndex, mapID, sendPack)
+ return
+
+def Sync_PlayerCache(curPlayer, curCache, equipClassLV=0):
+ ## 同步玩家缓存
if equipClassLV:
itemData = ""
if hasattr(curCache, "ItemDataSize%s" % equipClassLV):
itemData = getattr(curCache, "ItemData%s" % equipClassLV)
sendPack = ChPyNetSendPack.tagSCPlayerEquipCacheResult()
- sendPack.PlayerID = findPlayerID
+ sendPack.PlayerID = curCache.PlayerID
sendPack.EquipClassLV = equipClassLV
sendPack.ItemData = itemData
sendPack.ItemDataSize = len(sendPack.ItemData)
@@ -205,13 +288,12 @@
#回包客户端
sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
- sendPack.PlayerID = findPlayerID
+ sendPack.PlayerID = curCache.PlayerID
sendPack.PropData = curCache.PropData
sendPack.PropDataSize = len(sendPack.PropData)
sendPack.PlusData = curCache.PlusData
sendPack.PlusDataSize = len(sendPack.PlusData)
NetPackCommon.SendFakePack(curPlayer, sendPack)
- #GameWorld.DebugLog('ViewCache### OnMGQueryPlayerCache out')
return
#===============================================================================
@@ -238,15 +320,21 @@
answerPack.RealmLV = 1
answerPack.OnlineType = ChConfig.Def_Offline
answerPack.ServerGroupID = 0
+ answerPack.Face = 0
else:
- cacheDict = eval(curCache.PropData)
+ cacheDict = GetCachePropDataDict(curCache)
answerPack.PlayerID = clientPack.PlayerID
answerPack.PlayerName = cacheDict["Name"]
answerPack.Job = cacheDict["Job"]
answerPack.LV = cacheDict["LV"]
answerPack.RealmLV = cacheDict["RealmLV"]
answerPack.OnlineType = ChConfig.Def_Offline
- answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
+ answerPack.Face = cacheDict.get("Face", 0)
+
+ if GameWorld.IsCrossServer():
+ answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
+ else:
+ answerPack.ServerGroupID = GameWorld.GetServerGroupID()
else:
answerPack.PlayerID = clientPack.PlayerID
answerPack.PlayerName = tagPlayer.GetName()
@@ -256,6 +344,7 @@
answerPack.OnlineType = ChConfig.Def_Online
answerPack.IsInTeam = tagPlayer.GetTeamID() > 0
answerPack.ServerGroupID = PlayerControl.GetPlayerServerGroupID(tagPlayer)
+ answerPack.Face = tagPlayer.GetFace()
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
NetPackCommon.SendFakePack(curPlayer, answerPack)
@@ -266,7 +355,7 @@
curCache = FindViewCache(playerID)
if not curCache:
return
- PropData = eval(curCache.PropData)
+ PropData = GetCachePropDataDict(curCache)
PropData["FamilyID"] = familyID
PropData["FamilyName"] = familyName
PropData = json.dumps(PropData, ensure_ascii=False).replace(" ", "")
--
Gitblit v1.8.0