From 11c9a3b5846401523e4dafc17f2a074a712730da Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 11 三月 2026 18:27:10 +0800
Subject: [PATCH] 526 【挑战】PVP群英榜-后端(本服群英榜;优化机器人表支持按功能加载不同的机器人;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py |   53 ++++++++++++++++++++++++-----------------------------
 1 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
index ab10733..2891192 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
@@ -452,36 +452,31 @@
                  }
     return robotDict
 
-def LoadRobot():
-    ## 加载机器人缓存,在服务器启动、重读配置时加载
-    robotFPSortList = []
-    viewCacheMgr = DBDataMgr.GetPlayerViewCacheMgr()
-    ipyDataMgr = IpyGameDataPY.IPY_Data()
-    for index in range(ipyDataMgr.GetRobotCount()):
-        ipyData = ipyDataMgr.GetRobotByIndex(index)
-        robotPlayerID = ipyData.GetID()
-        curCache = viewCacheMgr.GetPlayerViewCache(robotPlayerID)
-        if not curCache:
-            curCache = viewCacheMgr.AddPlayerViewCache(robotPlayerID)
-        if not curCache:
-            continue
-        UpdRobotViewCache(curCache, robotPlayerID, ipyData)
-        robotFPSortList.append([curCache.GetFightPowerTotal(), robotPlayerID])
-    robotFPSortList.sort(reverse=True) # 战力倒序排序
-    IpyGameDataPY.SetConfigEx("robotFPSortList", robotFPSortList)
-    GameWorld.Log("加载机器人战力排序: %s, %s" % (len(robotFPSortList), robotFPSortList))
-    return robotFPSortList
-
-def GetRobotFightPowerSortList():
+def GetRobotFightPowerSortList(tempNum=0):
     ## 机器人战力倒序排序列表
     # @return: 倒序排序列表 [[战力, 机器人ID], ...],外部使用可随机修改,不会打乱原始排序
-    sortList = []
-    robotFPSortList = IpyGameDataPY.GetConfigEx("robotFPSortList")
+    robotFPSortList = IpyGameDataPY.GetConfigEx("robotFPSortList%s" % tempNum)
     if not robotFPSortList:
-        robotFPSortList = LoadRobot()
-    if robotFPSortList:
-        sortList += robotFPSortList
-    return sortList
+        robotFPSortList = []
+        viewCacheMgr = DBDataMgr.GetPlayerViewCacheMgr()
+        ipyDataMgr = IpyGameDataPY.IPY_Data()
+        for index in range(ipyDataMgr.GetRobotCount()):
+            ipyData = ipyDataMgr.GetRobotByIndex(index)
+            if ipyData.GetTempNum() != tempNum:
+                continue
+            robotPlayerID = ipyData.GetID()
+            curCache = viewCacheMgr.GetPlayerViewCache(robotPlayerID)
+            if not curCache:
+                curCache = viewCacheMgr.AddPlayerViewCache(robotPlayerID)
+            if not curCache:
+                continue
+            UpdRobotViewCache(curCache, robotPlayerID, ipyData)
+            robotFPSortList.append([curCache.GetFightPowerTotal(), robotPlayerID])
+        robotFPSortList.sort(reverse=True) # 战力倒序排序
+        IpyGameDataPY.SetConfigEx("robotFPSortList%s" % tempNum, robotFPSortList)
+        GameWorld.Log("加载机器人战力排序: tempNum=%s,%s, %s" % (tempNum, len(robotFPSortList), robotFPSortList))
+        
+    return robotFPSortList
 
 def UpdRobotViewCache(curCache, robotID, robotIpyData=None):
     ## 更新机器人查看缓存
@@ -495,11 +490,11 @@
         return
     
     #curCache.SetAccID(dbPlayer.AccID)
-    
+    realmLV = robotIpyData.GetRealmLV()
     curCache.SetPlayerName(GameWorld.GbkToCode(robotIpyData.GetRobotName()))
     curCache.SetLV(robotInfo.get("LV", 1))
     curCache.SetJob(robotInfo.get("Job", 1))
-    curCache.SetRealmLV(robotInfo.get("RealmLV", 0))
+    curCache.SetRealmLV(realmLV if realmLV else robotInfo.get("RealmLV", 0))
     curCache.SetFace(robotInfo.get("Face", 0))
     curCache.SetFacePic(robotInfo.get("FacePic", 0))
     curCache.SetTitleID(robotInfo.get("TitleID", 0))

--
Gitblit v1.8.0