From 6cd229135f9d68fd116638fb00c859419f75b76c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 09 一月 2025 18:19:38 +0800
Subject: [PATCH] 9936 【BT】【英文】【越南】【砍树】人族法宝(增加任务进度奖励领取事件通知CustomAward)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
index 538ec46..d7ad0ea 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
@@ -421,6 +421,31 @@
     ## 服务器组ID,必须唯一,代表这台物理服务器
     return ToIntDef(ReadChConfig.GetPyMongoConfig("platform", "GroupID"), 0)
 
+def GetMainServerID(serverID):
+    ## 获取服务器ID所属主服ID
+    ServerIDMainServerDict = IpyGameDataPY.GetConfigEx("ServerIDMainServerDict")
+    if ServerIDMainServerDict == None:
+        filePath = ChConfig.GetDBPath() + ("\\MixServerMap_%s.json" % GetPlatform())
+        if not os.path.isfile(filePath):
+            SendGameErrorEx("GetMainServerIDError", "file can not found. %s" % filePath)
+        else:
+            fileObj = open(filePath, 'rb')
+            content = fileObj.read()
+            fileObj.close()
+            MixServerMapDict = eval(content)
+            
+            ServerIDMainServerDict = {}
+            for mainServerIDStr, serverIDList in MixServerMapDict.items():
+                mainServerID = int(mainServerIDStr)
+                for sID in serverIDList:
+                    ServerIDMainServerDict[sID] = mainServerID
+            IpyGameDataPY.SetConfigEx("ServerIDMainServerDict", ServerIDMainServerDict)
+            Log("加载 ServerIDMainServerDict=%s" % ServerIDMainServerDict)
+            
+    if not ServerIDMainServerDict:
+        return serverID
+    return ServerIDMainServerDict.get(serverID, serverID)
+
 def GetPlatformServerNum(platform):
     # 获取服务器的平台编号
     platformNumDict = ReadChConfig.GetDBEvalChConfig("DBPlatformNum")
@@ -460,7 +485,7 @@
 def GetPlayerServerID(curPlayer): return GetAccIDServerID(curPlayer.GetAccID())
 def GetAccIDServerID(accID):
     infoList = accID.split(Def_AccID_Split_Sign)
-    return 0 if len(infoList) < 3 else int(infoList[-1][1:])
+    return 0 if len(infoList) < 3 else ToIntDef(infoList[-1][1:])
 
 def GetPlayerServerSID(curPlayer):
     # 返回含s的serverID
@@ -1215,14 +1240,26 @@
     # if not GetGameWorld().GetDebugLevel():
     #    return
     #===========================================================================
+    if IsCrossServer():
+        DebugAnswerCross(0, 0, text)
+        return
     if isLog:
         DebugLog(text)
     text = text.decode(ShareDefine.Def_Game_Character_Encoding).encode(GetCharacterEncoding())
-    curPlayer.DebugAnswer(text)
+    if curPlayer:
+        curPlayer.DebugAnswer(text)
     return
 
 def CrossServerMsg_DebugAnswer(msgData):
     playerID, text = msgData
+    if not playerID:
+        playerManager = GetPlayerManager()
+        for i in xrange(playerManager.GetActivePlayerCount()):
+            player = playerManager.GetActivePlayerAt(i)
+            if player == None:
+                continue
+            player.DebugAnswer(text)
+        return
     curPlayer = GetPlayerManager().FindPlayerByID(playerID)
     if not curPlayer:
         return
@@ -1235,7 +1272,7 @@
     
     import CrossRealmMsg
     dataMsg = [playerID, text]
-    serverGroupIDList = [serverGroupID]
+    serverGroupIDList = [serverGroupID] if serverGroupID else []
     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_DebugAnswer, dataMsg, serverGroupIDList)
     return
 
@@ -1292,6 +1329,14 @@
         SendGameError("GameServerRaiseException", errorMsg)
     return
 
+def SendGameErrorEx(errType, msgInfo="", playerID=0):
+    ErrLog("SendGameErrorEx: %s -> %s" % (errType, msgInfo), playerID)
+    if GetGameWorld().GetDebugLevel():
+        raise Exception("%s -> %s" % (errType, msgInfo))
+    else:
+        SendGameError(errType, msgInfo)
+    return
+
 def SendGameError(errType, msgInfo=""):
     ''' 向运维发送邮件,用于需要紧急处理的信息
     @param errType: 错误类型,自定义即可

--
Gitblit v1.8.0