From 5bfcd3104f7c2fa25995bc0184e6c33c818e3cf8 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 19 五月 2025 17:29:58 +0800
Subject: [PATCH] 16 卡牌服务端(ServersConfig先提到配置json文件)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py                       |    4 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/DBCommon/GlobalFunctions.py |    3 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCRealmRefresh.py                |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py                      |    4 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py                          |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Config/DBConfig.py          |    4 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/LogicProcess/UserCtrlDB.py  |   50 ++++++++++++------------
 PySysDB/生成IpyGameDataPY/IpyGameDataPYCreater.py                                                           |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py                           |    7 +++
 9 files changed, 43 insertions(+), 35 deletions(-)

diff --git "a/PySysDB/\347\224\237\346\210\220IpyGameDataPY/IpyGameDataPYCreater.py" "b/PySysDB/\347\224\237\346\210\220IpyGameDataPY/IpyGameDataPYCreater.py"
index 567e787..939cbb7 100644
--- "a/PySysDB/\347\224\237\346\210\220IpyGameDataPY/IpyGameDataPYCreater.py"
+++ "b/PySysDB/\347\224\237\346\210\220IpyGameDataPY/IpyGameDataPYCreater.py"
@@ -57,7 +57,7 @@
     StructFileName = sys.argv[1]
     if StructFileName == "PySysDBPY.h":
         IpyGameDataPYFile = CodeProjectPath + "\\ZoneServerGroup\\map1_8G\\MapServer\\MapServerData\\Script\\"
-        LoadStructPath = "ChConfig.GetDBPath()"
+        LoadStructPath = "ChConfig.GetServerConfigPath()"
     elif StructFileName == "PySysDBG.h":
         IpyGameDataPYFile = CodeProjectPath + "\\CoreServerGroup\\GameServer\\Script\\"
         LoadStructPath = "ChConfig.GetAppPath()"
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 09d29ce..58aa633 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -54,7 +54,12 @@
 # @param 无参数
 # @return 返回值当前的DB路径
 def GetDBPath():
-    return MapServerPath.split("ZoneServerGroup")[0] + "ZoneServerGroup\\map1_8G\\MapServer\\MapServerData\\Script\\PyMongoDB"
+    return MapServerPath + "Script\\PyMongoDB"
+
+def GetServerConfigPath():
+    ## 获取以Map为单服的服务器配置路径
+    mapID = IPY_GameWorld.IPY_GameWorld().GetMapID()
+    return MapServerPath + "ServerConfig\\m_%s" % mapID
 
 def GetServerRootPath():
     ##获取服务器根路径
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
index 7cde81b..090cf01 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
@@ -1328,7 +1328,7 @@
     ## 获取服务器ID所属主服ID
     ServerIDMainServerDict = IpyGameDataPY.GetConfigEx("ServerIDMainServerDict")
     if ServerIDMainServerDict == None:
-        filePath = ChConfig.GetDBPath() + ("\\MixServerMap_%s.json" % GetPlatform())
+        filePath = ChConfig.GetServerConfigPath() + ("\\MixServerMap_%s.json" % GetPlatform())
         if not os.path.isfile(filePath):
             SendGameErrorEx("GetMainServerIDError", "file can not found. %s" % filePath)
         else:
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 09f93a8..333ae0e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -6918,9 +6918,9 @@
     
     def __LoadFileData(self, tableName, onlyCheck=False):
         # @param onlyCheck: 是否仅检查格式,一般启动时用
-        curPath = ChConfig.GetDBPath() + "\\PySysDB\\" + tableName + ".txt"
+        curPath = ChConfig.GetServerConfigPath() + "\\PySysDB\\" + tableName + ".txt"
         if not os.path.isfile(curPath):
-            curPath = ChConfig.GetDBPath() + "\\PySysDB\\tag" + tableName + ".txt"
+            curPath = ChConfig.GetServerConfigPath() + "\\PySysDB\\tag" + tableName + ".txt"
             if not os.path.isfile(curPath):
                 ErrLog("can not find file = %s,%s" % (tableName, curPath))
                 raise Exception("can not find file = %s,%s" % (tableName, curPath))
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCRealmRefresh.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCRealmRefresh.py
index faf9446..03301ba 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCRealmRefresh.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCRealmRefresh.py
@@ -96,7 +96,7 @@
     if key in PyGameData.g_realmDiffNPCRefresh:
         return PyGameData.g_realmDiffNPCRefresh[key]
     
-    filePath = os.path.join(ChConfig.GetDBPath(), "SysDB", "tagNPCRefresh.txt")
+    filePath = os.path.join(ChConfig.GetServerConfigPath(), "SysDB", "tagNPCRefresh.txt")
     if not os.path.isfile(filePath):
         GameWorld.ErrLog("can not find file = %s" % filePath)
         raise Exception("can not find file = %s" % filePath)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Config/DBConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Config/DBConfig.py
index 785f677..52144fc 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Config/DBConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Config/DBConfig.py
@@ -155,14 +155,14 @@
         config = ConfigParser.ConfigParser()
         
         #读取数据库配置文件config\\config.ini
-        config.read(os.path.join(GlobalFunctions.getAppPath(), 'config\\config.ini'))      
+        config.read(os.path.join(GlobalFunctions.getServerConfigPath(), 'config.ini'))      
         for k, v in dbconfig.items(): 
             value = ReadCongfigValue(config, v[1], k, v[0])
             if value == None:return False
             setattr(self_module, k, value)
         
         #读取数据库配置文件PyMongoDataServer.ini
