| | |
| | | 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):
|
| | |
| | | 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:
|
| | |
| | | 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
|
| | |
| | | ## 跨服服务器同步互通公会信息给游戏服
|
| | | # @param toServerID: 有指定游戏服连上时只发给该服,没有的话一般是分区配置变更时由跨服主动同步所有相关游戏服
|
| | |
|
| | | GameWorld.DebugLog("Sync_CrossToServer_FamilyInfo toServerID=%s,syncZoneID=%s,syncFamilyIDList=%s" % (toServerID, syncZoneID, syncFamilyIDList))
|
| | | 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:
|
| | |
| | | syncData = familyMgr.GetSaveData(cntDict)
|
| | | familyIDList = familyMgr.GetFamilyIDList()
|
| | |
|
| | | GameWorld.Log("dataslen=%s" % len(syncData))
|
| | | CrossMsg.SendToCrossServer(ShareDefine.S2C_FamilyData, {"syncData":syncData, "familyIDList":familyIDList, "cntDict":cntDict}, [crossServerID])
|
| | | return
|
| | |
|
| | |
| | | GameWorld.Log("收到游戏服同步的互通公会数据! fromServerID=%s,cntDict=%s,familyIDList=%s" % (fromServerID, cntDict, familyIDList))
|
| | |
|
| | | unpackRet = __unpackFamilyData(syncData, familyIDList, cntDict)
|
| | | if not unpackRet:
|
| | | errorMsg = "unknown"
|
| | | else:
|
| | | errorMsg = unpackRet[0]
|
| | | if errorMsg:
|
| | | 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
|
| | |
| | |
|
| | | syncFamilyIDList = []
|
| | | for dbData in familyDataList:
|
| | | dbData = DBStruct.tagDBFamily()
|
| | | familyID = dbData.ID
|
| | | familyMgr.DelFamily(familyID, False) # 每次都强制先删除,支持重复同步
|
| | | zoneMgr.AddFamilyToZone(familyMgr.InitFamilyInstance(dbData))
|
| | |
| | |
|
| | | 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"]
|