| | |
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | | import PyGameData
|
| | |
|
| | | # 获取玩家跨服服务器上的名字
|
| | | #===============================================================================
|
| | | # def GetCrossPlayerName(curPlayer):
|
| | |
| | | # 获取玩家跨服服务器上的名字
|
| | | def GetCrossPlayerName(curPlayer):
|
| | | # 通过游戏账号中的平台标志获取名称,目前为spid
|
| | | playerName = curPlayer.GetPlayerName()
|
| | | playerName = curPlayer.GetName()
|
| | |
|
| | | opName = ReadChConfig.GetPyMongoConfig("Merge", "OpName_%s_%s" % (GameWorld.GetPlayerPlatform(curPlayer),
|
| | | GameWorld.GetPlayerServerSID(curPlayer)))
|
| | |
| | |
|
| | | return opName.decode('gbk').encode(GameWorld.GetCharacterEncoding()) + playerName
|
| | |
|
| | | def GetServerCrossZoneIpyData(mapID, serverGroupID=0):
|
| | | ## 获取本服对应跨服玩法分区地图信息
|
| | | if mapID not in ChConfig.Def_CrossZoneTableName:
|
| | | def GetCrossCommZoneIpyDataByZoneID(zoneID):
|
| | | ## 获取跨服常规分区 |
| | | crossZoneName = GameWorld.GetCrossZoneName()
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataNotLog("CrossZoneComm", crossZoneName, zoneID)
|
| | | return ipyData
|
| | |
|
| | | def GetCrossCommZoneIpyDataByServerGroupID(serverGroupID):
|
| | | ## 获取跨服常规分区
|
| | | crossZoneName = GameWorld.GetCrossZoneName()
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZoneComm", {"CrossZoneName":crossZoneName}, True)
|
| | | if not ipyDataList:
|
| | | return
|
| | | if not serverGroupID:
|
| | | serverGroupID = GameWorld.GetServerGroupID()
|
| | | |
| | | tableName = ChConfig.Def_CrossZoneTableName[mapID]
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | if not hasattr(ipyDataMgr, "Get%sCount" % tableName):
|
| | | return
|
| | | |
| | | for i in xrange(getattr(ipyDataMgr, "Get%sCount" % tableName)()):
|
| | | ipyData = getattr(ipyDataMgr, "Get%sByIndex" % tableName)(i)
|
| | | for ipyData in ipyDataList:
|
| | | serverGroupIDList = ipyData.GetServerGroupIDList()
|
| | | for serverGroupIDInfo in serverGroupIDList:
|
| | | if (isinstance(serverGroupIDInfo, tuple) and serverGroupIDInfo[0] <= serverGroupID <= serverGroupIDInfo[1]) \
|
| | |
| | | return ipyData
|
| | | return
|
| | |
|
| | | def GetCrossCommZoneIpyDataListByServerGroupID(serverGroupID):
|
| | | ## 获取跨服常规分区列表
|
| | | if serverGroupID:
|
| | | ipyData = GetCrossCommZoneIpyDataByServerGroupID(serverGroupID)
|
| | | if not ipyData:
|
| | | return
|
| | | ipyDataList = [ipyData]
|
| | | else:
|
| | | crossZoneName = GameWorld.GetCrossZoneName()
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZoneComm", {"CrossZoneName":crossZoneName}, True)
|
| | | return ipyDataList
|
| | |
|
| | | def GetServerCrossZoneMapIpyData(mapID, serverGroupID=0):
|
| | | ## 获取本服对应跨服玩法分区地图信息
|
| | | if mapID not in ChConfig.Def_CrossZoneMapTableName:
|
| | | return
|
| | | tableName = ChConfig.Def_CrossZoneMapTableName[mapID]
|
| | | if not serverGroupID:
|
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | serverGroupID = GameWorld.GetServerGroupID()
|
| | | zoneIpyData = GetCrossCommZoneIpyDataByServerGroupID(serverGroupID)
|
| | | if not zoneIpyData:
|
| | | return
|
| | | commZoneID = zoneIpyData.GetZoneID()
|
| | | return IpyGameDataPY.GetIpyGameDataByCondition(tableName, {"ZoneID":commZoneID})
|
| | |
|
| | | def IsCrossServerOpen():
|
| | | ## 跨服服务器是否开放中
|
| | | return GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossServerOpen)
|
| | |
|
| | | def ClientServerMsg_ServerInitOK(serverGroupID):
|
| | | ## 子服连接成功
|
| | | def Sync_CrossCommInitDataToClientServer(serverGroupID=0):
|
| | | ''' 同步跨服常规通用数据到子服务器
|
| | | @param serverGroupID: 为0时同步所有子服
|
| | | '''
|
| | | |
| | | isOpen = GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossServerOpen)
|
| | | GameWorld.Log("子服连接成功,通知当前跨服服务器状态: isOpen=%s" % isOpen)
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_CrossServerState, {"isOpen":isOpen}, [serverGroupID])
|
| | | crossZoneName = GameWorld.GetCrossZoneName()
|
| | | GameWorld.Log("通知当前跨服服务器状态: isOpen=%s,crossZoneName=%s,syncServerGroupID=%s" % (isOpen, crossZoneName, serverGroupID))
|
| | | serverGroupIDList = [serverGroupID] if serverGroupID else []
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_CrossServerState, {"isOpen":isOpen, "crossZoneName":crossZoneName}, serverGroupIDList)
|
| | | return
|
| | |
|
| | | def DoChangeCrossServerState(isOpen):
|
| | |
| | |
|
| | | def CrossServerMsg_CrossServerState(msgData):
|
| | | ## 子服收到跨服服务器状态变更,子服不存DB,默认跨服维护中,连接跨服成功后由跨服同步状态直接更新到字典即可,没连上就默认维护中
|
| | | if "crossZoneName" in msgData:
|
| | | PyGameData.g_crossZoneName = msgData["crossZoneName"]
|
| | | GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CrossZoneName, PyGameData.g_crossZoneName)
|
| | | |
| | | isOpen = msgData["isOpen"]
|
| | | isOpen = 1 if isOpen else 0
|
| | | GameWorld.Log("收到跨服服务器状态变更: 是否正常开放中=%s" % isOpen)
|
| | |
| | | continue
|
| | | PlayerControl.SetCrossMapID(curPlayer, 0)
|
| | |
|
| | | GameWorld.GetGameWorld().SendCrossServerStateToLoginServer(isOpen)
|
| | | # 通知地图
|
| | | GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CrossServerOpen, isOpen)
|
| | | return
|
| | |
| | | sendPack.ItemDataSize = len(sendPack.ItemData)
|
| | | sendPack.PlusData = PlusData
|
| | | sendPack.PlusDataSize = len(sendPack.PlusData)
|
| | | sendPack.CrossPlayer = 1
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | return
|
| | |
|