| | |
| | | import IPY_GameWorld
|
| | | import LogUI
|
| | | import ReadChConfig
|
| | | import IpyGameDataPY
|
| | | import random
|
| | | import math
|
| | | import sys
|
| | |
| | | if curPlayer.GetGMLevel() in [0 , ChConfig.Def_GM_LV_God]:
|
| | | return
|
| | |
|
| | | return True
|
| | |
|
| | | def IsMirrorPlayer(curPlayer):
|
| | | ## 是否镜像玩家
|
| | | if curPlayer.GetRealPlayerID() > 0:
|
| | | return True
|
| | | return False
|
| | |
|
| | | def IsNormalPlayer(curPlayer):
|
| | | '''是否正常可用的常规玩家,一般用于判断是否是一个正常的玩家
|
| | | 可用于封包通知判断、活动玩家判断等一切仅处理真实常规玩家的验证
|
| | | '''
|
| | | if not curPlayer or curPlayer.GetID() == 0 or curPlayer.IsEmpty():
|
| | | return False
|
| | | #if not curPlayer.GetInitOK():
|
| | | # return False
|
| | | #if IsTJGPlayer(curPlayer):
|
| | | # return False
|
| | | if IsMirrorPlayer(curPlayer):
|
| | | return False
|
| | | return True
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
| | | ## 服务器组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):
|
| | | accID = curPlayer.GetAccID()
|
| | | 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
|
| | |
| | | SendGameError("MapServerRaiseException", 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: 错误类型,自定义即可
|