From 8f7a29d699d30c14695a1a47a6fb70f45f9f4177 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期四, 17 十月 2024 16:50:18 +0800 Subject: [PATCH] 10263 【越南】【英文】后端支持NPC仿真实玩家战斗和快速战斗 --- ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py index 12c07f6..1283b15 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 @@ -1243,6 +1268,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