From acf66892de825190045053d1c7892b0ac5911d0a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 21 五月 2025 09:31:15 +0800
Subject: [PATCH] 16 卡牌服务端(仙盟ID分配优化;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBFamily.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 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 c8bf380..9ef6384 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
@@ -20,6 +20,7 @@
 import GameWorld
 import ShareDefine
 import PlayerControl
+import PyMongoMain
 import DBDataMgr
 import ChConfig
 import DBComm
@@ -430,9 +431,14 @@
         self.__familyList.sort(key=lambda f: (f.GetFightPowerTotal(), f.GetLV()), reverse=True)
         return
     
-    def AddFamily(self, familyID, familyName, serverID):
+    def AddFamily(self, familyName, serverID, familyID=None):
         ## 创建新仙盟
         newFamily = None
+        if familyID == None:
+            familyID = PyMongoMain.GetUserCtrlDB().GetNewFamilyID()
+            if familyID <= 0:
+                GameWorld.ErrLog("创建仙盟时生成新ID异常!")
+                return newFamily
         if familyID in self.__familyIDDict:
             GameWorld.ErrLog("创建仙盟时ID已存在! familyID=%s" % familyID)
             return newFamily
@@ -478,6 +484,8 @@
                 self.__familyList.remove(family)
             family.OnDelete()
         self.__familyIDDict.pop(familyID, None)
+        if familyID > ShareDefine.FackFamilyIDMax:
+            PyMongoMain.GetUserCtrlDB().FreeFamilyID(familyID) # 归还仙盟ID,重复使用
         return family
     
     def DelAllFamily(self):
@@ -628,6 +636,7 @@
             action = self.__actionMgr.GetFamilyAction(familyID, actionType)
             action.InitActionInstance(dbData)
             
+        PyMongoMain.GetUserCtrlDB().OnFamilyIDInit(self.__familyIDDict.keys())
         return pos
     
 def OnMinute():

--
Gitblit v1.8.0