From bc5f3f1c88d225109fa39a85b209ef13f5fb52a9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 06 二月 2026 21:28:13 +0800
Subject: [PATCH] 66 【公会】基础主体-服务端(跨服公会所有基本功能支持、跨服砍价支持;修改查看目标公会、查看目标玩家方式;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py |   57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py
index 81d7080..de1ac31 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py
@@ -263,6 +263,8 @@
         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:
@@ -343,6 +345,9 @@
             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()
@@ -360,7 +365,6 @@
             if not member and False:
                 member = FamilyMem()
         self.RefrshFightPowerTotal()
-        self.__familyMgr.OnAddMember(self, playerID)
         return member
     
     def DeleteMember(self, playerID):
@@ -520,6 +524,8 @@
                 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:
@@ -834,10 +840,18 @@
         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)
             
@@ -877,7 +891,7 @@
                     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-所属分区
     
@@ -1035,7 +1049,7 @@
             self.__setFamilyToDefaultZone() # 游戏服本服的数据无论有没有跨服了都同意设置到默认分区
         return pos
     
-def LoadZoneCfg(self):
+def LoadZoneCfg():
     crossZoneCfgDict = {}
     appID = GameWorld.GetAppID()
     ipyDataMgr = IpyGameDataPY.IPY_Data()
@@ -1049,6 +1063,7 @@
             crossZoneCfgDict[crossServerID] = {}
         zoneDict = crossZoneCfgDict[crossServerID]
         zoneDict[zoneID] = [] + ipyData.GetServerIDList()
+    GameWorld.Log("跨服公会分区配置加载: appID=%s,%s" % (appID, crossZoneCfgDict))
     return crossZoneCfgDict
 
 def CheckCrossZoneCfg(curCrossZoneCfgDict, updCrossZoneCfgDict):
@@ -1058,7 +1073,7 @@
         GameWorld.Log("跨服公会互通分区配置不变不处理")
         return
     
-    # 验证配置,是否有交叉、拆分,并邮件通知运维,待扩展,先开发功能
+    # 验证配置,是否有交叉、拆分,并邮件通知运维,待扩展,功能完整性优先
     #GameWorld.SendGameErrorEx("FamilyCrossZoneCfgError", "noZoneServerIDList=%s" % noZoneServerIDList)
     
     return True
@@ -1073,11 +1088,13 @@
         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
@@ -1115,6 +1132,7 @@
     ## 跨服服务器同步互通公会信息给游戏服
     # @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:
@@ -1123,6 +1141,7 @@
     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:
@@ -1134,6 +1153,7 @@
         if toServerID:
             if not GameWorld.CheckServerIDInList(toServerID, cfgServerIDList):
                 # 非指定目标服务器所属分区不同步
+                #GameWorld.DebugLog("    非指定目标服务器所属分区不同步 toServerID=%s" % (toServerID))
                 continue
             toServerIDList = [toServerID]
         else:
@@ -1260,6 +1280,7 @@
     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
 
@@ -1270,11 +1291,9 @@
     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
@@ -1287,7 +1306,6 @@
     
     syncFamilyIDList = []
     for dbData in familyDataList:
-        dbData = DBStruct.tagDBFamily()
         familyID = dbData.ID
         familyMgr.DelFamily(familyID, False) # 每次都强制先删除,支持重复同步
         zoneMgr.AddFamilyToZone(familyMgr.InitFamilyInstance(dbData))
@@ -1327,6 +1345,7 @@
     
     errorMsg = ""
     datas, pos, dataslen = syncData, 0, len(syncData)
+    GameWorld.Log("__unpackFamilyData: dataslen=%s" % dataslen)
     
     zoneIDDict = {}
     familyMgr = DBDataMgr.GetFamilyMgr()
@@ -1342,25 +1361,25 @@
         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 = []
@@ -1375,7 +1394,7 @@
     membreDataCnt = cntDict.get("membreDataCnt", 0)
     if uppackMemberCnt != membreDataCnt:
         errorMsg = "同步的成员个数不匹配! uppackMemberCnt=%s != %s" % (uppackMemberCnt, membreDataCnt)
-        return errorMsg
+        return False, errorMsg
     
     # 行为
     actionDataList = []
@@ -1390,9 +1409,9 @@
     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"]

--
Gitblit v1.8.0