-        config.read(os.path.join(GlobalFunctions.getAppPath(), 'PyMongoDataServer.ini'))      
+        config.read(os.path.join(GlobalFunctions.getServerConfigPath(), 'PyMongoDataServer.ini'))      
         for k, v in BaseConfig.items(): 
             value = ReadCongfigValue(config, v[1], k, v[0])
             if value == None:return False
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/DBCommon/GlobalFunctions.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/DBCommon/GlobalFunctions.py
index 5ef2c0a..3e96afb 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/DBCommon/GlobalFunctions.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/DBCommon/GlobalFunctions.py
@@ -30,6 +30,9 @@
 def getAppPath():
     return ChConfig.GetDBPath()
 
+def getServerConfigPath():
+    ##单服配置路径
+    return ChConfig.GetServerConfigPath()
 
 def GetTransactionIDStr(len):
     nowtime = datetime.today()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/LogicProcess/UserCtrlDB.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/LogicProcess/UserCtrlDB.py
index 0285c5f..7ea3eda 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/LogicProcess/UserCtrlDB.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/LogicProcess/UserCtrlDB.py
@@ -82,7 +82,7 @@
     centerVersion = ""
     try:
         cfGameVer = ConfigParser.ConfigParser()
-        cfGameVer.read(os.path.join(GlobalFunctions.getAppPath(), 'GameVersion.ini'))
+        cfGameVer.read(os.path.join(GlobalFunctions.getServerConfigPath(), 'GameVersion.ini'))
         
         gameID = cfGameVer.get("config", "GameID")
         curVersion = cfGameVer.get("config", "Version")
@@ -2930,7 +2930,7 @@
                 mylog.info("###dgPlayerInit cntError accid = %s" % queryAccid)
                 PegasusCollectorProxy.ErrorReport("login data cntError accid=%s" % queryAccid)
                 dbIni = ConfigParser.ConfigParser() # 每次重新加载,确保随时修改有效
-                dbIni.read(os.path.join(GlobalFunctions.getAppPath(), 'PyMongoDataServer.ini'))
+                dbIni.read(os.path.join(GlobalFunctions.getServerConfigPath(), 'PyMongoDataServer.ini'))
                 DataCntErrorKick = dbIni.has_option("dataset", "DataCntErrorKick") and (dbIni.getint("dataset", "DataCntErrorKick") == 1) # 数据存取条数异常时是否禁止登录
                 if DataCntErrorKick:
                     self.sendFailString(CommonDefine.dgPlayerInit, pack, disAccStateError)
@@ -5876,95 +5876,95 @@
     #读取静态表,与数据库无关
     def OnGetGameData(self):
         sysData = DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinNPC,
-                                                    os.path.join(GlobalFunctions.getAppPath(),
+                                                    os.path.join(GlobalFunctions.getServerConfigPath(),
                                                                     CommonDefine.SYSDB_PATH,
                                                                     'tagChinNPC.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagNPCRefresh,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagNPCRefresh.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinSkill,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinSkill.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinExp,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinExp.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinItem,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinItem.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagTransportRefresh,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagTransportRefresh.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinShopItem,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinShopItem.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagBornRefresh,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagBornRefresh.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinMixItem,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinMixItem.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagBuildEquip,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagBuildEquip.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagSuiteActivation,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagSuiteActivation.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagSuiteEffect,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagSuiteEffect.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagRepeatEvent,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagRepeatEvent.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagEffectRefresh,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagEffectRefresh.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinMap,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagChinMap.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagDBStoreItem,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagDBStoreItem.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagOnMissionDelete,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagOnMissionDelete.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPet,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagPet.txt'))   
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetGrade,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagPetGrade.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetFriendliness,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagPetFriendliness.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetExp,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagPetExp.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagNPC_Item_Pet,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagNPC_Item_Pet.txt'))
         sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagFlyObjBaseInfo,
-                                            os.path.join(GlobalFunctions.getAppPath(),
+                                            os.path.join(GlobalFunctions.getServerConfigPath(),
                                                         CommonDefine.SYSDB_PATH,
                                                         'tagFlyObjBaseInfo.txt'))
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
index 0acb2a0..08d278d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
@@ -220,7 +220,7 @@
     global PyMongoDataServerConfig
     
     if not PyMongoDataServerConfig:
-        dbAPPath = ChConfig.GetDBPath() + "\\PyMongoDataServer.ini"
+        dbAPPath = ChConfig.GetServerConfigPath() + "\\PyMongoDataServer.ini"
         
         if not os.path.isfile(dbAPPath):
             GameWorld.Log('无法找到文件 = %s'%(dbAPPath))
@@ -261,7 +261,7 @@
     if key not in Def_DBCfgFilePath:
         GameWorld.Log('DB配置中未发现Key文件 = %s' % (key))
         return
-    filePath = ChConfig.GetDBPath() + Def_DBCfgFilePath[key]
+    filePath = ChConfig.GetServerConfigPath() + Def_DBCfgFilePath[key]
     
     retData = __ReadConfigDataEx(key, filePath, needEval)
     if not retData:

--
Gitblit v1.8.0