| | |
| | | ## 服务器组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")
|
| | |
| | | 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
|
| | |
| | |
|
| | | return fullName
|
| | |
|
| | | def MergeItemList(itemList):
|
| | | ## 合并物品列表,将相同物品数量合并
|
| | | itemDict = {}
|
| | | for itemInfo in itemList:
|
| | | if len(itemInfo) == 3:
|
| | | itemID, itemCount, isAuctionItem = itemInfo
|
| | | elif len(itemInfo) == 2:
|
| | | itemID, itemCount = itemInfo
|
| | | isAuctionItem = None
|
| | | else:
|
| | | continue
|
| | | key = (itemID, isAuctionItem)
|
| | | itemDict[key] = itemDict.get(key, 0) + itemCount
|
| | | |
| | | mItemList = []
|
| | | for key, itemCount in itemDict.items():
|
| | | itemID, isAuctionItem = key
|
| | | if isAuctionItem == None:
|
| | | mItemList.append([itemID, itemCount])
|
| | | else:
|
| | | mItemList.append([itemID, itemCount, isAuctionItem])
|
| | | return mItemList
|
| | |
|
| | | ## 从列表中产生物品,[[几率,object], ....],万分率
|
| | | # @param itemList 待选列表
|
| | |
| | | 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: 错误类型,自定义即可
|