| | |
| | | self.__dbData.FightPower = fightPowerTotal % ChConfig.Def_PerPointValue
|
| | | self.__dbData.FightPowerEx = fightPowerTotal / ChConfig.Def_PerPointValue
|
| | | return
|
| | | def GetServerID(self): return self.__dbData.ServerID
|
| | | def GetServerID(self): return int(self.__dbData.ServerID)
|
| | | def SetServerID(self, serverID): self.__dbData.ServerID = serverID
|
| | | def GetOffTime(self): return self.__dbData.OffTime
|
| | | def SetOffTime(self, offTime): self.__dbData.OffTime = offTime
|
| | |
| | | self.SetFacePic(viewCache.GetFacePic())
|
| | | self.SetTitleID(viewCache.GetTitleID())
|
| | | self.SetServerID(viewCache.GetServerID())
|
| | | if not self.GetOffTime(): # 有离线时间数据了,以成员自己的为准
|
| | | self.SetOffTime(viewCache.GetOffTime())
|
| | | fpChange = False
|
| | | fightPowerTotal = viewCache.GetFightPowerTotal()
|
| | | if self.GetFightPowerTotal() != fightPowerTotal:
|
| | |
| | |
|
| | | def GetID(self): return self.__dbData.ID
|
| | | def GetCreateTime(self): return self.__dbData.CreateTime
|
| | | def GetServerID(self): return self.__dbData.ServerID
|
| | | def GetServerID(self): return int(self.__dbData.ServerID)
|
| | | def GetName(self): return self.__dbData.Name
|
| | | def SetName(self, name): self.__dbData.Name = name
|
| | | def GetLeaderID(self): return self.__dbData.LeaderID
|
| | |
| | | return
|
| | | self.__memberDict[playerID] = member
|
| | | self.__memberList.append(member)
|
| | | viewCache = PlayerViewCache.FindViewCache(playerID)
|
| | | member.SetOffTime(viewCache.GetOffTime() if viewCache else int(time.time()))
|
| | | self.__familyMgr.OnAddMember(self, playerID)
|
| | | return member
|
| | |
|
| | | def GetMemberIDList(self): return self.__memberDict.keys()
|
| | |
| | | if not member and False:
|
| | | member = FamilyMem()
|
| | | self.RefrshFightPowerTotal()
|
| | | self.__familyMgr.OnAddMember(self, playerID)
|
| | | return member
|
| | |
|
| | | def DeleteMember(self, playerID):
|
| | |
| | | self.__needSort = False
|
| | | return
|
| | |
|
| | | def AddServerIDToZone(self, serverID):
|
| | | '''直接将某个区服加入该分区,一般用于自身没有公会的游戏服
|
| | | 比较特殊的情况:当某个游戏服自身没有公会时,在加入互通后,当还没有玩家加入某个其他服公会时,会导致找不到该服的所属分区
|
| | | 所以游戏服在互通分区更新时在本服没有公会时需要额外同步跨服告知加入互通,否则会导致该服玩家无法正常加入公会互通
|
| | | @return: True - 成功新加入; False - 已经加入了
|
| | | '''
|
| | | if serverID not in self.__zoneServerIDList:
|
| | | self.__zoneServerIDList.append(serverID)
|
| | | return True
|
| | | return False
|
| | | |
| | | def AddFamilyToZone(self, family):
|
| | | ## 将某个公会分配给该分区
|
| | | if not family:
|
| | |
| | | if fixName not in self.__familyNameDict:
|
| | | familyName = fixName
|
| | | break
|
| | | family.SetName(familyName)
|
| | | family.SetExtra1(0) # 重置改名CD
|
| | | self.__familyNameDict[familyName] = family
|
| | |
|
| | | if family not in self.__familyList:
|
| | |
| | |
|
| | | if familyServerID not in self.__zoneServerIDList:
|
| | | self.__zoneServerIDList.append(familyServerID)
|
| | | |
| | | # 成员也需要检查,防止没有公会的游戏服玩家无法正确划入某个分区
|
| | | for index in range(family.GetCount()):
|
| | | member = family.GetAt(index)
|
| | | memID = member.GetPlayerID()
|
| | | memServerID = member.GetServerID()
|
| | | if memID < ShareDefine.RealPlayerIDStart:
|
| | | #GameWorld.DebugLog("非真人的成员不计入! memID=%s,memServerID=%s" % (memID, memServerID))
|
| | | continue
|
| | | if memServerID not in self.__zoneServerIDList:
|
| | | self.__zoneServerIDList.append(memServerID)
|
| | | |
| | | self.__needSort = True
|
| | | self.__familyMgr.OnAddToZone(family, self.__zoneID)
|
| | | return
|
| | |
| | | elif False:
|
| | | family = Family()
|
| | | return family
|
| | | |
| | | def FamilyRemainName(self, family, newName):
|
| | | if newName in self.__familyNameDict:
|
| | | return
|
| | | self.__familyNameDict.pop(family.GetName(), None) # 去除旧名
|
| | | family.SetName(newName)
|
| | | self.__familyNameDict[newName] = family # 设置新名
|
| | | return True
|
| | |
|
| | | def GetCount(self): return len(self.__familyList)
|
| | | def GetAt(self, index):
|
| | |
| | | self.__crossZoneCfgDict = updCrossZoneCfgDict
|
| | | self.__zoneFamilyMgrDict = {}
|
| | | self.__familyIDZoneIDDict = {}
|
| | | |
| | | # 重新初始化本服管理的分区
|
| | | zoneDict = self.__crossZoneCfgDict[crossServerID]
|
| | | GameWorld.Log("本跨服重置公会互通分区! crossServerID=%s,zoneDict=%s" % (crossServerID, zoneDict))
|
| | | for zoneID in zoneDict.keys():
|
| | | self.GetZoneFamilyMgr(zoneID)
|
| | | GameWorld.Log("GetZoneIDListThisServer=%s" % self.GetZoneIDListThisServer())
|
| | | |
| | | # 重新将本服公会数据分配到所属分区
|
| | | for family in self.__familyIDDict.values():
|
| | | familyID = family.GetID()
|
| | | zoneID = familyZoneDict.get(familyID, 0) # 理论上不可能再为0
|
| | | zoneID = familyZoneDict.get(familyID, 0) # 理论上不可能再为0,因为有0时 noZoneServerIDList 验证不会通过
|
| | | zoneMgr = self.GetZoneFamilyMgr(zoneID)
|
| | | zoneMgr.AddFamilyToZone(family)
|
| | |
|
| | |
| | | break
|
| | | return zoneID
|
| | |
|
| | | def GetZoneIDListThisServer(self): return self.__zoneFamilyMgrDict.keys() # 在本服数据中已存在的分区
|
| | | def GetZoneIDListThisServer(self): return self.__zoneFamilyMgrDict.keys() # 本服管理的分区
|
| | |
|
| | | def GetFamilyZoneID(self, familyID): return self.__familyIDZoneIDDict.get(familyID, -1) # -1-未找到所属分区;>=0-所属分区
|
| | |
|
| | |
| | | self.__setFamilyToDefaultZone() # 游戏服本服的数据无论有没有跨服了都同意设置到默认分区
|
| | | return pos
|
| | |
|
| | | def LoadZoneCfg(self):
|
| | | def LoadZoneCfg():
|
| | | crossZoneCfgDict = {}
|
| | | appID = GameWorld.GetAppID()
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | |
| | | crossZoneCfgDict[crossServerID] = {}
|
| | | zoneDict = crossZoneCfgDict[crossServerID]
|
| | | zoneDict[zoneID] = [] + ipyData.GetServerIDList()
|
| | | GameWorld.Log("跨服公会分区配置加载: appID=%s,%s" % (appID, crossZoneCfgDict))
|
| | | return crossZoneCfgDict
|
| | |
|
| | | def CheckCrossZoneCfg(curCrossZoneCfgDict, updCrossZoneCfgDict):
|
| | |
| | | GameWorld.Log("跨服公会互通分区配置不变不处理")
|
| | | return
|
| | |
|
| | | # 验证配置,是否有交叉、拆分,并邮件通知运维,待扩展,先开发功能
|
| | | # 验证配置,是否有交叉、拆分,并邮件通知运维,待扩展,功能完整性优先
|
| | | #GameWorld.SendGameErrorEx("FamilyCrossZoneCfgError", "noZoneServerIDList=%s" % noZoneServerIDList)
|
| | |
|
| | | return True
|
| | |
| | | if not crossZoneCfgDict or not DBDataMgr.GetFamilyMgr().UpdCrossZoneCfgDict(crossZoneCfgDict):
|
| | | return
|
| | | Sync_CenterToCross_FamilyCrossCfg()
|
| | | |
| | | Sync_CrossToServer_FamilyInfo()
|
| | | return
|
| | |
|
| | | def Sync_CenterToCross_FamilyInfo(serverType, serverID):
|
| | | ## 跨服中心同步给跨服服务器
|
| | | |
| | | # 【注】只同步给跨服服务器,各跨服验证通过后,游戏服才会通过所属跨服取得最终的分区信息
|
| | | if serverType == ShareDefine.serverType_Cross:
|
| | | Sync_CenterToCross_FamilyCrossCfg(serverID)
|
| | | return
|
| | |
| | | Sync_CrossToServer_FamilyInfo()
|
| | | return
|
| | |
|
| | | def Sync_CrossToServer_FamilyInfo(toServerID=0, syncZoneID=0, syncFamilyIDList=[]):
|
| | | def Sync_CrossToServer_FamilyInfo(toServerID=0, syncZoneID=0, withCfg=True):
|
| | | ## 跨服服务器同步互通公会信息给游戏服
|
| | | # @param toServerID: 有指定游戏服连上时只发给该服,没有的话一般是分区配置变更时由跨服主动同步所有相关游戏服
|
| | |
|
| | | GameWorld.DebugLog("Sync_CrossToServer_FamilyInfo toServerID=%s,syncZoneID=%s,withCfg=%s" % (toServerID, syncZoneID, withCfg))
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | | crossZoneCfgDict = familyMgr.GetCrossZoneCfgDict() # 配置的互通
|
| | | if not crossZoneCfgDict:
|
| | |
| | | if crossServerID not in crossZoneCfgDict:
|
| | | return
|
| | | zoneCfgDict = crossZoneCfgDict[crossServerID]
|
| | | GameWorld.DebugLog(" crossServerID=%s,zoneCfgDict=%s" % (crossServerID, zoneCfgDict))
|
| | |
|
| | | for zoneID in familyMgr.GetZoneIDListThisServer():
|
| | | if syncZoneID and syncZoneID != zoneID:
|
| | |
| | | if toServerID:
|
| | | if not GameWorld.CheckServerIDInList(toServerID, cfgServerIDList):
|
| | | # 非指定目标服务器所属分区不同步
|
| | | #GameWorld.DebugLog(" 非指定目标服务器所属分区不同步 toServerID=%s" % (toServerID))
|
| | | continue
|
| | | toServerIDList = [toServerID]
|
| | | else:
|
| | | toServerIDList = cfgServerIDList
|
| | |
|
| | | zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
|
| | | zoneServerIDList = zoneMgr.GetZoneServerIDList()
|
| | | zoneServerIDList = zoneMgr.GetZoneServerIDList() # 实际已经互通的区服ID列表
|
| | |
|
| | | # viewBaseDict = {}
|
| | | # for index in range(zoneMgr.GetCount()):
|
| | | # family = zoneMgr.GetAt(index)
|
| | | # familyID = family.GetID()
|
| | | # if syncFamilyIDList and familyID not in syncFamilyIDList:
|
| | | # continue
|
| | | # viewBase = familyMgr.GetFamilyViewBase(familyID)
|
| | | # viewBaseDict[familyID] = viewBase.GetSyncData()
|
| | | |
| | | # 只通知给已经互通的相关服务器即可
|
| | | # 关于查看玩家
|
| | | # 1. 查看玩家直接到玩家所在服务器查询即可,查看玩家需要公会的一些基本信息,如 公会名、徽章、旗帜、互通跨服ID 等
|
| | | # 2. 玩家/查看玩家信息只需记录所属公会ID即可,公会相关基础信息通过 FamilyViewBase 获取,由互通所在跨服同步过来
|
| | | |
| | | # 关于查看公会
|
| | | # 1. 从查看玩家中查看公会,发送公会ID、所属互通跨服ID,直接去目标服务器查询即可
|
| | | # 2. 从跨服活动中查看公会,活动相关公会记录所属互通跨服ID,同样直接去目标服务器查询即可
|
| | | |
| | | dataMsg = {"crossZoneCfgDict":crossZoneCfgDict, "zoneID":zoneID, "zoneServerIDList":zoneServerIDList}
|
| | | dataMsg = {"zoneID":zoneID, "zoneServerIDList":zoneServerIDList}
|
| | | if withCfg:
|
| | | dataMsg["crossZoneCfgDict"] = crossZoneCfgDict
|
| | | CrossMsg.SendToClientServer(ShareDefine.C2S_FamilyCrossInfo, dataMsg, toServerIDList)
|
| | |
|
| | | return
|
| | |
| | | familyMgr.SetCurCrossServerID(fromServerID) # 直接设置,哪个服同步过来的就是所属跨服ID
|
| | | familyMgr.SetCurZoneID(dataMsg["zoneID"])
|
| | |
|
| | | # ## 本服更新跨服互通公会的基本信息
|
| | | # if "viewBaseDict" in dataMsg:
|
| | | # viewBaseDict = dataMsg["viewBaseDict"]
|
| | | # for familyID, syncData in viewBaseDict.items():
|
| | | # viewBase = familyMgr.GetFamilyViewBase(familyID)
|
| | | # viewBase.UpdSyncData(syncData)
|
| | | |
| | | # 互通配置
|
| | | if "crossZoneCfgDict" in dataMsg:
|
| | | # 游戏服不用验证了,直接设置,跨服中心、跟跨服数据服已经验证过了,只要验证互通条件传输数据逻辑即可
|
| | | familyMgr.SetCrossZoneCfgDict(dataMsg["crossZoneCfgDict"])
|
| | | CheckCrossFamilyTransData(fromServerID)
|
| | | |
| | | # 实际已互通分区
|
| | | if "zoneServerIDList" in dataMsg:
|
| | | curZoneServerIDList = familyMgr.GetCurZoneServerIDList()
|
| | |
| | | if curZoneServerIDList != updZoneServerIDList:
|
| | | Sync_FamilyCrossInfo()
|
| | |
|
| | | # 互通配置
|
| | | if "crossZoneCfgDict" in dataMsg:
|
| | | # 游戏服不用验证了,直接设置,跨服中心、跟跨服数据服已经验证过了,只要验证互通条件传输数据逻辑即可
|
| | | familyMgr.SetCrossZoneCfgDict(dataMsg["crossZoneCfgDict"])
|
| | | CheckCrossFamilyTransData(fromServerID)
|
| | | |
| | | return
|
| | |
|
| | | def IsFamilyCross():
|
| | |
| | | ## 本服公会首次跨服互通同步数据中
|
| | | return DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_FamilyTransDataTime) > 0
|
| | |
|
| | | def CheckMainServerNoFamilyToCross(connServerID=0):
|
| | | '''已经互通的情况下,需要再额外检查本服是否有公会
|
| | | 没有公会时需要主动告知跨服检查是否成功加入互通分区,否则本服将无法正常进行公会互通
|
| | | '''
|
| | | if not IsFamilyCross():
|
| | | return
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | | familyIDList = familyMgr.GetFamilyIDList()
|
| | | if familyIDList:
|
| | | return
|
| | | |
| | | serverID = GameWorld.GetGameWorld().GetServerID()
|
| | | GameWorld.Log("本服无公会需直接同步跨服请求检查加入互通分区! serverID=%s" % (serverID))
|
| | | |
| | | curZoneServerIDList = familyMgr.GetCurZoneServerIDList()
|
| | | if serverID in curZoneServerIDList:
|
| | | GameWorld.Log("已经在互通分区里了不处理! serverID=%s in %s" % (serverID, curZoneServerIDList))
|
| | | return
|
| | | |
| | | crossServerID = 0
|
| | | toZoneID = 0
|
| | | crossZoneCfgDict = familyMgr.GetCrossZoneCfgDict()
|
| | | for cID, zoneDict in crossZoneCfgDict.items():
|
| | | for zoneID, serverIDRangeList in zoneDict.items():
|
| | | if GameWorld.CheckServerIDInList(serverID, serverIDRangeList):
|
| | | crossServerID = cID
|
| | | toZoneID = zoneID
|
| | | GameWorld.Log("本服公会所属跨服ID! serverID=%s,crossServerID=%s,zoneID=%s,serverIDRangeList=%s" % (serverID, crossServerID, zoneID, serverIDRangeList))
|
| | | break
|
| | | if crossServerID:
|
| | | break
|
| | | if not crossServerID:
|
| | | GameWorld.Log("本服公会未分配互通分区! serverID=%s" % (serverID))
|
| | | return
|
| | | |
| | | if connServerID:
|
| | | if connServerID != crossServerID:
|
| | | GameWorld.Log("本服公会互通非目标跨服ID不处理! serverID=%s,crossServerID=%s != %s" % (serverID, crossServerID, connServerID))
|
| | | return
|
| | | else:
|
| | | ssServer = CrossMgr.GetSSServerMgr().GetSSServer(crossServerID)
|
| | | connState = ssServer.GetConnState()
|
| | | if connState != ShareDefine.ssConn_Normal:
|
| | | GameWorld.Log("本服公会互通目标跨服ID非连接状态! serverID=%s,crossServerID=%s,connState=%s" % (serverID, crossServerID, connState))
|
| | | return
|
| | | |
| | | CrossMsg.SendToCrossServer(ShareDefine.S2C_FamilyData, {"checkInZone":1, "toZoneID":toZoneID}, [crossServerID])
|
| | | return
|
| | |
|
| | | def CheckCrossFamilyTransData(connServerID=0, ignoreCD=False):
|
| | | ## 检查跨服公会传输数据,服务器启动时、onday时检查,或GM等指定强制调用
|
| | |
|
| | | if IsFamilyCross():
|
| | | GameWorld.DebugLog("本服公会已经跨服了!")
|
| | | CheckMainServerNoFamilyToCross(connServerID)
|
| | | return
|
| | |
|
| | | NeedServerDay = IpyGameDataPY.GetFuncCfg("FamilyCross", 1)
|
| | |
| | | crossZoneCfgDict = familyMgr.GetCrossZoneCfgDict()
|
| | |
|
| | | crossServerID = 0
|
| | | toZoneID = 0
|
| | | serverID = GameWorld.GetGameWorld().GetServerID()
|
| | | for cID, zoneDict in crossZoneCfgDict.items():
|
| | | for zoneID, serverIDRangeList in zoneDict.items():
|
| | | if GameWorld.CheckServerIDInList(serverID, serverIDRangeList):
|
| | | crossServerID = cID
|
| | | toZoneID = zoneID
|
| | | GameWorld.Log("本服公会所属跨服ID! serverID=%s,crossServerID=%s,zoneID=%s,serverIDRangeList=%s" % (serverID, crossServerID, zoneID, serverIDRangeList))
|
| | | break
|
| | | if crossServerID:
|
| | |
| | | GameWorld.Log("本服公会互通传输数据中! serverID=%s,crossServerID=%s,transDataTime=%s" % (serverID, crossServerID, GameWorld.ChangeTimeNumToStr(transDataTime)))
|
| | | return
|
| | |
|
| | | GameWorld.Log("本服公会开启互通开始传输公会相关数据! serverID=%s,crossServerID=%s" % (serverID, crossServerID))
|
| | | GameWorld.Log("本服公会开启互通开始传输公会相关数据! serverID=%s,crossServerID=%s,toZoneID=%s" % (serverID, crossServerID, toZoneID))
|
| | | DBDataMgr.GetEventTrigMgr().SetValue(ShareDefine.Def_FamilyTransDataTime, int(time.time()))
|
| | |
|
| | | cntDict = {}
|
| | |
| | | syncData = familyMgr.GetSaveData(cntDict)
|
| | | familyIDList = familyMgr.GetFamilyIDList()
|
| | |
|
| | | CrossMsg.SendToCrossServer(ShareDefine.S2C_FamilyData, {"syncData":syncData, "familyIDList":familyIDList, "cntDict":cntDict}, [crossServerID])
|
| | | GameWorld.Log("dataslen=%s" % len(syncData))
|
| | | CrossMsg.SendToCrossServer(ShareDefine.S2C_FamilyData, {"syncData":syncData, "familyIDList":familyIDList, "cntDict":cntDict, "toZoneID":toZoneID}, [crossServerID])
|
| | | return
|
| | |
|
| | | def S2C_FamilyData(dataMsg, fromServerID):
|
| | | if "checkInZone" in dataMsg:
|
| | | toZoneID = dataMsg["toZoneID"]
|
| | | __doCheckServerInZone(fromServerID, toZoneID)
|
| | | return
|
| | | syncData = dataMsg["syncData"]
|
| | | familyIDList = dataMsg["familyIDList"]
|
| | | cntDict = dataMsg["cntDict"]
|
| | | GameWorld.Log("收到游戏服同步的互通公会数据! fromServerID=%s,cntDict=%s,familyIDList=%s" % (fromServerID, cntDict, familyIDList))
|
| | | toZoneID = dataMsg["toZoneID"]
|
| | | GameWorld.Log("收到游戏服同步的互通公会数据! fromServerID=%s,toZoneID=%s,cntDict=%s,familyIDList=%s" % (fromServerID, toZoneID, cntDict, familyIDList))
|
| | |
|
| | | unpackRet = __unpackFamilyData(syncData, familyIDList, cntDict)
|
| | | if not unpackRet:
|
| | | errorMsg = "unknown"
|
| | | if not familyIDList:
|
| | | GameWorld.Log("该服没有公会,直接加入互通范围! fromServerID=%s,toZoneID=%s" % (fromServerID, toZoneID))
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | | zoneID = familyMgr.GetZoneIDInThisServer(fromServerID)
|
| | | familyDataList, memberDataList, actionDataList = [], [], []
|
| | | else:
|
| | | errorMsg = unpackRet[0]
|
| | | if errorMsg:
|
| | | GameWorld.SendGameErrorEx("S2C_FamilyDataError", "互通公会数据同步失败! fromServerID=%s,errorMsg=%s" % (fromServerID, errorMsg))
|
| | | unpackRet = __unpackFamilyData(syncData, familyIDList, cntDict)
|
| | | isOK = unpackRet[0]
|
| | | if not isOK:
|
| | | errorMsg = unpackRet[1]
|
| | | GameWorld.SendGameErrorEx("S2C_FamilyDataError", "互通公会数据同步失败! fromServerID=%s,errorMsg=%s" % (fromServerID, errorMsg))
|
| | | CrossMsg.SendToClientServer(ShareDefine.C2S_FamilyDataRet, {"isOK":False}, [fromServerID])
|
| | | return
|
| | | zoneID, familyDataList, memberDataList, actionDataList = unpackRet[1:]
|
| | | |
| | | if toZoneID != zoneID:
|
| | | GameWorld.SendGameErrorEx("S2C_FamilyDataError", "加入的互通分区不一致! fromServerID=%s,toZoneID=%s != %s" % (fromServerID, toZoneID, zoneID))
|
| | | CrossMsg.SendToClientServer(ShareDefine.C2S_FamilyDataRet, {"isOK":False}, [fromServerID])
|
| | | return
|
| | | zoneID, familyDataList, memberDataList, actionDataList = unpackRet[1:]
|
| | |
|
| | | # 插入新数据,重名的会在加入分区后自动改名
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | | zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
|
| | | actionMgr = familyMgr.GetFamilyActionMgr()
|
| | |
|
| | | syncFamilyIDList = []
|
| | | for dbData in familyDataList:
|
| | | dbData = DBStruct.tagDBFamily()
|
| | | familyID = dbData.ID
|
| | | familyMgr.DelFamily(familyID, False) # 每次都强制先删除,支持重复同步
|
| | | zoneMgr.AddFamilyToZone(familyMgr.InitFamilyInstance(dbData))
|
| | | syncFamilyIDList.append(familyID)
|
| | |
|
| | | # 成员
|
| | | for dbData in memberDataList:
|
| | |
| | | action = actionMgr.GetFamilyAction(familyID, actionType)
|
| | | action.InitActionInstance(dbData)
|
| | |
|
| | | zoneMgr.AddServerIDToZone(fromServerID) # 再补设置一次,确保没有公会时也能正常加入互通分区
|
| | | |
| | | # 同步给相同互通分区的服务器
|
| | | Sync_CrossToServer_FamilyInfo(syncZoneID=zoneID, syncFamilyIDList=syncFamilyIDList)
|
| | | Sync_CrossToServer_FamilyInfo(syncZoneID=zoneID)
|
| | |
|
| | | # 最后回复同步结果
|
| | | CrossMsg.SendToClientServer(ShareDefine.C2S_FamilyDataRet, {"isOK":True}, [fromServerID])
|
| | | return
|
| | |
|
| | | def __doCheckServerInZone(fromServerID, toZoneID):
|
| | | GameWorld.Log("检查游戏服是否已经成功加入互通分区! fromServerID=%s,toZoneID=%s" % (fromServerID, toZoneID))
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | | zoneID = familyMgr.GetZoneIDInThisServer(fromServerID)
|
| | | if toZoneID != zoneID:
|
| | | GameWorld.SendGameErrorEx("CheckServerInZoneError", "检查的互通分区不一致! fromServerID=%s,toZoneID=%s != %s" % (fromServerID, toZoneID, zoneID))
|
| | | return
|
| | | zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
|
| | | if not zoneMgr.AddServerIDToZone(fromServerID):
|
| | | GameWorld.Log("已经在该互通分区里了不处理! fromServerID=%s,toZoneID=%s" % (fromServerID, toZoneID))
|
| | | return
|
| | | GameWorld.Log("检查且成功加入公会互通分区! fromServerID=%s,toZoneID=%s" % (fromServerID, toZoneID))
|
| | | Sync_CrossToServer_FamilyInfo(syncZoneID=zoneID, withCfg=False) # 需传False,防止一直重复检查
|
| | | return
|
| | |
|
| | | def __unpackFamilyData(syncData, familyIDList, cntDict):
|
| | |
| | |
|
| | | errorMsg = ""
|
| | | datas, pos, dataslen = syncData, 0, len(syncData)
|
| | | GameWorld.Log("__unpackFamilyData: dataslen=%s" % dataslen)
|
| | |
|
| | | zoneIDDict = {}
|
| | | familyMgr = DBDataMgr.GetFamilyMgr()
|
| | |
| | | familyID = dbData.ID
|
| | | if familyID not in familyIDList:
|
| | | errorMsg = "同步的数据公会ID不匹配! familyID=%s not in %s" % (familyID, familyIDList)
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | |
|
| | | familyServerID = dbData.ServerID
|
| | | zoneID = familyMgr.GetZoneIDInThisServer(familyServerID)
|
| | | if zoneID <= 0:
|
| | | errorMsg = "同步的公会数据不属于本跨服! familyID=%s,familyServerID=%s,zoneID=%s" % (familyID, familyServerID, zoneID)
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | | zoneIDDict[zoneID] = familyServerID
|
| | |
|
| | | if len(zoneIDDict) != 1:
|
| | | errorMsg = "同步的公会数据分区异常可能存在多个分区! zoneIDDict=%s" % zoneIDDict
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | | zoneID = zoneIDDict.keys()[0]
|
| | |
|
| | | uppackFamilyCnt = len(familyDataList)
|
| | | familyDataCnt = cntDict.get("familyDataCnt", 0)
|
| | | if uppackFamilyCnt != familyDataCnt:
|
| | | errorMsg = "同步的公会个数不匹配! uppackFamilyCnt=%s != %s" % (uppackFamilyCnt, familyDataCnt)
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | |
|
| | | # 成员
|
| | | memberDataList = []
|
| | |
| | | membreDataCnt = cntDict.get("membreDataCnt", 0)
|
| | | if uppackMemberCnt != membreDataCnt:
|
| | | errorMsg = "同步的成员个数不匹配! uppackMemberCnt=%s != %s" % (uppackMemberCnt, membreDataCnt)
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | |
|
| | | # 行为
|
| | | actionDataList = []
|
| | |
| | | actionDataCnt = cntDict.get("actionDataCnt", 0)
|
| | | if uppackMemberCnt != membreDataCnt:
|
| | | errorMsg = "同步的行为个数不匹配! uppackActionCnt=%s != %s" % (uppackActionCnt, actionDataCnt)
|
| | | return errorMsg
|
| | | return False, errorMsg
|
| | |
|
| | | return errorMsg, zoneID, familyDataList, memberDataList, actionDataList
|
| | | return True, zoneID, familyDataList, memberDataList, actionDataList
|
| | |
|
| | | def C2S_FamilyDataRet(dataMsg, fromServerID):
|
| | | isOK = dataMsg["isOK"]
|