From 01e46bb91dbc5023379dd2e10f2cb3532ca57ad0 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 02 九月 2024 10:35:33 +0800
Subject: [PATCH] 10256 【越南】【砍树】排行榜名次加入积分限制(修复特殊排名规则跨服榜单报错bug;)
---
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
index 6d5ea6f..5fb24a9 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
@@ -114,6 +114,7 @@
self.__crossServerDataVer = 0 # 主服榜单数据版本
self.__clientServerDataVer = 0 # 子服榜单数据版本
self.__billboardList = [] # [tagDBCrossBillboard, ...]
+ self.__idIndexDict = {} # {id:index, ...}
self.__idOrderDict = {} # {id:名次, ...}
self.__orderRuleList = None
self.__sortDelay = False # 是否需要延迟排序
@@ -130,6 +131,7 @@
self.SaveDRData("Clear")
self.__billboardList = [] # [tagDBCrossBillboard, ...]
self.__idOrderDict = {} # {id:名次, ...}
+ self.__idIndexDict = {}
self.UpdCrossServerDataVer(0)
return
@@ -139,6 +141,7 @@
% (self.__billboardType, self.__groupValue1, self.__groupValue2, len(self.__billboardList)))
self.__billboardList.sort(key=operator.attrgetter("CmpValue", "CmpValue2", "CmpValue3"), reverse=True)
self.__idOrderDict = {} # 排序后重置,下次查询时更新并缓存
+ self.__idIndexDict = {}
self.__sortDelay = False
self.UpdCrossServerDataVer()
return
@@ -172,22 +175,24 @@
@param findID: 查找的ID
@return: None or PyGameDataStruct.tagDBCrossBillboard()
'''
- idOrderDict = self.GetIDOrderDict()
- if findID not in idOrderDict:
+ self.GetIDOrderDict()
+ if findID not in self.__idIndexDict:
return None
- order = idOrderDict[findID]
- return self.__billboardList[order - 1]
+ idIndex = self.__idIndexDict[findID]
+ if idIndex >= len(self.__billboardList):
+ return None
+ return self.__billboardList[idIndex]
def IndexOfByID(self, findID):
''' 根据ID查询所在榜单索引
@param findID: 查找的ID
@return: -1 or >=0
'''
- idOrderDict = self.GetIDOrderDict()
- if findID not in idOrderDict:
+ self.GetIDOrderDict()
+ if findID not in self.__idIndexDict:
return -1
- order = idOrderDict[findID]
- return order - 1
+ idIndex = self.__idIndexDict[findID]
+ return idIndex
def SaveDRData(self, eventName="", addDataDict={}):
## 记录流向数据
@@ -224,7 +229,9 @@
def GetIDOrderDict(self):
## 获取ID对应名次字典
# @return: {ID:名次, ...} 名次从1开始
- if not self.__idOrderDict:
+ if not self.__idOrderDict or not self.__idIndexDict:
+ self.__idOrderDict = {}
+ self.__idIndexDict = {}
if self.__orderRuleList:
billboardDataCount = self.GetCount()
rankPre = 0
@@ -242,9 +249,12 @@
self.__idOrderDict[billboardData.ID] = orderReal
orderCountTotal -= 1
billboardIndex += 1
+ for order, billboardData in enumerate(self.__billboardList, 1):
+ self.__idIndexDict[billboardData.ID] = order - 1
else:
for order, billboardData in enumerate(self.__billboardList, 1):
self.__idOrderDict[billboardData.ID] = order
+ self.__idIndexDict[billboardData.ID] = order - 1
return self.__idOrderDict
def SetOrderRuleList(self, orderRuleList):
@@ -252,6 +262,7 @@
# @param orderRuleList: 排名所需值规则列表 [[order, needCmpValue], ...]
self.__orderRuleList = orderRuleList
self.__idOrderDict = {} # 设置后需重置,可能配置规则变化了导致实际排名可能变化
+ self.__idIndexDict = {}
GameWorld.Log("设置排名所需值规则列表: billboardType=%s,groupValue1=%s,groupValue2=%s, %s"
% (self.__billboardType, self.__groupValue1, self.__groupValue2, orderRuleList))
return
@@ -291,6 +302,7 @@
if syncBillboardList != None:
self.__billboardList = self.__billboardList[:len(syncBillboardList)] # 直接用本服以后的排行数据实例clear后覆盖更新,不足的创建新实例
self.__idOrderDict = {}
+ self.__idIndexDict = {}
for i, syncData in enumerate(syncBillboardList):
ID, ID2, Name1, Name2, Type2, Value1, Value2, CmpValue, CmpValue2, CmpValue3, Value3, Value4, Value5, Value6, Value7, Value8, UserData = syncData
if i < len(self.__billboardList):
@@ -323,6 +335,7 @@
billboardData.CmpValue3 = CmpValue3
self.__idOrderDict[ID] = i + 1
+ self.__idIndexDict[ID] = i
self.__clientServerDataVer = crossServerDataVer
--
Gitblit v1.8.0