From d9611fb2b7b4616e5d40746ecda265dfa1d9a0b9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 13 十二月 2021 16:00:24 +0800
Subject: [PATCH] 8901 【BT2】【后端】全服红包(报错防范)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py | 67 +++++++++++++++++++++++++++------
1 files changed, 55 insertions(+), 12 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
index 586d56e..25705b1 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
@@ -26,8 +26,11 @@
import NetPackCommon
import DataRecordPack
import PlayerFamily
+import PyDataManager
+import PlayerViewCache
import time
+import random
Def_Key_BillboardSortTick = "BillboardSortTick_%s" # 排行榜是否排序tick,参数(排行榜类型)
Def_Key_BillboardNeedSort = "BillboardNeedSort_%s" # 排行榜是否需要排序,参数(排行榜类型)
@@ -483,8 +486,6 @@
#GameWorld.DebugLog("更新排行榜:bType=%s,autoSort=%s,tick=%s,lastSortTick=%s,d=%s" % (bType, autoSort, tick, lastSortTick, tick - lastSortTick))
UpdatePlayerBillboard(bID, bName, bName2, bType, bType2, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
- gameWorld.SetDict(Def_Key_BillboardNeedSort % bType, 1)
- #__UpdateBillboardSortState(gameWorld, bType, autoSort, isUpd)
exInfo = billInfoDict["ExInfo"]
# 以下为榜单附加特殊处理
@@ -506,20 +507,61 @@
if job in ShareDefine.JobFightPowerBillboardDict:
jobBType = ShareDefine.JobFightPowerBillboardDict[job]
UpdatePlayerBillboard(bID, bName, bName2, jobBType, bType2, value1, value2, cmpValue, autoSort, cmpValue2)
- gameWorld.SetDict(Def_Key_BillboardNeedSort % jobBType, 1)
- #__UpdateBillboardSortState(gameWorld, jobBType, autoSort, isUpd)
return
-def __UpdateBillboardSortState(gameWorld, bType, autoSort, isUpd):
- key = Def_Key_BillboardNeedSort % bType
- needSort = gameWorld.GetDictByKey(key)
- if not autoSort and isUpd and not needSort:
- gameWorld.SetDict(key, 1)
- elif autoSort and needSort:
- gameWorld.SetDict(key, 0)
+def GetBillboardOperateInfo(curPlayer):
+ # 排行榜中所保存的运营商相关信息
+ platform = curPlayer.GetAccID()
+ if platform in ["tencent"]:
+ return curPlayer.GetOperateInfo()
+ return platform
+
+def UpdatePlayerBillboardEx(curPlayer, playerID, bType, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0, autoSort=False):
+ ## 更新玩家排行榜
+ # @param curPlayer: 可能为None
+
+ playerOpInfo = ""
+ playerJob = 0
+ playerName = ""
+ playerRealmLV = 0
+
+ if curPlayer:
+ playerID = curPlayer.GetID()
+ playerJob = curPlayer.GetJob()
+ playerName = curPlayer.GetName()
+ playerRealmLV = curPlayer.GetOfficialRank()
+ playerOpInfo = GetBillboardOperateInfo(curPlayer)
+ else:
+ socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID)
+ if socialPlayer:
+ playerJob = socialPlayer.playerInfo.Job
+ playerName = socialPlayer.playerInfo.PlayerName
+ playerRealmLV = socialPlayer.playerInfo.RealmLV
+ else:
+ curCache = PlayerViewCache.FindViewCache(playerID)
+ if curCache:
+ cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
+ playerJob = cacheDict["Job"]
+ playerName = cacheDict["Name"]
+ playerRealmLV = cacheDict["RealmLV"]
+
+ if not playerName and playerID < 10000:
+ playerJob = random.choice([1, 2])
+ playerName = "testName%s" % playerID
+ playerRealmLV = random.randint(1, 10)
- #GameWorld.DebugLog("__UpdateBillboardSortState:bType=%s,autoSort=%s,isUpd=%s,needSort=%s" % (bType, autoSort, isUpd, gameWorld.GetDictByKey(key)))
+ if bType in ShareDefine.BTValue1_OfficialRankList:
+ value1 = playerRealmLV
+
+ tick = GameWorld.GetGameWorld().GetTick()
+ gameWorld = GameWorld.GetGameWorld()
+ lastSortTick = gameWorld.GetDictByKey(Def_Key_BillboardSortTick % bType)
+ autoSort = ((tick - lastSortTick) >= 60000 or autoSort) # 1分钟强制排序一次
+ if autoSort:
+ gameWorld.SetDict(Def_Key_BillboardSortTick % bType, tick)
+
+ UpdatePlayerBillboard(playerID, playerName, playerOpInfo, bType, playerJob, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
return
#---------------------------------------------------------------------
@@ -604,6 +646,7 @@
% (billboardIndex, billboardType, value1, value2, cmpValue, cmpValue2, cmpValue3, isNewData), curPlayerID)
if not autoSort:
#不自动排序
+ GameWorld.GetGameWorld().SetDict(Def_Key_BillboardNeedSort % billboardIndex, 1) # 设置需要下次查看需要先排序
return True
#重新排序排行榜
--
Gitblit v1.8.0